예제 #1
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("程序异常");
     }
 }
예제 #2
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("程序异常");
            }
        }
        private void InitEventHandle() //注册控件相关事件
        {
            btnSave.Click += (sender, args) => Save();
            btnCancel.Click += delegate
            {
                UCForm.BindPageData();
                deleteMenuByTag(Tag.ToString(), UCForm.Name);
            };
            btnImport.Click += delegate
            {
                //var import = new UCMaintainSettlementImprot();
                //import.ShowDialog();
                //return;
                var callbackImport = new UCRepairCallbackImport {MaintainThreeGuarantyEdit = this, strTag = "4"};
                callbackImport.ShowDialog();
            };
            cbo_whether_yt.SelectedIndexChanged += delegate  //是否宇通车
            {
                //if (cbo_receipt_type.SelectedValue == null) return;
                //var selectedValue4BillType = cbo_receipt_type.SelectedValue == null ? "" : cbo_receipt_type.SelectedValue.ToString().ToUpper();
                if (cbo_whether_yt.SelectedValue == null) return;
                var selectedValue = cbo_whether_yt.SelectedValue == null ? "" : cbo_whether_yt.SelectedValue.ToString().ToUpper();
                if (selectedValue == DbDic2Enum.TRUE)
                {
                    lbl__vehicle_vin.Visible = true;
                    lbl_depot_no.Visible = true;
                    lbl_engine_num.Visible = true;
                }
                else
                {
                    lbl__vehicle_vin.Visible = false;
                    lbl_depot_no.Visible = false;
                    lbl_engine_num.Visible = false;
                }
            };
            cbo_whether_go_out.SelectedIndexChanged += delegate   //根据是否外出不同显示不同的可填字段
            {
                if (cbo_whether_go_out.SelectedValue == null) return;
                var selectedValue = cbo_whether_go_out.SelectedValue == null ? "" : cbo_whether_go_out.SelectedValue.ToString().ToUpper();
                pnl_goout_info.Visible = selectedValue == DbDic2Enum.TRUE;  //外出情况
                dtp_repairs_time.Focus();
            };
            btnCommit.Click += delegate
            {
                //if (!CheckControlValue()) return;
                //上报厂家/宇通
                if (windowStatus == WindowStatus.Add || windowStatus == WindowStatus.Copy)
                {
                    lbl_service_no.Text = CommonUtility.GetNewNo(DataSources.EnumProjectType.ThreeGuarantyService);
                }
                var result = SaveThreeGuarantyItem(DbDic2Enum.SYS_SERVICE_INFO_STATUS_YTJ);
                var id = windowStatus == WindowStatus.Edit ? TgId : _newTgId;
                if (UIAssistants.ThreeServiceAudit)
                {
                    if (result)
                    {
                        SaveAttachement(id);
                        SaveMaterialDetail(id);
                        if ((cbo_contain_man_hour_cost.SelectedValue == null ? "" : cbo_contain_man_hour_cost.SelectedValue.ToString().ToUpper()) == DbDic2Enum.TRUE)
                            SaveProjectData(id);
                        MessageBoxEx.Show("数据提交成功!", "操作提示");
                        return;
                    }
                    MessageBoxEx.Show("数据提交失败!", "操作提示");
                    return;
                }
                if (result)
                {
                    var process = new ProcessOperator();
                    #region 匿名方法,后台线程执行调用
                    process.BackgroundWork = delegate()
                    {
                        SaveAttachement(id);
                        SaveMaterialDetail(id);
                        if ((cbo_contain_man_hour_cost.SelectedValue == null
                            ? ""
                            : cbo_contain_man_hour_cost.SelectedValue.ToString().ToUpper()) == DbDic2Enum.TRUE)
                            SaveProjectData(id);
                        var resultStr = UCForm.Submit2Company(id, "100000001");
                        if (String.IsNullOrEmpty(resultStr))
                        {
                            MessageBoxEx.Show("三包服务单上报厂家成功!", "操作提示");
                        }
                        else
                        {
                            MessageBoxEx.Show("三包服务单上报厂家失败!", "操作提示");
                        }
                    };
                    #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();
                }
                else
                {
                    MessageBoxEx.Show("上报厂家失败!", "操作提示");
                }
            };
            cbo_contain_man_hour_cost.SelectedIndexChanged += delegate   //根据是否包含工时费决定是否显示维修项目表
            {
                if (cbo_contain_man_hour_cost.SelectedValue == null) return;
                var selectedValueManHourCost = cbo_contain_man_hour_cost.SelectedValue == null ? "" : cbo_contain_man_hour_cost.SelectedValue.ToString().ToUpper();
                if (selectedValueManHourCost == DbDic2Enum.TRUE) //是
                {
                    if(!tabControlExBottom.TabPages.Contains(tb_wxxm))
                        tabControlExBottom.TabPages.Insert(0,tb_wxxm);
                    tabControlExBottom.SelectTab(tb_wxxm);
                }
                else
                {
                    if (tabControlExBottom.TabPages.Contains(tb_wxxm))
                        tabControlExBottom.TabPages.Remove(tb_wxxm);
                }
                dtp_repairs_time.Focus();
            };
            #region 根据宇通单据类型不同显示不同的可填字段
            cbo_receipt_type.SelectedIndexChanged += delegate   
            {
                pnl_promise_guarantee.Visible = false;  //维修 -- 特殊约定质保

                pnl_approver_name_yt.Visible = false;   //政策照顾 -- 宇通批准信息

                pnl_product_notice_no.Visible = false;  //产品改进 -- 产品改进通知

                pnl_cost_type_service_fwhd.Visible = false; //服务活动 -- 费用类型

                pnl_custome_property.Visible = true;
                pnl_cust_address.Visible = true;
                pnl_customer_postcode.Visible = true;
                pnl_linkman.Visible = true;
                pnl_link_man_mobi.Visible = true;
                pnl_vehicle_use_corp.Visible = true;
                pnl_vehicle_location.Visible = true;

                pnl_driving_license_no.Visible = true;
                pnl_travel_mileage.Visible = true;
                pnl_whether_yt.Visible = true;
                pnl_maintain_time.Visible = true;
                pnl_maintain_mileage.Visible = true;
                pnl_whether_yt.Visible = false;
                lbl_vehicle_model.Visible = true;

                pnl_customer_info.Height = 130;
                pnl_vehicle.Height = 100;

                tableLayoutPanel3.Controls.Remove(pnl_driving_license_no);

                var selectedValue = cbo_receipt_type.SelectedValue == null ? "" : cbo_receipt_type.SelectedValue.ToString().ToUpper();

                if (selectedValue == DbDic2Enum.BILL_TYPE_YT_100000007) //配件三包
                {
                    tableLayoutPanel3.Controls.Add(pnl_driving_license_no, 1, 2);

                    pnl_part_info.Visible = true;
                    var selectedValueManHourCost = cbo_contain_man_hour_cost.SelectedValue == null ? "" : cbo_contain_man_hour_cost.SelectedValue.ToString().ToUpper();
                    if (selectedValueManHourCost == DbDic2Enum.TRUE) //是
                    {
                        if (!tabControlExBottom.TabPages.Contains(tb_wxxm))
                            tabControlExBottom.TabPages.Insert(0, tb_wxxm);
                        tabControlExBottom.SelectTab(tb_wxxm);
                    }
                    else
                    {
                        if (!tabControlExBottom.TabPages.Contains(tb_wxxm))
                            tabControlExBottom.TabPages.Insert(0, tb_wxxm);
                        tabControlExBottom.SelectTab(tb_wxxm);
                    }
                }
                else
                {
                    tableLayoutPanel3.Controls.Add(pnl_driving_license_no, 3, 0);

                    if (!tabControlExBottom.TabPages.Contains(tb_wxxm))
                        tabControlExBottom.TabPages.Insert(0, tb_wxxm);
                    tabControlExBottom.SelectTab(tb_wxxm);
                    pnl_part_info.Visible = false;

                    var selectedValue4WhetherYt = cbo_whether_yt.SelectedValue == null ? "" : cbo_whether_yt.SelectedValue.ToString().ToUpper();
                    if (selectedValue4WhetherYt == DbDic2Enum.TRUE)
                    {
                        lbl__vehicle_vin.Visible = true;
                        lbl_depot_no.Visible = true;
                        lbl_engine_num.Visible = true;
                    }
                    else
                    {
                        lbl__vehicle_vin.Visible = false;
                        lbl_depot_no.Visible = false;
                        lbl_engine_num.Visible = false;
                    }
                }

                if (selectedValue == DbDic2Enum.BILL_TYPE_YT_100000007) //配件三包
                {
                    pnl_cust_address.Visible = false;
                    pnl_customer_postcode.Visible = false;
                    pnl_linkman.Visible = false;
                    pnl_link_man_mobi.Visible = false;
                    pnl_vehicle_location.Visible = false;

                    pnl_driving_license_no.Visible = false;
                    pnl_travel_mileage.Visible = false;
                    pnl_whether_yt.Visible = false;
                    pnl_maintain_time.Visible = false;
                    pnl_whether_yt.Visible = true;
                    pnl_maintain_mileage.Visible = false;

                }
                else if (selectedValue == DbDic2Enum.BILL_TYPE_YT_100000003) //维修
                {
                    pnl_promise_guarantee.Visible = true;   //特殊约定质保
                }
                else if (selectedValue == DbDic2Enum.BILL_TYPE_YT_100000005) //政策照顾
                {
                    pnl_approver_name_yt.Visible = true;    //宇通批准信息
                }
                else if (selectedValue == DbDic2Enum.BILL_TYPE_YT_100000006) //产品改进
                {
                    pnl_product_notice_no.Visible = true;   //产品改进通知
                }
                else if (selectedValue == DbDic2Enum.BILL_TYPE_YT_100000004) //服务活动
                {
                    pnl_cost_type_service_fwhd.Visible = true;  //费用类型
                }

                if (selectedValue == DbDic2Enum.BILL_TYPE_YT_100000007 ||
                    selectedValue == DbDic2Enum.BILL_TYPE_YT_100000003 ||
                    selectedValue == DbDic2Enum.BILL_TYPE_YT_100000005 ||
                    selectedValue == DbDic2Enum.BILL_TYPE_YT_100000006 ||
                    selectedValue == DbDic2Enum.BILL_TYPE_YT_100000004)
                {
                    pnl_fault.Height = 170;
                    pnl_fault_duty_corp.Visible = true;
                    pnl_fault_cause.Visible = true;
                    pnl_fault_system.Visible = true;
                    pnl_fault_assembly.Visible = true;
                    pnl_fault_part.Visible = true;
                    pnl_fault_schema.Visible = true;
                    pnl_fault_describe.Visible = true;
                    pnl_reason_analysis.Visible = true;
                    pnl_dispose_result.Visible = true;
                }
                else
                {
                    pnl_fault.Height = 75;
                    pnl_fault_duty_corp.Visible = false;
                    pnl_fault_cause.Visible = false;
                    pnl_fault_system.Visible = false;
                    pnl_fault_assembly.Visible = false;
                    pnl_fault_part.Visible = false;
                    pnl_fault_schema.Visible = false;
                    pnl_fault_describe.Visible = false;
                    pnl_reason_analysis.Visible = false;
                    pnl_dispose_result.Visible = false;
                }

                if (selectedValue == DbDic2Enum.BILL_TYPE_YT_100000000) //新车报道
                {
                    if (tabControlExBottom.TabPages.Contains(tb_wxyl))
                        tabControlExBottom.TabPages.Remove(tb_wxyl);
                }
                else
                {
                    if (!tabControlExBottom.TabPages.Contains(tb_wxyl))
                        tabControlExBottom.TabPages.Insert(0, tb_wxyl);
                    tabControlExBottom.SelectTab(tb_wxyl);
                }
                if (selectedValue == DbDic2Enum.BILL_TYPE_YT_100000007 ||
                    selectedValue == DbDic2Enum.BILL_TYPE_YT_100000003 ||
                    selectedValue == DbDic2Enum.BILL_TYPE_YT_100000005 ||
                    selectedValue == DbDic2Enum.BILL_TYPE_YT_100000006 ||
                    selectedValue == DbDic2Enum.BILL_TYPE_YT_100000004 ||
                    selectedValue == DbDic2Enum.BILL_TYPE_YT_100000000)
                {
                    tb_wxxm.Enabled = true;
                }
                else
                {
                    tb_wxxm.Enabled = false;
                }
                dtp_repairs_time.Focus();
            };
            #endregion
        }
