Exemplo n.º 1
0
 /// <summary> 创建帐套
 /// </summary>
 private void btnCreateAcc_Click(object sender, EventArgs e)
 {
     try
     {
         ProcessOperator process = new ProcessOperator();
         #region 匿名方法,后台线程执行调用
         process.BackgroundWork = CreateAccount;
         #endregion
         process.MessageInfo = "正在执行中...";
         #region 匿名方法,后台线程执行完调用
         process.BackgroundWorkerCompleted += new EventHandler <BackgroundWorkerEventArgs>(
             delegate(object osender, BackgroundWorkerEventArgs be)
         {
             if (be.BackGroundException == null)
             {
                 this.DialogResult = DialogResult.OK;
                 MessageBoxEx.ShowInformation("帐套创建成功!");
             }
             else
             {
                 GlobalStaticObj_Server.GlobalLogService.WriteLog("账套设置", be.BackGroundException);
                 MessageBoxEx.ShowWarning("创建失败!");
             }
         }
             );
         #endregion
         process.Start();
     }
     catch (Exception ex)
     {
         GlobalStaticObj_Server.GlobalLogService.WriteLog("账套设置", ex);
         MessageBoxEx.ShowWarning("程序异常");
     }
 }
Exemplo n.º 2
0
 /// <summary> 还原
 /// </summary>
 void UCAcountSet_RestoreEvent(object sender, EventArgs e)
 {
     if (dgvAccList.CurrentRow == null)
     {
         MessageBoxEx.Show("请选择记录!");
         return;
     }
     try
     {
         string       accCode = dgvAccList.CurrentRow.Cells["setbook_code"].Value.ToString();
         string       msg     = string.Format("将要还原当前选中帐套{0}({1}),还原前请备份,是否继续?", dgvAccList.CurrentRow.Cells["setbook_name"].Value.ToString(), accCode);
         DialogResult result  = MessageBoxEx.Show(msg, "系统提示", MessageBoxButtons.YesNo);
         if (result == DialogResult.Yes)
         {
             frmBackupRecord frm = new frmBackupRecord();
             frm.IsSelected = true;
             frm.Acc_Code   = accCode;
             frm.Acc_Name   = dgvAccList.CurrentRow.Cells["setbook_name"].Value.ToString();
             if (frm.ShowDialog() == DialogResult.OK)
             {
                 ProcessOperator process = new ProcessOperator();
                 #region 匿名方法,后台线程执行调用
                 process.BackgroundWork = delegate()
                 {
                     string errMsg = CommonUtility.RestoreDb(accCode, frm.FileName);
                     if (!string.IsNullOrEmpty(errMsg))
                     {
                         throw new Exception(errMsg);
                     }
                 };
                 #endregion
                 process.MessageInfo = "正在执行中...";
                 #region 匿名方法,后台线程执行完调用
                 process.BackgroundWorkerCompleted += new EventHandler <BackgroundWorkerEventArgs>(
                     delegate(object osender, BackgroundWorkerEventArgs be)
                 {
                     if (be.BackGroundException == null)
                     {
                         MessageBoxEx.ShowInformation("还原成功!");
                     }
                     else
                     {
                         GlobalStaticObj_Server.GlobalLogService.WriteLog("账套设置", be.BackGroundException);
                         MessageBoxEx.ShowWarning("还原失败!");
                     }
                 }
                     );
                 #endregion
                 process.Start();
             }
         }
     }
     catch (Exception ex)
     {
         GlobalStaticObj_Server.GlobalLogService.WriteLog("帐套设置", ex);
         MessageBoxEx.ShowWarning("程序异常");
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 关闭服务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnTCPStop_Click(object sender, EventArgs e)
        {
            BtnTcpControl("alloff");
            ProcessOperator pOpStopServer = new ProcessOperator();

            pOpStopServer.BackgroundWork             = pOPBackWork;
            pOpStopServer.MessageInfo                = "正在关闭服务,请稍后...";
            pOpStopServer.BackgroundWorkerCompleted += new EventHandler <BackgroundWorkerEventArgs>(pOpStopServer_BackgroundWorkerCompleted);
            pOpStopServer.Start();
        }
Exemplo n.º 4
0
 /// <summary> 完成注册
 /// </summary>
 private void btnReg_Click(object sender, EventArgs e)
 {
     try
     {
         errProvider.Clear();
         if (string.IsNullOrEmpty(txtauthentication.Caption))
         {
             Validator.SetError(errProvider, txtauthentication, "请录入通讯鉴权码");
             return;
         }
         if (string.IsNullOrEmpty(txts_user.Caption))
         {
             Validator.SetError(errProvider, txts_user, "请录入通讯账号");
             return;
         }
         if (string.IsNullOrEmpty(txts_pwd.Caption))
         {
             Validator.SetError(errProvider, txts_pwd, "请录入通讯密码");
             return;
         }
         ProcessOperator process = new ProcessOperator();
         #region 匿名方法,后台线程执行调用
         process.BackgroundWork = delegate()
         {
             FinishReg();
         };
         #endregion
         process.MessageInfo = "正在注册...";
         #region 匿名方法,后台线程执行完调用
         process.BackgroundWorkerCompleted += new EventHandler <BackgroundWorkerEventArgs>(
             delegate(object osender, BackgroundWorkerEventArgs be)
         {
             if (be.BackGroundException != null)
             {
                 GlobalStaticObj_Server.GlobalLogService.WriteLog("账套设置", be.BackGroundException);
                 MessageBoxEx.ShowWarning("注册失败!");
             }
             else
             {
                 this.DialogResult = DialogResult.OK;
                 MessageBoxEx.ShowInformation("注册成功");
             }
         }
             );
         #endregion
         process.Start();
     }
     catch (Exception ex)
     {
         GlobalStaticObj_Server.GlobalLogService.WriteLog("注册鉴权", ex);
         MessageBoxEx.ShowWarning("程序异常");
     }
 }
Exemplo n.º 5
0
 /// <summary> 删除
 /// </summary>
 void UCAcountSet_DeleteEvent(object sender, EventArgs e)
 {
     if (dgvAccList.CurrentRow == null)
     {
         MessageBoxEx.Show("请选择删除记录!");
         return;
     }
     if (MessageBoxEx.Show("将要删除选中帐套,是否继续?", "系统提示", MessageBoxButtons.YesNo) == DialogResult.No)
     {
         return;
     }
     try
     {
         ProcessOperator process = new ProcessOperator();
         #region 匿名方法,后台线程执行调用
         process.BackgroundWork = DelAcc;
         #endregion
         process.MessageInfo = "正在执行中...";
         #region 匿名方法,后台线程执行完调用
         process.BackgroundWorkerCompleted += new EventHandler <BackgroundWorkerEventArgs>(
             delegate(object osender, BackgroundWorkerEventArgs be)
         {
             if (be.BackGroundException == null)
             {
                 MessageBoxEx.ShowInformation("删除成功!");
                 BindData(where);
                 if (dgvAccList.Rows.Count > 0)
                 {
                     dgvAccList.CurrentCell = dgvAccList.Rows[0].Cells[0];
                 }
             }
             else
             {
                 GlobalStaticObj_Server.GlobalLogService.WriteLog("账套设置", be.BackGroundException);
                 MessageBoxEx.ShowWarning("删除失败!");
             }
         }
             );
         #endregion
         process.Start();
     }
     catch (Exception ex)
     {
         GlobalStaticObj_Server.GlobalLogService.WriteLog("帐套设置", ex);
         MessageBoxEx.ShowWarning("程序异常");
     }
 }
Exemplo n.º 6
0
 /// <summary> 备份
 /// </summary>
 void UCAcountSet_BackupEvent(object sender, EventArgs e)
 {
     if (dgvAccList.CurrentRow == null)
     {
         MessageBoxEx.Show("请选择记录!");
         return;
     }
     try
     {
         string       accCode = dgvAccList.CurrentRow.Cells["setbook_code"].Value.ToString();
         string       msg     = string.Format("将要备份当前选中帐套{0}({1}),是否继续?", dgvAccList.CurrentRow.Cells["setbook_name"].Value.ToString(), accCode);
         DialogResult result  = MessageBoxEx.Show(msg, "系统提示", MessageBoxButtons.YesNo);
         if (result == DialogResult.Yes)
         {
             ProcessOperator process = new ProcessOperator();
             #region 匿名方法,后台线程执行调用
             process.BackgroundWork = BackupAcc;
             #endregion
             process.MessageInfo = "正在执行中...";
             #region 匿名方法,后台线程执行完调用
             process.BackgroundWorkerCompleted += new EventHandler <BackgroundWorkerEventArgs>(
                 delegate(object osender, BackgroundWorkerEventArgs be)
             {
                 if (be.BackGroundException == null)
                 {
                     MessageBoxEx.ShowInformation("备份成功!");
                 }
                 else
                 {
                     GlobalStaticObj_Server.GlobalLogService.WriteLog("账套设置", be.BackGroundException);
                     MessageBoxEx.ShowWarning("备份失败!");
                 }
             }
                 );
             #endregion
             process.Start();
         }
     }
     catch (Exception ex)
     {
         GlobalStaticObj_Server.GlobalLogService.WriteLog("帐套设置", ex);
         MessageBoxEx.ShowWarning("程序异常");
     }
 }
Exemplo n.º 7
0
        /// <summary> 下一步
        /// </summary>
        private void btnNextStep_Click(object sender, EventArgs e)
        {
            try
            {
                errProvider.Clear();
                bool flag = false;
                if (currStep == 1)
                {
                    #region 信息验证
                    if (string.IsNullOrEmpty(txtcom_name.Caption))
                    {
                        Validator.SetError(errProvider, txtcom_name, "请录入公司名称");
                        return;
                    }
                    if (string.IsNullOrEmpty(txtcom_address.Caption))
                    {
                        Validator.SetError(errProvider, txtcom_address, "请录入联系地址");
                        return;
                    }
                    if (!string.IsNullOrEmpty(txtzip_code.Caption))
                    {
                        if (Common.ValidateStr(txtzip_code.Caption.Trim(), @"[1-9]\d{5}(?!\d)") != 1)
                        {
                            Validator.SetError(errProvider, txtzip_code, "请录入正确的邮政编码");
                            return;
                        }
                    }
                    if (string.IsNullOrEmpty(txtcom_contact.Caption))
                    {
                        Validator.SetError(errProvider, txtcom_contact, "请录入联系人");
                        return;
                    }
                    if (string.IsNullOrEmpty(txtcom_tel.Caption))
                    {
                        Validator.SetError(errProvider, txtcom_tel, "请录入联系人电话号码或手机号");
                        return;
                    }
                    else
                    {
                        if (Common.ValidateStr(txtcom_tel.Caption.Trim(), @"[\d-]+") != 1)
                        {
                            Validator.SetError(errProvider, txtcom_tel, "请录入正确的电话号码或手机号");
                            return;
                        }
                    }

                    if (!string.IsNullOrEmpty(txtcom_email.Caption))
                    {
                        if (Common.ValidateStr(txtcom_email.Caption.Trim(), @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*") != 1)
                        {
                            Validator.SetError(errProvider, txtcom_email, "请录入正确的电子邮箱");
                            return;
                        }
                    }
                    if (!string.IsNullOrEmpty(txthotline.Caption))
                    {
                        if (Common.ValidateStr(txthotline.Caption.Trim(), @"[\d-]+") != 1)
                        {
                            Validator.SetError(errProvider, txthotline, "请录入正确的电话号码或手机号");
                            return;
                        }
                    }
                    #endregion

                    #region 宇通验证
                    if (string.IsNullOrEmpty(txtservice_station_sap.Caption))
                    {
                        if (MessageBoxEx.ShowQuestion("如果本公司与宇通签约,请填写宇通SAP代码和接入码,该信息填写后,才能与宇通关联,\r\n注意:如本次不填写,将无法成为签约服务站,后续也不能补充修改,是否返回填写?"))
                        {
                            return;
                        }
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(txtaccess_code.Caption.Trim()))
                        {
                            Validator.SetError(errProvider, txtaccess_code, "请录入宇通接入码");
                            return;
                        }
                    }
                    #endregion

                    #region 执行第一步
                    ProcessOperator process = new ProcessOperator();
                    #region 匿名方法,后台线程执行调用
                    process.BackgroundWork = delegate()
                    {
                        flag = FirstStep();
                    };
                    #endregion
                    process.MessageInfo = "请稍候...";
                    #region 匿名方法,后台线程执行完调用
                    process.BackgroundWorkerCompleted += new EventHandler <BackgroundWorkerEventArgs>(
                        delegate(object osender, BackgroundWorkerEventArgs be)
                    {
                        if (be.BackGroundException != null)
                        {
                            flag = false;
                            GlobalStaticObj_Server.GlobalLogService.WriteLog("账套设置", be.BackGroundException);
                            MessageBoxEx.ShowWarning("操作失败!");
                        }
                    }
                        );
                    #endregion
                    process.Start();
                    #endregion
                }
                else if (currStep == 2)
                {
                    flag = SecondStep();
                }
                if (flag)
                {
                    ToStep(true);
                }
            }
            catch (Exception ex)
            {
                GlobalStaticObj_Server.GlobalLogService.WriteLog("注册鉴权", ex);
                MessageBoxEx.ShowWarning("程序异常");
            }
        }
Exemplo n.º 8
0
        private void FuncationRegiste()  //注册控件相关事件
        {
            #region 窗体加载事件
            Load += delegate
            {
                dgv_table.ReadOnly = false;
                foreach (DataGridViewColumn dgvc in dgv_table.Columns)
                {
                    if (dgvc == drchk_check)
                    {
                        continue;
                    }
                    dgvc.ReadOnly = true;
                }
            };
            #endregion

            #region 添加按钮事件
            AddEvent += delegate
            {
                var uc = new UCMaintainThreeGuarantyEdit {
                    UCForm = this, windowStatus = WindowStatus.Add
                };
                uc.addUserControl(uc, "三包服务单-新增", "UCMaintainThreeGuarantyAdd", Tag.ToString(), Name);
            };
            #endregion

            #region  制按钮事件
            CopyEvent += delegate
            {
                var tgid     = "";
                var dataView = GetCheckRows();
                if (dataView != null)
                {
                    foreach (DataRowView rowView in GetSelectedRowData())
                    {
                        tgid = rowView["tg_id"].ToString();
                        break;
                    }
                }
                var uc = new UCMaintainThreeGuarantyEdit {
                    UCForm = this, TgId = tgid, windowStatus = WindowStatus.Copy
                };
                uc.addUserControl(uc, "三包服务单-复制", "UCMaintainThreeGuarantyCopy", Tag.ToString(), Name);
            };
            #endregion

            #region 编辑按钮事件
            EditEvent += delegate
            {
                var tgid     = "";
                var dataView = GetCheckRows();
                if (dataView != null && dataView.Count > 0)
                {
                    foreach (DataRowView rowView in GetSelectedRowData())
                    {
                        tgid = rowView["tg_id"].ToString();
                        break;
                    }
                }
                var uc = new UCMaintainThreeGuarantyEdit {
                    UCForm = this, TgId = tgid, windowStatus = WindowStatus.Edit
                };
                uc.addUserControl(uc, "三包服务单-编辑", "UCMaintainThreeGuarantyEdit", Tag.ToString(), Name);
            };
            #endregion

            #region  除按钮事件
            DeleteEvent += delegate
            {
                var selectedRows = GetCheckRows();
                if (MessageBoxEx.Show("确认要删除吗?", "提示", MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return;
                }
                var comField = new Dictionary <string, string> {
                    { "enable_flag", "0" }
                };
                var flag = DBHelper.BatchUpdateDataByIn("删除三包服务单", TableName, comField, "tg_id", selectedRows.ToArray());
                if (flag)
                {
                    BindPageData();
                    if (dgv_table.Rows.Count > 0)
                    {
                        dgv_table.CurrentCell = dgv_table.Rows[0].Cells[0];
                    }
                    MessageBoxEx.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBoxEx.Show("删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            };
            #endregion

            #region 激活作废按钮事件
            InvalidOrActivationEvent += delegate
            {
                if (MessageBoxEx.Show("确认要" + btnActivation.Caption + "吗?", "提示", MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return;
                }
                var selectedRows = GetCheckRows();
                var flag         = false;
                foreach (var selectedRow in selectedRows)
                {
                    var dvt       = DBHelper.GetTable("获得三包服务单前一个状态", "tb_maintain_three_guaranty_BackUp", "info_status", "tg_id='" + selectedRow + "'", "", "order by Record_id_UpdateTime desc");
                    var oldStatus = DbDic2Enum.SYS_SERVICE_INFO_STATUS_CG;
                    if (dvt.Rows.Count > 0)
                    {
                        var dr = dvt.Rows[0];
                        oldStatus = CommonCtrl.IsNullToString(dr["info_status"]);
                    }
                    flag = DBHelper.Submit_AddOrEdit("作废或激活三包服务单", TableName, "tg_id", selectedRow,
                                                     new Dictionary <string, string>
                    {
                        {
                            "info_status", btnActivation.Caption == "作废"  ? DbDic2Enum.SYS_SERVICE_INFO_STATUS_YZF : oldStatus
                        },
                        {
                            "update_by", GlobalStaticObj.UserID
                        },
                        {
                            "update_name", GlobalStaticObj.UserName
                        },
                        {
                            "update_time", Common.LocalDateTimeToUtcLong(GlobalStaticObj.CurrentDateTime).ToString()
                        }
                    });
                }
                if (flag)
                {
                    BindPageData();
                    if (dgv_table.Rows.Count > 0)
                    {
                        dgv_table.CurrentCell = dgv_table.Rows[0].Cells[0];
                    }
                    MessageBoxEx.Show(btnActivation.Caption + "成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBoxEx.Show(btnActivation.Caption + "失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            };
            #endregion

            #region 提交按钮事件
            btnSubmit.Click += delegate
            {
                if (!GlobalStaticObj.IsDefaultAcc)
                {
                    MessageBoxEx.ShowWarning("不是主账套信息,不允许进行操作!");
                    return;
                }
                var dataView = GetCheckRows();
                if (dataView != null)
                {
                    var cg = 0;
                    var sb = 0;
                    foreach (DataRowView rowView in GetSelectedRowData())
                    {
                        var tgid      = CommonCtrl.IsNullToString(rowView["tg_id"]);
                        var status    = CommonCtrl.IsNullToString(rowView["info_status"]);
                        var serviceNo = CommonCtrl.IsNullToString(rowView["service_no"]);
                        var dicFields = new Dictionary <string, string>();
                        dicFields.Add("info_status", DbDic2Enum.SYS_SERVICE_INFO_STATUS_YTJ);
                        if (status == DbDic2Enum.SYS_SERVICE_INFO_STATUS_CG && String.IsNullOrEmpty(serviceNo))
                        {
                            dicFields.Add("service_no", CommonUtility.GetNewNo(DataSources.EnumProjectType.ThreeGuarantyService));
                        }
                        var result = DBHelper.Submit_AddOrEdit("三包服务单提交", "tb_maintain_three_guaranty", "tg_id", tgid, dicFields);
                        if (result)
                        {
                            cg++;
                        }
                        else
                        {
                            sb++;
                        }
                    }
                    if (cg != 0)
                    {
                        BindPageData();
                    }
                    var msg = "三包服务单提交操作成功";
                    if (sb != 0 && cg == 0)
                    {
                        msg = "三包服务单提交失败";
                    }
                    else if (cg != 0 && sb == 0)
                    {
                        msg = "三包服务单提交成功";
                    }
                    else
                    {
                        msg += ",但存在" + sb + "条提交失败的单据";
                    }
                    MessageBoxEx.Show(msg, "操作提示");
                }
                else
                {
                    MessageBoxEx.Show("无法获取到选择的数据,请选择需要操作的数据", "操作提示");
                }
            };
            #endregion

            #region 审核按钮事件
            VerifyEvent += delegate
            {
                var tgid     = "";
                var dataView = GetCheckRows();
                if (dataView != null)
                {
                    foreach (DataRowView rowView in GetSelectedRowData())
                    {
                        tgid = rowView["tg_id"].ToString();
                        break;
                    }
                }
                var form = new UCMaintainThreeGuarantyVerify(tgid);
                form.UcForm = this;
                var result = form.ShowDialog(this);
                if (result == DialogResult.OK)
                {
                    BindPageData();
                }
            };
            #endregion

            #region  报厂家/总公司按钮事件
            CommitEvent += delegate
            {
                if (!GlobalStaticObj.IsDefaultAcc)
                {
                    MessageBoxEx.ShowWarning("不是主账套信息,不允许进行操作!");
                    return;
                }
                if (MessageBoxEx.Show("确认要将三包服务单上报宇通吗?", "提示", MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return;
                }
                var tgid     = "";
                var dataView = GetCheckRows();
                if (dataView != null)
                {
                    foreach (DataRowView rowView in GetSelectedRowData())
                    {
                        tgid = rowView["tg_id"].ToString();
                        break;
                    }
                }
                else
                {
                    return;
                }
                //var process = new ProcessOperator();
                //#region 匿名方法,后台线程执行调用
                //process.BackgroundWork = delegate()
                //{
                var resultStr = Submit2Company(tgid, "100000001");
                MessageBoxEx.Show(String.IsNullOrEmpty(resultStr) ? "三包服务单上报厂家成功!" : "三包服务单上报厂家失败!", "操作提示");
                BindPageData();
                //};
                //#endregion
                //process.MessageInfo = "正在执行中...";
                //#region 匿名方法,后台线程执行完调用
                //process.BackgroundWorkerCompleted += new EventHandler<BackgroundWorkerEventArgs>(
                //        delegate(object osender, BackgroundWorkerEventArgs be)
                //        {
                //            if (be.BackGroundException != null)
                //            {
                //                GlobalStaticObj.GlobalLogService.WriteLog("三包单上报", be.BackGroundException);
                //            }
                //        }
                //    );
                //#endregion
                //process.Start();
            };
            #endregion

            #region 撤销按钮事件
            RevokeEvent += delegate
            {
                if (!GlobalStaticObj.IsDefaultAcc)
                {
                    MessageBoxEx.ShowWarning("不是主账套信息,不允许进行操作!");
                    return;
                }
                if (MessageBoxEx.Show("确认要撤销已提交的单据吗?", "提示", MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return;
                }
                var selectedRowsYt    = GetCheckRowsByYt();
                var selectedRows      = GetCheckRows();
                var canSubmit2Company = false;
                if (selectedRowsYt != null && selectedRowsYt.Count > 0)
                {
                    var orderStatus = DBHelper.GetSingleValue("获取三包服务单状态", TableName, "info_status", String.Format("tg_id = '{0}'", selectedRows[0]), "");
                    if (orderStatus == DbDic2Enum.SYS_SERVICE_INFO_STATUS_YTJ)
                    {
                        bool flag = DBHelper.Submit_AddOrEdit("撤销三包服务单", "tb_maintain_three_guaranty", "tg_id", selectedRows[0],
                                                              new Dictionary <string, string>
                        {
                            {
                                "info_status", DbDic2Enum.SYS_SERVICE_INFO_STATUS_CG
                            }
                        });
                        if (flag)
                        {
                            BindPageData("enable_flag = '1'");
                            MessageBoxEx.Show("撤销成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBoxEx.Show("撤销失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else if (orderStatus == DbDic2Enum.SYS_SERVICE_INFO_STATUS_SHTG)
                    {
                        var resultStr = DBHelper.WebServHandlerByObj("查询三包服务单状态", EnumWebServFunName.SearchOrderStatus, selectedRowsYt[0]);
                        if (resultStr == "100000001" || String.IsNullOrEmpty(resultStr))
                        {
                            var process = new ProcessOperator();
                            #region 匿名方法,后台线程执行调用
                            process.BackgroundWork = delegate()
                            {
                                Submit2Company(selectedRows[0], selectedRowsYt[0], "100000002");
                            };
                            #endregion
                            process.MessageInfo = "正在执行中...";
                            #region 匿名方法,后台线程执行完调用
                            process.BackgroundWorkerCompleted += new EventHandler <BackgroundWorkerEventArgs>(
                                delegate(object osender, BackgroundWorkerEventArgs be)
                            {
                                if (be.BackGroundException != null)
                                {
                                    GlobalStaticObj.GlobalLogService.WriteLog("三包单上报", be.BackGroundException);
                                }
                            }
                                );
                            #endregion
                            process.Start();
                            var flag = DBHelper.Submit_AddOrEdit("撤销三包服务单", "tb_maintain_three_guaranty", "tg_id", selectedRows[0],
                                                                 new Dictionary <string, string>
                            {
                                {
                                    "info_status", DbDic2Enum.SYS_SERVICE_INFO_STATUS_YTJ
                                }
                            });
                            if (flag)
                            {
                                MessageBoxEx.Show("撤销成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                BindPageData("enable_flag = '1'");
                            }
                            else
                            {
                                MessageBoxEx.Show("撤销失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        else
                        {
                            MessageBoxEx.Show("此单据已被引用,无法撤销!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
                else
                {
                    MessageBoxEx.Show("请选择需要撤销的单据信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            };
            #endregion

            #region 导入按钮事件
            ImportEvent += delegate
            {
                //var callbackImport = new UCRepairCallbackImport();
                //callbackImport.Fetchuc = this;
                //callbackImport.strTag = "1";
                //callbackImport.ShowDialog();
            };
            #endregion

            #region 查询按钮事件
            pnl_search.QueryClick += (sender, args) => BindPageData();
            #endregion

            #region 数据翻页
            pageQ.PageIndexChanged += delegate
            {
                BindPageData();
            };
            #endregion

            #region 数据表数据选择
            dgv_table.CellDoubleClick += delegate(object sender, DataGridViewCellEventArgs args)
            {
                if (args.RowIndex < 0)
                {
                    return;
                }
                var tgid = dgv_table.Rows[args.RowIndex].Cells["drtxt_tg_id"].Value.ToString();
                if (String.IsNullOrEmpty(tgid))
                {
                    MessageBoxEx.Show("无效的结算单信息", "操作提示");
                    return;
                }
                var uc = new UCMaintainThreeGuarantyViewDetail {
                    TgId = tgid, UCForm = this
                };
                uc.addUserControl(uc, "三包服务单-详细信息", "UCMaintainThreeGuarantyViewDetail" + uc.TgId, Tag.ToString(), Name);
            };
            #endregion

            #region 数据表格单元格数据转换
            dgv_table.CellFormatting += (sender, args) => ConvertDataGridColumnsData(args);
            #endregion

            #region 根据选择的数据判断功能按钮的显示状态
            dgv_table.CellMouseUp += delegate
            {
                var dataView  = GetSelectedRowData();
                var listField = GetCheckRows();
                if (dataView == null || listField.Count == 0)
                {
                    //btnAdd, btnCopy, btnDelete, btnInvalidOrActivation, btnVerify, btnSave, btnCommit, btnCancel, btnExport, btnImport, btn_Revoke, btnView, btnPrint, btnSet
                    btnCopy.Enabled       = false;
                    btnEdit.Enabled       = false;
                    btnDelete.Enabled     = false;
                    btnActivation.Enabled = false;
                    btnCommit.Enabled     = btnSubmit.Enabled = btnVerify.Enabled = false;
                }
                else
                {
                    var cg    = 0;
                    var shwtg = 0;
                    var shtg  = 0;
                    var ytj   = 0;
                    var yzf   = 0;
                    foreach (DataRowView drv in dataView)
                    {
                        var status = drv["info_status"].ToString();
                        if (status == DbDic2Enum.SYS_SERVICE_INFO_STATUS_CG)
                        {
                            cg++;
                        }
                        else if (status == DbDic2Enum.SYS_SERVICE_INFO_STATUS_SHWTG)
                        {
                            shwtg++;
                        }
                        else if (status == DbDic2Enum.SYS_SERVICE_INFO_STATUS_SHTG)
                        {
                            shtg++;
                        }
                        else if (status == DbDic2Enum.SYS_SERVICE_INFO_STATUS_YTJ)
                        {
                            ytj++;
                        }
                        else if (status == DbDic2Enum.SYS_SERVICE_INFO_STATUS_YZF)
                        {
                            yzf++;
                        }
                    }

                    #region 编辑
                    if (listField.Count == 1 && (cg + shwtg) == listField.Count)
                    {
                        btnEdit.Enabled = true;
                    }
                    else
                    {
                        btnEdit.Enabled = false;
                    }
                    //提交
                    if (listField.Count >= 1 && (cg + shwtg) == listField.Count)
                    {
                        btnSubmit.Enabled = true;
                    }
                    else
                    {
                        btnSubmit.Enabled = false;
                    }
                    #endregion

                    #region  制
                    if (listField.Count == 1)
                    {
                        btnCopy.Enabled = true;
                    }
                    #endregion

                    #region  除
                    if (listField.Count >= 1 && (cg + shwtg + yzf) == listField.Count)
                    {
                        btnDelete.Enabled = true;
                    }
                    else
                    {
                        btnDelete.Enabled = false;
                    }
                    #endregion

                    #region 作废/激活
                    var zf = 0;
                    var jh = 0;
                    if (listField.Count == 1)
                    {
                        foreach (DataRowView rowView in dataView) //作废/激活
                        {
                            if (rowView["info_status"].ToString() == DbDic2Enum.SYS_SERVICE_INFO_STATUS_CG ||
                                rowView["info_status"].ToString() == DbDic2Enum.SYS_SERVICE_INFO_STATUS_SHWTG)
                            {
                                zf++;
                            }
                            else if (rowView["info_status"].ToString() == DbDic2Enum.SYS_SERVICE_INFO_STATUS_YZF)
                            {
                                jh++;
                            }
                        }
                        if (zf == 0 && jh != 0)
                        {
                            btnActivation.Enabled = true;
                            btnActivation.Caption = "激活";
                            btnActivation.Width   = 60;
                        }
                        else if (zf != 0 && jh == 0)
                        {
                            btnActivation.Enabled = true;
                            btnActivation.Caption = "作废";
                            btnActivation.Width   = 60;
                        }
                        else
                        {
                            btnActivation.Enabled = false;
                            btnActivation.Caption = "作废/激活";
                            btnActivation.Width   = 90;
                        }
                    }
                    else
                    {
                        btnActivation.Enabled = false;
                        btnActivation.Caption = "作废/激活";
                        btnActivation.Width   = 90;
                    }
                    #endregion

                    #region 审核
                    if (UIAssistants.ThreeServiceAudit && listField.Count == 1)
                    {
                        btnVerify.Enabled = ytj == listField.Count;
                    }
                    else
                    {
                        btnVerify.Enabled = false;
                    }
                    #endregion

                    #region  报厂家/总公司

                    if (UIAssistants.ThreeServiceAudit)
                    {
                        if (listField.Count == 1 && listField.Count == shtg)
                        {
                            btnCommit.Enabled = true;
                        }
                        else
                        {
                            btnCommit.Enabled = false;
                        }
                    }
                    else
                    {
                        if (listField.Count == 1 && listField.Count == ytj)
                        {
                            btnCommit.Enabled = true;
                        }
                        else
                        {
                            btnCommit.Enabled = false;
                        }
                    }
                    #endregion

                    #region 撤销
                    if (listField.Count == 1 && cg == 0)
                    {
                        btnRevoke.Enabled = true;
                    }
                    else
                    {
                        btnRevoke.Enabled = false;
                    }
                    #endregion
                }
            };
            #endregion
        }