I have a Multiple Select DROPDOWNLIST
to select items. See the Dropdownlist
below
What I am doing is, I am selecting 2
items from the list. One of PROCESSED
and another of PENDING
So what's happening wrong here is, when the condition is PROCESSED
it works properly and goes in IF
condition but second time it is PENDING
but still it goes in the IF
condition.
using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString()))
{
using (SqlCommand sqcmd = new SqlCommand("select month(a.dt_of_leave)month, year(a.dt_of_leave)year " +
"from emp_mst a where month(a.dt_of_leave) >= month(getdate())-1 and " +
"year(a.dt_of_leave)= case when month(getdate())=1 " +
"then year(getdate())-1 else year(getdate()) end " +
"and emp_card_no IN (" + str_emp_sel + ") order by emp_name", conn))
{
SqlDataAdapter damonthyear = new SqlDataAdapter(sqcmd);
damonthyear.Fill(dtspmonthyear);
for (i = 0; i < dtspmonthyear.Rows.Count; i++)
{
if (cmbEmp_Name.SelectedItem.Text.Contains("PROCESSED") == true)
{
//CF.ExecuteQuerry("exec Emp_Resign_Allocate_Leave '" + str_emp_sel + "','" + dtspmonthyear.Rows[0]["month"].ToString() + "', '" + dtspmonthyear.Rows[0]["year"].ToString() + "'");
}
else
{
// not going in else for `PENDING`
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire