Exemplo n.º 1
0
        protected void SaveIssue()
        {
            bool    success;
            decimal decVal;

            // update the INCIDENT record
            qualityIssue.Incident.INCIDENT_DT = WebSiteCommon.ConvertDateFromString(tbDateDetected.Text, Convert.ToDateTime(WebSiteCommon.GetXlatValue("effDates", "MIN")));
            qualityIssue.Incident.DESCRIPTION = tbIssueDesc.Text.Trim();
            qualityIssue.Incident.COMPANY_ID  = SessionManager.SessionContext.ActiveCompany().COMPANY_ID;
            qualityIssue.Incident.BUS_ORG_ID  = SessionManager.UserContext.BusinessOrg.BUS_ORG_ID;
            qualityIssue.Incident.PLANT_ID    = Convert.ToDecimal(ddlPlant.SelectedValue);
            if (ddlPlantLine.SelectedIndex > -1)
            {
                qualityIssue.Incident.PLANT_LINE_ID = Convert.ToDecimal(ddlPlantLine.SelectedValue);
            }

            // QUALITY ISSUE records
            qualityIssue.IssueOccur.PROBLEM_TYPE = ddlQualityIssueType.SelectedItem.Text;
            qualityIssue.IssueOccur.SOURCE       = rblSource.SelectedValue;
            if (ddlCustomer.SelectedIndex > -1)
            {
                qualityIssue.IssueOccur.CUSTOMER_ID = Convert.ToDecimal(ddlCustomer.SelectedValue);
            }
            if (ddlCustomerPlant.SelectedIndex > -1)
            {
                qualityIssue.IssueOccur.CUSTOMER_PLANT_ID = Convert.ToDecimal(ddlCustomerPlant.SelectedValue);
            }

            qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().LOT_NUM       = tbNCLotNum.Text;
            qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().CONTAINER_NUM = tbNCContainer.Text;
            if (decimal.TryParse(tbNCTotalQty.Text.Trim(), out decVal))
            {
                qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().TOTAL_QTY = decVal;
            }
            if (decimal.TryParse(tbNCSampleQty.Text.Trim(), out decVal))
            {
                qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().INSPECT_QTY = decVal;
            }
            if (decimal.TryParse(tbNCNonConformQty.Text.Trim(), out decVal))
            {
                qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().INSPECT_NC_QTY = decVal;
            }
            qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().TOTAL_NC_QTY = (qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().INSPECT_NC_QTY / qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().INSPECT_QTY) * qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().TOTAL_QTY;

            int          nrow = -1;
            DropDownList ddl;
            HiddenField  hf;

            foreach (GridViewRow row in gvQISamples.Rows)
            {
                ++nrow;
                ddl = (DropDownList)row.FindControl("ddlPrimaryNC");
                qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().QI_OCCUR_SAMPLE.First().PROBLEM_PRIMARY = ddl.SelectedItem.Text;
                ddl = (DropDownList)row.FindControl("ddlSecondaryNC");
                qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().QI_OCCUR_SAMPLE.First().PROBLEM_SECONDARY = ddl.SelectedItem.Text;
                TextBox tb    = (TextBox)row.FindControl("tbNCCount");
                int     count = 1;
                if (int.TryParse(tb.Text.Trim(), out count))
                {
                    qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().QI_OCCUR_SAMPLE.First().PROBLEM_COUNT = count;
                }
                hf = (HiddenField)row.FindControl("hfAttachmentID");
                if (!String.IsNullOrEmpty(hf.Value))
                {
                    qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().QI_OCCUR_SAMPLE.First().ATTACHMENT_ID = Convert.ToInt32(hf.Value);
                }
                else
                {
                    qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().QI_OCCUR_SAMPLE.First().ATTACHMENT_ID = 0;
                }
            }
            qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().QI_OCCUR_SAMPLE.First().SAMPLE_COMMENTS = tbObservations.Text.Trim();

            qualityIssue.IssueOccur.DISPOSITION = ddlDisposition.SelectedValue;
            qualityIssue.IssueOccur.RESPONSIBLE = rblResponsible.SelectedValue;
            qualityIssue.IssueOccur.ACTION_REQD = cbActionRequired.Checked;
            qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().ITEM_COMMENTS = tbComments.Text.Trim();

            if (QualityIssue.AddIssue(qualityIssue) != null)
            {
                btnPrintLabel.OnClientClick = "Popup('../Problem/QualityIssue_Label.aspx?issue=" + qualityIssue.IssueOccur.QIO_ID.ToString() + "', 'newPage', 600, 450); return false;";
                DisplayIssue();
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alertResult('hfAlertSaveSuccess');", true);
            }
        }