hello
I am trying hide/show button for condition if i can use with cells text footer ?
private void SearchCustomers()
{
try
{
string constr = ConfigurationManager.ConnectionStrings["kankonConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand())
{
string sql = "SELECT * FROM Table_vacation";
if (!string.IsNullOrEmpty(txtSearch.Text.Trim()))
{
sql += " WHERE (idnamev LIKE '%' + @idnamev + '%')";
sql += " OR (idcivilv LIKE '%' + @idcivilv + '%')";
sql += " AND (datestart LIKE '%' + @datestart + '%' OR ISNULL(@datestart,'') = '') ";
sql += " AND (namevacation LIKE '%' + @namevacation + '%' OR ISNULL(@namevacation,'') = '') ";
if (!string.IsNullOrEmpty(txtSearch.Text.Trim()))
{
cmd.Parameters.AddWithValue("@idnamev", txtSearch.Text.ToString());
}
if (!string.IsNullOrEmpty(txtSearch.Text.Trim()))
{
cmd.Parameters.AddWithValue("@idcivilv", txtSearch.Text.ToString());
}
if (int.Parse(ddlYear.SelectedItem.Value) == 0)
{
cmd.Parameters.AddWithValue("@datestart", (object)DBNull.Value);
}
else
{
cmd.Parameters.AddWithValue("@datestart", this.ddlYear.SelectedItem.Text.Trim());
}
if (int.Parse(ddlDepartment.SelectedItem.Value) == 0)
{
cmd.Parameters.AddWithValue("@namevacation", (object)DBNull.Value);
}
else
{
cmd.Parameters.AddWithValue("@namevacation", this.ddlDepartment.SelectedItem.Text.Trim());
}
}
cmd.CommandText = sql;
cmd.Connection = con;
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
sda.Fill(dt);
gvFiles.DataSource = dt;
gvFiles.DataBind();
gvFiles.FooterRow.Cells[13].Text = (dt.Compute("Sum(totalva)", ""), "Day").ToString();
gvFiles.FooterRow.Cells[14].Text = "76 Total Point Year";
gvFiles.FooterRow.Cells[15].Text = ("total point left", 76 - Convert.ToInt32(dt.Compute("Sum(totalva)", ""))).ToString();
int myvalue = Int32.Parse(Label_day.Text);
if (myvalue <= 14)
{
gvFiles.FooterRow.Cells[3].Text = ("Left", 35 - Convert.ToInt32(dt.Compute("Sum(totalva)", "")), "Day").ToString();
gvFiles.FooterRow.Cells[2].Text = ("Total Point 35 year");
}
else
if (myvalue >= 16)
{
gvFiles.FooterRow.Cells[3].Text = ("Left", 45 - Convert.ToInt32(dt.Compute("Sum(totalva)", "")), "Day").ToString();
gvFiles.FooterRow.Cells[2].Text = ("Total Point 45 year");
}
int totalhidebutton = Convert.ToInt32(gvFiles.FooterRow.Cells[15].Text);
if (totalhidebutton <= 0)
{
AddUsers.Enabled = false;
}
else if (totalhidebutton > 0 && totalhidebutton <= 76)
{
AddUsers.Enabled = true;
}
}
}
}
}
catch (Exception)
{
}
}