Ejemplo n.º 1
0
    void LoadWorkInspectionDetails()
    {
        try
        {
            if (ddlJudgeList.SelectedIndex > 0 && txtFiscalYear.Text != "")
            {
                ATTJudgeWorkInspection obj = BLLJudgeWorkInspection.GetJudgeWorkInspection(int.Parse(ddlJudgeList.SelectedValue), txtFiscalYear.Text);


                if (obj != null)
                {
                    txtInspection.Text = obj.InspEmpName.ToString();
                    txtInspection.Attributes.Add("InspectorID", obj.InspEmpID.ToString());
                    txtInspectionDate.Text = obj.InspectionDate.ToShortDateString();

                    List <ATTJudgeWorkInspectionDetails> list = obj.Details;

                    List <ATTJudgeWorkInspectionDetails> list1 = list.FindAll(delegate(ATTJudgeWorkInspectionDetails detail)
                    {
                        return(detail.InspectionCaseNo != null && detail.InspectionCaseNo != 0);
                    });



                    Session["WorkDetailsLst"]           = list1;
                    grdWorkInspectionDetails.DataSource = list1;
                    grdWorkInspectionDetails.DataBind();

                    Session["AddEdit"] = "E";

                    btnSave.Visible   = true;
                    btnCancel.Visible = true;

                    ddlJudgeList.Enabled  = false;
                    txtFiscalYear.Enabled = false;

                    cpeDemo.Collapsed = true;
                    Panel3.Enabled    = false;
                }
                else
                {
                    grdWorkInspectionDetails.DataSource = null;
                    grdWorkInspectionDetails.DataBind();

                    Session["WorkDetailsLst"] = null;
                    Session["AddEdit"]        = "A";
                }
            }
            else
            {
                Session["AddEdit"] = "A";
            }
        }
        catch (Exception ex)
        {
            this.lblStatusMessage.Text = ex.Message.ToString();
            this.programmaticModalPopup.Show();
        }
    }
Ejemplo n.º 2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            if (grdWorkInspectionDetails.Rows.Count < 1)
            {
                return;
            }


            int    i          = 0;
            string errmessage = "<P><b><U>! Attention </U></b></P>";

            if (ddlJudgeList.SelectedIndex < 1)
            {
                i++; errmessage += i.ToString() + ") Select Judge <br />";
            }
            if (!txtInspection.HasAttributes || txtInspection.Text == "")
            {
                i++; errmessage += i.ToString() + ") Inspector Missing  <br />";
            }
            if (txtInspectionDate.Text == "")
            {
                i++; errmessage += i.ToString() + ") Inspection Date Missing  <br />";
            }
            else
            {
                try
                {
                    DateTime dt = DateTime.Parse(txtInspectionDate.Text);
                }
                catch (Exception)
                {
                    i++; errmessage += i.ToString() + ") Invalid Date  <br />";
                }
            }

            if (i > 0)
            {
                this.lblStatusMessage.Text = errmessage;
                this.programmaticModalPopup.Show();
                return;
            }


            InspectionListInsert = new List <ATTJudgeWorkInspectionDetails>();
            int j = 0;

            foreach (ATTJudgeWorkList work in (List <ATTJudgeWorkList>)Session["WorkList"])
            {
                if (j > 0)
                {
                    ATTJudgeWorkInspectionDetails inspdet = new ATTJudgeWorkInspectionDetails();

                    inspdet.JwcID            = int.Parse(work.JwcID.ToString());
                    inspdet.JwcName          = work.JwcName;
                    inspdet.Action           = (Session["AddEdit"].ToString() == "A" ? "A" : "");
                    inspdet.EmployeeID       = int.Parse(ddlJudgeList.SelectedValue);
                    inspdet.EntryBy          = entryBy;
                    inspdet.EntryOn          = DateTime.Now;
                    inspdet.FiscalYear       = txtFiscalYear.Text;
                    inspdet.InspectionCaseNo = null;
                    inspdet.IsReasonValid    = null;
                    inspdet.NoDoneReason     = "";
                    inspdet.NoOfCase         = null;
                    inspdet.Remarks          = "";
                    inspdet.WorkDone         = false;

                    InspectionListInsert.Add(inspdet);
                }
                j++;
            }

            foreach (ATTJudgeWorkInspectionDetails inspDetails in (List <ATTJudgeWorkInspectionDetails>)Session["WorkDetailsLst"])
            {
                int k = InspectionListInsert.FindIndex(delegate(ATTJudgeWorkInspectionDetails detail)
                {
                    return(detail.JwcID == inspDetails.JwcID);
                });

                InspectionListInsert[k] = inspDetails;
            }

            ATTJudgeWorkInspection workInspection = new ATTJudgeWorkInspection();
            workInspection.EmployeeID = int.Parse(ddlJudgeList.SelectedValue);
            workInspection.FiscalYear = txtFiscalYear.Text;

            string st = txtInspection.Attributes["InspectorID"].ToString();
            workInspection.InspEmpID      = int.Parse(txtInspection.Attributes["InspectorID"].ToString());
            workInspection.InspectionDate = DateTime.Parse(txtInspectionDate.Text);
            workInspection.EntryBy        = entryBy;



            workInspection.Details = InspectionListInsert;
            workInspection.Action  = Session["AddEdit"].ToString();


            if (BLLJudgeWorkInspection.SaveJudgeWorkInspection(workInspection))
            {
                ClearControls(true);
                btnSave.Visible            = true;
                btnCancel.Visible          = true;
                this.lblStatusMessage.Text = "Information Saved.";
                this.programmaticModalPopup.Show();
            }
            else
            {
                this.lblStatusMessage.Text = "Problem Saving Information .";
                this.programmaticModalPopup.Show();
            }
        }
        catch (Exception ex)
        {
            this.lblStatusMessage.Text = ex.Message.ToString();
            this.programmaticModalPopup.Show();
        }
    }