Example #1
0
        /// <summary>
        /// 保存业务信息
        /// </summary>
        /// <param name="billInfo">业务总单信息</param>
        public void SaveInfo(Bus_Quality_8DReport billInfo)
        {
            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            ctx.Connection.Open();
            ctx.Transaction = ctx.Connection.BeginTransaction();

            try
            {
                Flow_FlowInfo info =
                    _serviceFlow.GetNowFlowInfo(_serviceFlow.GetBusinessTypeID(CE_BillTypeEnum.纠正预防措施报告, null),
                                                billInfo.BillNo);

                Bus_Quality_8DReport tempInfo = new Bus_Quality_8DReport();

                var varData = from a in ctx.Bus_Quality_8DReport
                              where a.BillNo == billInfo.BillNo
                              select a;

                if (varData.Count() == 1)
                {
                    tempInfo = varData.Single();
                    AssignmentValue(billInfo, info.FlowID, ref tempInfo);
                }
                else if (varData.Count() == 0)
                {
                    tempInfo.F_Id = Guid.NewGuid().ToString();
                    AssignmentValue(billInfo, info.FlowID, ref tempInfo);
                    ctx.Bus_Quality_8DReport.InsertOnSubmit(tempInfo);
                }
                else
                {
                    throw new Exception("单据数据不唯一");
                }

                ctx.SubmitChanges();

                switch (info.FlowID)
                {
                case 1112:
                    //D2
                    var varData1 = from a in ctx.Bus_Quality_8DReport_D2_Crew
                                   where a.ReportId == tempInfo.F_Id
                                   select a;

                    ctx.Bus_Quality_8DReport_D2_Crew.DeleteAllOnSubmit(varData1);

                    foreach (Bus_Quality_8DReport_D2_Crew item in billInfo.Bus_Quality_8DReport_D2_Crew.ToList())
                    {
                        Bus_Quality_8DReport_D2_Crew tempItem = new Bus_Quality_8DReport_D2_Crew();

                        tempItem.F_Id            = Guid.NewGuid().ToString();
                        tempItem.ReportId        = tempInfo.F_Id;
                        tempItem.PersonnelWorkId = item.PersonnelWorkId;

                        ctx.Bus_Quality_8DReport_D2_Crew.InsertOnSubmit(tempItem);
                    }

                    ctx.SubmitChanges();

                    //D5
                    var varData2 = from a in ctx.Bus_Quality_8DReport_D5_Reason
                                   where a.ReportId == tempInfo.F_Id
                                   select a;

                    ctx.Bus_Quality_8DReport_D5_Reason.DeleteAllOnSubmit(varData2);

                    foreach (Bus_Quality_8DReport_D5_Reason item in billInfo.Bus_Quality_8DReport_D5_Reason.ToList())
                    {
                        Bus_Quality_8DReport_D5_Reason tempItem = new Bus_Quality_8DReport_D5_Reason();

                        tempItem.F_Id        = Guid.NewGuid().ToString();
                        tempItem.ReportId    = tempInfo.F_Id;
                        tempItem.Description = item.Description;
                        tempItem.ReasonType  = item.ReasonType;

                        ctx.Bus_Quality_8DReport_D5_Reason.InsertOnSubmit(tempItem);
                    }

                    ctx.SubmitChanges();

                    //D6
                    var varData3 = from a in ctx.Bus_Quality_8DReport_D6_Countermeasure
                                   where a.ReportId == tempInfo.F_Id
                                   select a;

                    ctx.Bus_Quality_8DReport_D6_Countermeasure.DeleteAllOnSubmit(varData3);

                    foreach (Bus_Quality_8DReport_D6_Countermeasure item in billInfo.Bus_Quality_8DReport_D6_Countermeasure.ToList())
                    {
                        Bus_Quality_8DReport_D6_Countermeasure tempItem = new Bus_Quality_8DReport_D6_Countermeasure();

                        tempItem.F_Id               = Guid.NewGuid().ToString();
                        tempItem.ReportId           = tempInfo.F_Id;
                        tempItem.Description        = item.Description;
                        tempItem.CountermeasureType = item.CountermeasureType;
                        tempItem.Duty               = item.Duty;
                        tempItem.FinishDate         = item.FinishDate;

                        ctx.Bus_Quality_8DReport_D6_Countermeasure.InsertOnSubmit(tempItem);
                    }

                    ctx.SubmitChanges();

                    //D7
                    var varData4 = from a in ctx.Bus_Quality_8DReport_D7_Prevent
                                   where a.ReportId == tempInfo.F_Id
                                   select a;

                    ctx.Bus_Quality_8DReport_D7_Prevent.DeleteAllOnSubmit(varData4);

                    foreach (Bus_Quality_8DReport_D7_Prevent item in billInfo.Bus_Quality_8DReport_D7_Prevent.ToList())
                    {
                        Bus_Quality_8DReport_D7_Prevent tempItem = new Bus_Quality_8DReport_D7_Prevent();

                        tempItem.F_Id          = Guid.NewGuid().ToString();
                        tempItem.ReportId      = tempInfo.F_Id;
                        tempItem.Department    = item.Department;
                        tempItem.ItemsType     = item.ItemsType;
                        tempItem.OperationTime = item.OperationTime;

                        ctx.Bus_Quality_8DReport_D7_Prevent.InsertOnSubmit(tempItem);
                    }

                    ctx.SubmitChanges();
                    break;

                case 1114:
                    //D8
                    var varData5 = from a in ctx.Bus_Quality_8DReport_D8_Verify
                                   where a.ReportId == tempInfo.F_Id
                                   select a;

                    ctx.Bus_Quality_8DReport_D8_Verify.DeleteAllOnSubmit(varData5);

                    foreach (Bus_Quality_8DReport_D8_Verify item in billInfo.Bus_Quality_8DReport_D8_Verify.ToList())
                    {
                        Bus_Quality_8DReport_D8_Verify tempItem = new Bus_Quality_8DReport_D8_Verify();

                        tempItem.F_Id          = Guid.NewGuid().ToString();
                        tempItem.ReportId      = tempInfo.F_Id;
                        tempItem.OperationDate = item.OperationDate;
                        tempItem.Result        = item.Result;
                        tempItem.WayMode       = item.WayMode;
                        tempItem.Duty          = item.Duty;
                        tempItem.Effect        = item.Effect;

                        ctx.Bus_Quality_8DReport_D8_Verify.InsertOnSubmit(tempItem);
                    }

                    ctx.SubmitChanges();
                    break;

                default:
                    break;
                }

                ctx.Transaction.Commit();
            }
            catch (Exception ex)
            {
                ctx.Transaction.Rollback();
                throw new Exception(ex.Message);
            }
        }