예제 #4
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)
                     {
                         MessageBoxEx.ShowInformation("帐套创建成功!");
                         this.DialogResult = DialogResult.OK;
                     }
                     else
                     {
                         GlobalStaticObj_Server.GlobalLogService.WriteLog("账套设置", be.BackGroundException);
                         MessageBoxEx.ShowWarning("创建失败!");
                     }
                 }
             );
         #endregion
         process.Start();
     }
     catch (Exception ex)
     {
         GlobalStaticObj_Server.GlobalLogService.WriteLog("账套设置", ex);
         MessageBoxEx.ShowWarning("程序异常");
     }
 }
예제 #5
0
 public void UpdateDb()
 {
     #region 更新数据库
     string version = "V" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
     string currSoftVersion = version.Substring(0, version.Length - 2);
     string currDbVersion = BLL.DBHelper.GetSingleValue("获取版本号", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.CommAccCode, "select key_value from sys_config where key_name='DbVersion'");
     List<string> listVersion = DbCommonUtil.GetUpdateDbVersion(currSoftVersion, currDbVersion);
     if (listVersion.Count > 0)
     {
         try
         {
             #region 数据库升级
             bool flag = false;
             ProcessOperator process = new ProcessOperator();
             #region 匿名方法,后台线程执行调用
             process.BackgroundWork = delegate()
             {
                 flag = DbCommonUtil.UpdateDb(listVersion);
             };
             #endregion
             process.MessageInfo = "数据库升级中...";
             #region 匿名方法,后台线程执行完调用
             process.BackgroundWorkerCompleted += new EventHandler<BackgroundWorkerEventArgs>(
                     delegate(object osender, BackgroundWorkerEventArgs be)
                     {
                         if (be.BackGroundException == null)
                         {
                             this.DialogResult = DialogResult.OK;
                             if (flag)
                             {
                                 MessageBoxEx.ShowInformation("数据库升级成功!");
                             }
                             else
                             {
                                 MessageBoxEx.ShowWarning("数据库升级失败!");
                                 BLL.ServerUser.UserLoginOut(GlobalStaticObj_Server.Instance.UserID, GlobalStaticObj_Server.CommAccCode);
                                 Environment.Exit(-1);
                             }
                         }
                         else
                         {
                             GlobalStaticObj_Server.GlobalLogService.WriteLog("数据库升级", be.BackGroundException);
                             MessageBoxEx.ShowWarning("数据库升级异常!");
                             BLL.ServerUser.UserLoginOut(GlobalStaticObj_Server.Instance.UserID, GlobalStaticObj_Server.CommAccCode);
                             Environment.Exit(-1);
                         }
                     }
                 );
             #endregion
             process.Start();
             #endregion
         }
         catch (Exception ex)
         {
             GlobalStaticObj_Server.GlobalLogService.WriteLog("数据库升级", ex);
             MessageBoxEx.ShowWarning("程序异常");
         }
         finally
         {
             BLL.ServerUser.UserLoginOut(GlobalStaticObj_Server.Instance.UserID, GlobalStaticObj_Server.CommAccCode);
             Environment.Exit(-1);
         }
     }
     #endregion
 }
        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
        }
예제 #7
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("程序异常");
     }
 }
예제 #8
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("程序异常");
     }
 }
예제 #9
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("程序异常");
     }
 }