hello,
its good idea to mearge to thing
when i search name from database then i want use this link for merge it
so i can found all the record this user, when i select a year with 1 button
when i search for a user and not select a Year from DropDownList well show everything about this user
when i search a user and add select a Year option well show only his data for a year like (2019)
show all data this user record by 2019
my code C#
private void SearchCustomers()
{
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 + '%' OR idcivilv LIKE @idcivilv + '%' ORDER BY [datestart] DESC";
cmd.Parameters.AddWithValue("@idnamev", txtSearch.Text.Trim());
cmd.Parameters.AddWithValue("@idcivilv", txtSearch.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[11].Text = "الرصيد المستخدك";
gvFiles.FooterRow.Cells[12].Text = dt.Compute("Sum(totalva)", "").ToString();
gvFiles.FooterRow.Cells[13].Text = ("لرصيد المتبقي", 76 - Convert.ToInt32(dt.Compute("Sum(totalva)", ""))).ToString();
}
}
}
}
HTML
<asp:TextBox ID="txtSearch" runat="server" AutoPostBack="True" BackColor="#FFFF99" Font-Bold="False" Font-Names="Arial" Font-Size="Medium" Height="30px" placeholder="الاسم / رقم المدنى" style="text-align: center" Width="272px" TextMode="Search" OnTextChanged="txtSearch_TextChanged" ></asp:TextBox>
<asp:Button Text="بحث" runat="server" OnClick="Search" Font-Bold="True" Font-Names="Arial" Font-Size="14pt" ForeColor="#009900" ID="Button33" />
<br />
<asp:DropDownList ID="ddlYear" runat="server">
<asp:ListItem Text="Select" Value="0" Selected="True" />
<asp:ListItem Text="2018" Value="1" />
<asp:ListItem Text="2019" Value="2" />
<asp:ListItem Text="2020" Value="3" />
<asp:ListItem Text="2021" Value="4" />
</asp:DropDownList>
<asp:DropDownList ID="ddlDepartment" runat="server">
<asp:ListItem Text="Select" Value="0" Selected="True" />
<asp:ListItem Text="اجازة دورية" Value="1" />
<asp:ListItem Text="اقرار عودة" Value="2" />
</asp:DropDownList>
<asp:Button Text="Get Report" runat="server" ID="btnGetReport" OnClick="GetReport" />