private bool customForm_PanelGetDateInfo(CE_FlowOperationType flowOperationType)
        {
            try
            {
                if (!CheckData())
                {
                    return(false);
                }

                m_lnqBillInfo = new Business_PurchasingMG_PartsBelongPriovderChange();

                m_lnqBillInfo.BillNo       = txtBillNo.Text;
                m_lnqBillInfo.ChangeReason = txtChangeReason.Text;
                m_lnqBillInfo.ChangeType   = cmbChangeType.Text;
                m_lnqBillInfo.Provider     = txtProvider.Text;

                List <View_Business_PurchasingMG_PartsBelongPriovderChangeDetail> listTemp =
                    new List <View_Business_PurchasingMG_PartsBelongPriovderChangeDetail>();

                foreach (DataGridViewRow dr in customDataGridView1.Rows)
                {
                    View_Business_PurchasingMG_PartsBelongPriovderChangeDetail tempInfo =
                        new View_Business_PurchasingMG_PartsBelongPriovderChangeDetail();

                    tempInfo.单据号 = dr.Cells["单据号"].Value.ToString();

                    tempInfo.规格    = dr.Cells["规格"].Value.ToString();
                    tempInfo.零件类型  = dr.Cells["零件类型"].Value.ToString();
                    tempInfo.供应商等级 = dr.Cells["供应商等级"].Value.ToString();
                    tempInfo.难度等级  = dr.Cells["难度等级"].Value.ToString();
                    tempInfo.说明    = dr.Cells["说明"].Value.ToString();
                    tempInfo.图号型号  = dr.Cells["图号型号"].Value.ToString();
                    tempInfo.物品ID  = Convert.ToInt32(dr.Cells["物品ID"].Value);
                    tempInfo.物品名称  = dr.Cells["物品名称"].Value.ToString();

                    listTemp.Add(tempInfo);
                }

                this.FlowInfo_BillNo = txtBillNo.Text;
                this.ResultInfo      = listTemp;

                this.ResultList = new List <object>();

                this.ResultList.Add(m_lnqBillInfo);
                this.ResultList.Add(flowOperationType);

                return(true);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
                return(false);
            }
        }
        bool frm_CommonProcessSubmit(CustomFlowForm form, string advise)
        {
            try
            {
                List <View_Business_PurchasingMG_PartsBelongPriovderChangeDetail> detailInfo =
                    form.ResultInfo as List <View_Business_PurchasingMG_PartsBelongPriovderChangeDetail>;
                Business_PurchasingMG_PartsBelongPriovderChange lnqInPut = form.ResultList[0] as Business_PurchasingMG_PartsBelongPriovderChange;

                this.OperationType = GeneralFunction.StringConvertToEnum <CE_FlowOperationType>(form.ResultList[1].ToString());
                this.BillNo        = lnqInPut.BillNo;

                switch (this.OperationType)
                {
                case CE_FlowOperationType.提交:
                    //if (!panel.GetNotifyPersonnel())
                    //{
                    //    return false;
                    //}

                    //NotifyPersonnel = panel.FlowInfo_NotifyInfo;
                    m_serviceChangeBill.SaveInfo(lnqInPut, detailInfo);
                    m_serviceChangeBill.FinishBill(lnqInPut.BillNo);
                    break;

                case CE_FlowOperationType.暂存:
                    m_serviceChangeBill.SaveInfo(lnqInPut, detailInfo);
                    break;

                case CE_FlowOperationType.回退:
                    break;

                case CE_FlowOperationType.未知:
                    break;

                default:
                    break;
                }

                if (!m_serviceChangeBill.IsExist(lnqInPut.BillNo))
                {
                    MessageDialog.ShowPromptMessage("数据为空,保存失败,如需退出,请直接X掉界面");
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
                return(false);
            }
        }
        public override void LoadFormInfo()
        {
            try
            {
                m_billNoControl = new BillNumberControl(CE_BillTypeEnum.供应商与零件归属变更单.ToString(), m_serviceChangeBill);
                m_lnqBillInfo   = m_serviceChangeBill.GetSingleBillInfo(this.FlowInfo_BillNo);
                SetInfo();

                if (lbBillStatus.Text != CE_CommonBillStatus.新建单据.ToString())
                {
                    groupBox1.Enabled = false;
                    groupBox2.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowErrorMessage(ex.Message);
            }
        }
        void SetInfo()
        {
            if (m_lnqBillInfo != null)
            {
                lbBillStatus.Text = m_serverFlow.GetNowBillStatus(m_lnqBillInfo.BillNo);

                txtBillNo.Text       = m_lnqBillInfo.BillNo;
                txtProvider.Text     = m_lnqBillInfo.Provider;
                txtChangeReason.Text = m_lnqBillInfo.ChangeReason;
                cmbChangeType.Text   = m_lnqBillInfo.ChangeType;
            }
            else
            {
                lbBillStatus.Text = CE_CommonBillStatus.新建单据.ToString();

                m_lnqBillInfo = new Business_PurchasingMG_PartsBelongPriovderChange();

                txtBillNo.Text       = this.FlowInfo_BillNo;
                m_lnqBillInfo.BillNo = txtBillNo.Text;
            }

            m_listViewDetail = m_serviceChangeBill.GetListViewDetailInfo(m_lnqBillInfo.BillNo);
            RefreshDataGridView(m_listViewDetail);
        }
        /// <summary>
        /// 结束业务
        /// </summary>
        /// <param name="billNo">业务编号</param>
        public void FinishBill(string billNo)
        {
            IFlowServer serviceFlow = FlowControlService.ServerModuleFactory.GetServerModule <IFlowServer>();

            string billStatus = serviceFlow.GetNextBillStatus(billNo);

            if (billStatus == null)
            {
                throw new Exception("单据状态为空,请重新确认");
            }

            if (billStatus != CE_CommonBillStatus.单据完成.ToString())
            {
                return;
            }

            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

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

            try
            {
                Business_PurchasingMG_PartsBelongPriovderChange billInfo = GetSingleBillInfo(billNo);

                if (billInfo == null || billInfo.BillNo.Length == 0)
                {
                    throw new Exception("此单据不存在");
                }

                List <View_Business_PurchasingMG_PartsBelongPriovderChangeDetail> listDetail = GetListViewDetailInfo(billInfo.BillNo);

                foreach (View_Business_PurchasingMG_PartsBelongPriovderChangeDetail item in listDetail)
                {
                    CE_LV providerLV            = GlobalObject.GeneralFunction.StringConvertToEnum <CE_LV>(item.供应商等级);
                    B_AccessoryDutyInfo lnqTemp = GetDutyInfo(ctx, item.物品ID);

                    List <string> LVA = new List <string>();
                    List <string> LVB = new List <string>();
                    List <string> LVC = new List <string>();

                    switch (billInfo.ChangeType)
                    {
                    case "准入":
                        if (lnqTemp == null)
                        {
                            lnqTemp = new B_AccessoryDutyInfo();

                            List <CommonProcessInfo> lstTemp = serviceFlow.GetFlowData(billInfo.BillNo);

                            lnqTemp.CreatePersonnel = (lstTemp == null || lstTemp.Count() == 0) ? BasicInfo.LoginID :
                                                      serviceFlow.GetFlowData(billInfo.BillNo).OrderBy(k => k.时间).First().人员;
                            lnqTemp.CreateDate = ServerTime.Time;
                            lnqTemp.Grade      = item.难度等级;
                            lnqTemp.Remark     = item.说明;
                            lnqTemp.Sort       = item.零件类型;
                            lnqTemp.GoodsID    = item.物品ID;

                            List <string> lstProvider = new List <string>();
                            lstProvider.Add(billInfo.Provider);
                            SetProviderLV(ref lnqTemp, providerLV, lstProvider);

                            ctx.B_AccessoryDutyInfo.InsertOnSubmit(lnqTemp);
                        }
                        else if (lnqTemp != null)
                        {
                            LVA = GetListProviderLV(lnqTemp, CE_LV.A);
                            LVB = GetListProviderLV(lnqTemp, CE_LV.B);
                            LVC = GetListProviderLV(lnqTemp, CE_LV.C);

                            LVA.Remove(billInfo.Provider);
                            LVB.Remove(billInfo.Provider);
                            LVC.Remove(billInfo.Provider);

                            switch (providerLV)
                            {
                            case CE_LV.A:
                                LVA.Add(billInfo.Provider);
                                break;

                            case CE_LV.B:
                                LVB.Add(billInfo.Provider);
                                break;

                            case CE_LV.C:
                                LVC.Add(billInfo.Provider);
                                break;

                            default:
                                break;
                            }

                            SetProviderLV(ref lnqTemp, CE_LV.A, LVA);
                            SetProviderLV(ref lnqTemp, CE_LV.B, LVB);
                            SetProviderLV(ref lnqTemp, CE_LV.C, LVC);
                        }
                        else
                        {
                            throw new Exception("信息重复,无法操作");
                        }

                        break;

                    case "等级变更":

                        if (lnqTemp == null)
                        {
                            throw new Exception("无此零件信息,无法操作【等级变更】");
                        }

                        LVA = GetListProviderLV(lnqTemp, CE_LV.A);
                        LVB = GetListProviderLV(lnqTemp, CE_LV.B);
                        LVC = GetListProviderLV(lnqTemp, CE_LV.C);

                        LVA.Remove(billInfo.Provider);
                        LVB.Remove(billInfo.Provider);
                        LVC.Remove(billInfo.Provider);

                        switch (providerLV)
                        {
                        case CE_LV.A:
                            LVA.Add(billInfo.Provider);
                            break;

                        case CE_LV.B:
                            LVB.Add(billInfo.Provider);
                            break;

                        case CE_LV.C:
                            LVC.Add(billInfo.Provider);
                            break;

                        default:
                            break;
                        }

                        SetProviderLV(ref lnqTemp, CE_LV.A, LVA);
                        SetProviderLV(ref lnqTemp, CE_LV.B, LVB);
                        SetProviderLV(ref lnqTemp, CE_LV.C, LVC);
                        break;

                    case "淘汰":
                        if (lnqTemp != null)
                        {
                            LVA = GetListProviderLV(lnqTemp, CE_LV.A);
                            LVB = GetListProviderLV(lnqTemp, CE_LV.B);
                            LVC = GetListProviderLV(lnqTemp, CE_LV.C);

                            LVA.Remove(billInfo.Provider);
                            LVB.Remove(billInfo.Provider);
                            LVC.Remove(billInfo.Provider);

                            SetProviderLV(ref lnqTemp, CE_LV.A, LVA);
                            SetProviderLV(ref lnqTemp, CE_LV.B, LVB);
                            SetProviderLV(ref lnqTemp, CE_LV.C, LVC);

                            if ((lnqTemp.ProviderA == null || lnqTemp.ProviderA.Length == 0) &&
                                (lnqTemp.ProviderB == null || lnqTemp.ProviderB.Length == 0) &&
                                (lnqTemp.ProviderC == null || lnqTemp.ProviderC.Length == 0))
                            {
                                ctx.B_AccessoryDutyInfo.DeleteOnSubmit(lnqTemp);
                            }
                        }

                        break;

                    default:
                        break;
                    }

                    ctx.SubmitChanges();
                }

                ctx.SubmitChanges();
                ctx.Transaction.Commit();
            }
            catch (Exception ex)
            {
                ctx.Transaction.Rollback();
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// 保存业务信息
        /// </summary>
        /// <param name="billInfo">业务总单信息</param>
        /// <param name="detailInfo">业务明细信息</param>
        public void SaveInfo(Business_PurchasingMG_PartsBelongPriovderChange billInfo,
                             List <View_Business_PurchasingMG_PartsBelongPriovderChangeDetail> detailInfo)
        {
            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

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

            try
            {
                var varData = from a in ctx.Business_PurchasingMG_PartsBelongPriovderChange
                              where a.BillNo == billInfo.BillNo
                              select a;

                if (varData.Count() == 1)
                {
                    Business_PurchasingMG_PartsBelongPriovderChange lnqBill = varData.Single();

                    lnqBill.ChangeReason = billInfo.ChangeReason;
                    lnqBill.ChangeType   = billInfo.ChangeType;
                    lnqBill.Provider     = billInfo.Provider;
                }
                else if (varData.Count() == 0)
                {
                    ctx.Business_PurchasingMG_PartsBelongPriovderChange.InsertOnSubmit(billInfo);
                }
                else
                {
                    throw new Exception("单据数据不唯一");
                }

                var varDetail = from a in ctx.Business_PurchasingMG_PartsBelongPriovderChangeDetail
                                where a.BillNo == billInfo.BillNo
                                select a;

                ctx.Business_PurchasingMG_PartsBelongPriovderChangeDetail.DeleteAllOnSubmit(varDetail);
                ctx.SubmitChanges();

                foreach (View_Business_PurchasingMG_PartsBelongPriovderChangeDetail item in detailInfo)
                {
                    Business_PurchasingMG_PartsBelongPriovderChangeDetail lnqDetail
                        = new Business_PurchasingMG_PartsBelongPriovderChangeDetail();

                    lnqDetail.BillNo      = billInfo.BillNo;
                    lnqDetail.DiffcultyLV = item.难度等级;
                    lnqDetail.Explain     = item.说明;
                    lnqDetail.GoodsID     = item.物品ID;
                    lnqDetail.PartType    = item.零件类型;
                    lnqDetail.ProviderLV  = item.供应商等级;

                    ctx.Business_PurchasingMG_PartsBelongPriovderChangeDetail.InsertOnSubmit(lnqDetail);
                }

                ctx.SubmitChanges();
                ctx.Transaction.Commit();
            }
            catch (Exception ex)
            {
                ctx.Transaction.Rollback();
                throw new Exception(ex.Message);
            }
        }