protected void btnSubmit_Click(object sender, EventArgs e)
{
SqlTransaction trans = null;
try
{
JobOrderBL bl = new JobOrderBL();
if (btnSubmit.Text == "SUBMIT")
{
DataTable dt = (DataTable)Session["temp"];
DataRow[] rows = dt.Select();
bl.JobOrderDate = Convert.ToDateTime(dpDate.SelectedDate.ToString());
bl.JobApprovalID = Convert.ToInt64(ddlJobApprovalNO.SelectedValue.ToString());
bl.Remarks = txtRemarks.Text;
Int64 masterID = bl.CreateMaster(trans);
for (int index = 0; index < dt.Rows.Count; index++)
{
String QTY = Convert.ToString(dt.Rows[index]["OrderingQTY"].ToString());
if (QTY.ToString().Length <= 0)
{
continue;
}
bl.JOMasID = Convert.ToInt64(masterID.ToString());
bl.JobItemName = Convert.ToString(dt.Rows[index]["JobItemName"]);
bl.QTY = Convert.ToDouble(QTY);
bl.Rate = Convert.ToDecimal(dt.Rows[index]["Rate"].ToString());
bl.CreateDetails(trans);
}
}
else
{
bl.JOMasID = Convert.ToInt64(txtJOMasID.Text);
bl.JobApprovalID = Convert.ToInt64(ddlJobApprovalNO.SelectedValue.ToString());
bl.JobOrderDate = Convert.ToDateTime(dpDate.SelectedDate.ToString());
bl.Remarks = txtRemarks.Text;
bl.UpdateMaster();
Response.Redirect("JobOrder.aspx");
}
trans.Commit();
}
catch (Exception ex)
{
if (trans != null)
trans.Rollback();
lblMessage.Text=Convert.ToString(ex);
}
}