Example #2
0
        void GetInfo()
        {
            object objValue = null;

            _Lnq_BillInfo.Badness    = txtBadness.Text;
            _Lnq_BillInfo.BatchNo    = txtBatchNo.Text;
            _Lnq_BillInfo.BillNo     = txtBillNo.Text;
            _Lnq_BillInfo.GoodsInfo  = txtGoodsInfo.Text;
            _Lnq_BillInfo.HappenDate = dtpHappenDate.Value;
            _Lnq_BillInfo.HappenSite = txtHappenSite.Text;
            _Lnq_BillInfo.Involve    = txtInvolve.Text;
            _Lnq_BillInfo.Theme      = txtTheme.Text;

            //D1
            _Lnq_BillInfo.D1_DescribePhenomenon = txtD1_DescribePhenomenon.Text;

            objValue = GetControlValue(llbD1_DescribePhenomenon_Accessory);
            _Lnq_BillInfo.D1_DescribePhenomenon_Accessory = objValue == null ? null : objValue.ToString();

            foreach (Control cl in plD1_DutyDepartment.Controls)
            {
                if (cl is RadioButton)
                {
                    RadioButton rb = cl as RadioButton;
                    if (rb.Checked)
                    {
                        _Lnq_BillInfo.D1_DutyDepartment = rb.Text;
                        break;
                    }
                }
            }

            objValue = GetControlValue(txtD1_InfluenceElseProduct_Explain);
            _Lnq_BillInfo.D1_InfluenceElseProduct_Explain = objValue == null ? null : objValue.ToString();

            objValue = GetControlValue(dtpD1_LastHappenTime);
            _Lnq_BillInfo.D1_LastHappenTime = objValue == null ? null : (DateTime?)objValue;


            //D2
            _Lnq_BillInfo.D2_DutyPersonnel = txtD2_DutyPersonnel.Tag == null ? null : txtD2_DutyPersonnel.Tag.ToString();
            _Lnq_BillInfo.Bus_Quality_8DReport_D2_Crew.Clear();
            foreach (DataGridViewRow dgvr in dgvD2_Crew.Rows)
            {
                Bus_Quality_8DReport_D2_Crew temp = new Bus_Quality_8DReport_D2_Crew();

                temp.F_Id            = Guid.NewGuid().ToString();
                temp.ReportId        = _Lnq_BillInfo.F_Id;
                temp.PersonnelWorkId = dgvr.Cells["D2PersonnelWorkId"].Value.ToString();

                _Lnq_BillInfo.Bus_Quality_8DReport_D2_Crew.Add(temp);
            }

            //D3
            objValue = GetControlValue(txtD3_Reason_Incoming);
            _Lnq_BillInfo.D3_Reason_Incoming = objValue == null ? null : objValue.ToString();
            objValue = GetControlValue(txtD3_Reason_Producted);
            _Lnq_BillInfo.D3_Reason_Producted = objValue == null ? null : objValue.ToString();
            objValue = GetControlValue(txtD3_Reason_Production);
            _Lnq_BillInfo.D3_Reason_Production = objValue == null ? null : objValue.ToString();
            objValue = GetControlValue(txtD3_Reason_Send);
            _Lnq_BillInfo.D3_Reason_Send = objValue == null ? null : objValue.ToString();

            //D4
            objValue = GetControlValue(txtD4_Else_Measure);
            _Lnq_BillInfo.D4_Else_Measure = objValue == null ? null : objValue.ToString();
            objValue = GetControlValue(txtD4_Else_NG);
            _Lnq_BillInfo.D4_Else_NG = objValue == null ? null : objValue.ToString();
            objValue = GetControlValue(txtD4_Else_OK);
            _Lnq_BillInfo.D4_Else_OK = objValue == null ? null : objValue.ToString();
            objValue = GetControlValue(txtD4_FinishClient_Measure);
            _Lnq_BillInfo.D4_FinishClient_Measure = objValue == null ? null : objValue.ToString();
            objValue = GetControlValue(txtD4_FinishClient_NG);
            _Lnq_BillInfo.D4_FinishClient_NG = objValue == null ? null : objValue.ToString();
            objValue = GetControlValue(txtD4_FinishClient_OK);
            _Lnq_BillInfo.D4_FinishClient_OK = objValue == null ? null : objValue.ToString();
            objValue = GetControlValue(txtD4_FinishCom_Measure);
            _Lnq_BillInfo.D4_FinishCom_Measure = objValue == null ? null : objValue.ToString();
            objValue = GetControlValue(txtD4_FinishCom_NG);
            _Lnq_BillInfo.D4_FinishCom_NG = objValue == null ? null : objValue.ToString();
            objValue = GetControlValue(txtD4_FinishCom_OK);
            _Lnq_BillInfo.D4_FinishCom_OK = objValue == null ? null : objValue.ToString();
            objValue = GetControlValue(txtD4_Loading_Measure);
            _Lnq_BillInfo.D4_Loading_Measure = objValue == null ? null : objValue.ToString();
            objValue = GetControlValue(txtD4_Loading_NG);
            _Lnq_BillInfo.D4_Loading_NG = objValue == null ? null : objValue.ToString();
            objValue = GetControlValue(txtD4_Loading_OK);
            _Lnq_BillInfo.D4_Loading_OK = objValue == null ? null : objValue.ToString();
            objValue = GetControlValue(txtD4_Semi_Measure);
            _Lnq_BillInfo.D4_Semi_Measure = objValue == null ? null : objValue.ToString();
            objValue = GetControlValue(txtD4_Semi_NG);
            _Lnq_BillInfo.D4_Semi_NG = objValue == null ? null : objValue.ToString();
            objValue = GetControlValue(txtD4_Semi_OK);
            _Lnq_BillInfo.D4_Semi_OK = objValue == null ? null : objValue.ToString();

            _Lnq_BillInfo.D4_HowIdentify = txtD4_HowIdentify.Text;

            //D5
            _Lnq_BillInfo.D5_ReasonAnalysis = txtD5_ReasonAnalysis.Text;
            objValue = GetControlValue(llbD5_ReasonAnalysis_Accessory);
            _Lnq_BillInfo.D5_ReasonAnalysis_Accessory = objValue == null ? null : objValue.ToString();

            _Lnq_BillInfo.Bus_Quality_8DReport_D5_Reason.Clear();
            foreach (DataGridViewRow dgvr in dgvD5_Reason_Out.Rows)
            {
                Bus_Quality_8DReport_D5_Reason tempInfo = new Bus_Quality_8DReport_D5_Reason();

                tempInfo.F_Id        = Guid.NewGuid().ToString();
                tempInfo.ReportId    = _Lnq_BillInfo.F_Id;
                tempInfo.Description = dgvr.Cells["D5Out_Description"].Value.ToString();
                tempInfo.ReasonType  = dgvD5_Reason_Out.Parent.Text;

                _Lnq_BillInfo.Bus_Quality_8DReport_D5_Reason.Add(tempInfo);
            }

            foreach (DataGridViewRow dgvr in dgvD5_Reason_Pro.Rows)
            {
                Bus_Quality_8DReport_D5_Reason tempInfo = new Bus_Quality_8DReport_D5_Reason();

                tempInfo.F_Id        = Guid.NewGuid().ToString();
                tempInfo.ReportId    = _Lnq_BillInfo.F_Id;
                tempInfo.Description = dgvr.Cells["D5Pro_Description"].Value.ToString();
                tempInfo.ReasonType  = dgvD5_Reason_Pro.Parent.Text;

                _Lnq_BillInfo.Bus_Quality_8DReport_D5_Reason.Add(tempInfo);
            }

            //D6
            _Lnq_BillInfo.Bus_Quality_8DReport_D6_Countermeasure.Clear();

            foreach (DataGridViewRow dgvr in dgvD6_Countermeasure_Out.Rows)
            {
                Bus_Quality_8DReport_D6_Countermeasure tempInfo = new Bus_Quality_8DReport_D6_Countermeasure();

                tempInfo.F_Id               = Guid.NewGuid().ToString();
                tempInfo.ReportId           = _Lnq_BillInfo.F_Id;
                tempInfo.CountermeasureType = dgvD6_Countermeasure_Out.Parent.Text;
                tempInfo.Description        = dgvr.Cells["D6Out_Description"].Value.ToString();
                tempInfo.Duty               = dgvr.Cells["D6Out_Duty"].Value.ToString();
                tempInfo.FinishDate         = Convert.ToDateTime(dgvr.Cells["D6Out_FinishDate"].Value);

                _Lnq_BillInfo.Bus_Quality_8DReport_D6_Countermeasure.Add(tempInfo);
            }

            foreach (DataGridViewRow dgvr in dgvD6_Countermeasure_Pro.Rows)
            {
                Bus_Quality_8DReport_D6_Countermeasure tempInfo = new Bus_Quality_8DReport_D6_Countermeasure();

                tempInfo.F_Id               = Guid.NewGuid().ToString();
                tempInfo.ReportId           = _Lnq_BillInfo.F_Id;
                tempInfo.CountermeasureType = dgvD6_Countermeasure_Pro.Parent.Text;
                tempInfo.Description        = dgvr.Cells["D6Pro_Description"].Value.ToString();
                tempInfo.Duty               = dgvr.Cells["D6Pro_Duty"].Value.ToString();
                tempInfo.FinishDate         = dgvr.Cells["D6Pro_FinishDate"].Value == null ||
                                              GeneralFunction.IsNullOrEmpty(dgvr.Cells["D6Pro_FinishDate"].Value.ToString()) ?
                                              null : (DateTime?)dgvr.Cells["D6Pro_FinishDate"].Value;

                _Lnq_BillInfo.Bus_Quality_8DReport_D6_Countermeasure.Add(tempInfo);
            }

            //D7
            _Lnq_BillInfo.Bus_Quality_8DReport_D7_Prevent.Clear();

            foreach (DataGridViewRow dgvr in dgvD7_Prevent.Rows)
            {
                if (dgvr.Cells["D7Select"].Value != null && Convert.ToBoolean(dgvr.Cells["D7Select"].Value))
                {
                    Bus_Quality_8DReport_D7_Prevent tempInfo = new Bus_Quality_8DReport_D7_Prevent();

                    tempInfo.F_Id          = Guid.NewGuid().ToString();
                    tempInfo.ReportId      = _Lnq_BillInfo.F_Id;
                    tempInfo.Department    = dgvr.Cells["D7Department"].Value.ToString();
                    tempInfo.ItemsType     = dgvr.Cells["D7ItemsType"].Value.ToString();
                    tempInfo.OperationTime = dgvr.Cells["D7OperationTime"].Value == null ||
                                             GeneralFunction.IsNullOrEmpty(dgvr.Cells["D7OperationTime"].Value.ToString()) ?
                                             null : (DateTime?)dgvr.Cells["D7OperationTime"].Value;

                    _Lnq_BillInfo.Bus_Quality_8DReport_D7_Prevent.Add(tempInfo);
                }
            }

            //D8
            objValue = GetControlValue(txtD8_Unfulfillment_Explain);
            _Lnq_BillInfo.D8_Unfulfillment_Explain = objValue == null ? null : objValue.ToString();

            _Lnq_BillInfo.Bus_Quality_8DReport_D8_Verify.Clear();

            foreach (DataGridViewRow dgvr in dgvD8_Verify.Rows)
            {
                Bus_Quality_8DReport_D8_Verify tempInfo = new Bus_Quality_8DReport_D8_Verify();

                tempInfo.F_Id          = Guid.NewGuid().ToString();
                tempInfo.ReportId      = _Lnq_BillInfo.F_Id;
                tempInfo.Duty          = dgvr.Cells["D8Duty"].Value.ToString();
                tempInfo.Effect        = dgvr.Cells["D8Effect"].Value.ToString();
                tempInfo.OperationDate = dgvr.Cells["D8OperationDate"].Value == null ||
                                         GeneralFunction.IsNullOrEmpty(dgvr.Cells["D8OperationDate"].Value.ToString()) ?
                                         null : (DateTime?)dgvr.Cells["D8OperationDate"].Value;
                tempInfo.Result  = dgvr.Cells["D8Result"].Value.ToString();
                tempInfo.WayMode = dgvr.Cells["D8WayMode"].Value.ToString();

                _Lnq_BillInfo.Bus_Quality_8DReport_D8_Verify.Add(tempInfo);
            }
        }