please help me, iam newbie
here i have a problem
I have thousands of data in the datatable, I take this example only.
I want to checklist
1) unitid checklist must not be more than one if more than one then the error
2) may not be the same unitid checklist, if the same then an error
3) unitid must be the same but the duedate must be different, if the same then an error
4) The duedate must be different unitid must be the same, otherwise error
please help the masters
Thank you very much
I have created the code as below but it is not optimal
if (JobType == "MUnit1bill")
{
if (dt.Rows.Count > 0)
{
DataView view = new DataView(dt);
DataTable distinctValues1 = view.ToTable(true, "Unitid");
DataTable distinctValues2 = view.ToTable(true, "Duedatebaru");
DataTable distinctbill = view.ToTable(true, "BillingGroupID");
DataTable distinctcust = view.ToTable(true, "Customerid");
if (distinctValues1.Rows.Count == 1)
{
lblMessage.Text = "unitid must be different";
error = true;
}
if (distinctValues2.Rows.Count > 1)
{
lblMessage.Text = "Duedatebaru must not be more than one";
error = true;
}
if (distinctbill.Rows.Count != distinctcust.Rows.Count)
{
lblMessage.Text = "Billing groups cannot be more than one";
error = true;
}
if (error)
{
GridView1.DataSource = null;
GridView1.DataBind();
dtChecked.Clear();
}}
if (!error)
{
GridView1.DataSource = dtChecked.DefaultView;
GridView1.DataBind();
dtChecked.Clear();
}
}
Aucun commentaire:
Enregistrer un commentaire