Ejemplo n.º 1
0
        //初始化
        private void Init()
        {
            #region 设置功能按钮可见性
            UIAssistants.SetUCBaseFuncationVisible(this, new ObservableCollection <ButtonEx_sms>()
            {
                btnSave, btnCancel, btnSet, btnView, btnPrint
            });
            #endregion

            #region 初始化下拉框数据绑定
            CommonCtrl.CmbBindDict(cbo_cb_Callback_type, "sys_callback_type", false); //绑定回访类型
            CommonCtrl.CmbBindDict(cbo_cb_Callback_mode, "sys_callback_mode", false); //绑定回访方式
            CommonCtrl.CmbBindDict(cbo_member_class, "sys_member_grade", false);      //绑定会员等级
            CommonFuncCall.BindProviceComBox(cbo_province, "请选择");                    //绑定省份
            CommonFuncCall.BindCityComBox(cbo_city, "", "请选择");                       //绑定城市
            CommonFuncCall.BindCountryComBox(cbo_county, "", "请选择");                  //绑定县/区
            cbo_province.SelectedIndexChanged += ddlprovince_SelectedIndexChanged;
            cbo_city.SelectedIndexChanged     += ddlcity_SelectedIndexChanged;
            CommonCtrl.CmbBindDict(cbo_cust_type, "sys_customer_category", false);  //客户类别
            #endregion

            lbl_cb_create_by.Text = GlobalStaticObj.CurrUserCom_Name;
            lbl_cb_create_by.Tag  = GlobalStaticObj.UserID;
            if (windowStatus == WindowStatus.Edit || windowStatus == WindowStatus.View)
            {
                SetCustInfo();
                SetContInfo();
                SetCallbackInfo();
            }
            if (windowStatus == WindowStatus.View)
            {
                palQTop.Enabled = false;
            }
            #region 注册功能按钮事件
            #region  择客户信息
            txt_cust_code.ChooserClick += delegate
            {
                var frmCustomer = new frmCustomerInfo();
                var result      = frmCustomer.ShowDialog();
                if (result == DialogResult.OK)
                {
                    CustId             = frmCustomer.strCustomerId;
                    txt_cust_code.Tag  = CustId;
                    txt_cust_code.Text = frmCustomer.strCustomerNo;
                }

                SetCustInfo();
            };
            #endregion

            #region  择被回访人
            txt_cb_Callback_by.ChooserClick += delegate
            {
                var frmContacts = new frmContacts();
                var result      = frmContacts.ShowDialog();
                if (result == DialogResult.OK)
                {
                    ContId = frmContacts.contID;
                    txt_cb_Callback_by.Tag           = ContId;
                    txt_cb_Callback_by.Text          = frmContacts.contName;
                    txt_cb_Callback_by_duty.Caption  = frmContacts.contDuty;
                    txt_cb_Callback_by_phone.Caption = frmContacts.contPhone;
                }
            };
            #endregion

            #region  择经办人
            txt_handle_name.ChooserClick += delegate
            {
                var chooser = new frmUsers();
                var result  = chooser.ShowDialog();
                if (result == DialogResult.OK)
                {
                    txt_handle_name.Text      = chooser.User_Name;
                    txt_handle_name.Tag       = chooser.User_ID;
                    txt_cb_handle_org.Caption = chooser.OrgName;
                }
            };
            #endregion

            CancelEvent += (sender, args) => deleteMenuByTag(Tag.ToString(), UCCallBackManager.Name);

            #region 保存数据
            SaveEvent += delegate
            {
                var check = CheckValue();
                if (!check)
                {
                    return;
                }
                var dicFileds = new Dictionary <String, String>();
                if (windowStatus == WindowStatus.Add)
                {
                    dicFileds.Add("create_by", GlobalStaticObj.UserID);                       //创建人
                    dicFileds.Add("create_time", DBHelper.GetCurrentTime().Ticks.ToString()); //创建时间
                    dicFileds.Add("update_by", GlobalStaticObj.UserID);                       //最后编辑人
                    dicFileds.Add("update_time", DBHelper.GetCurrentTime().Ticks.ToString()); //最后编辑时间
                    dicFileds.Add("Callback_id", Guid.NewGuid().ToString());                  //客户ID
                    dicFileds.Add("status", "58b325d2-0792-4847-8e4a-22b3f25628f3");          //数据状态
                }
                else if (windowStatus == WindowStatus.Edit)
                {
                    dicFileds.Add("update_by", GlobalStaticObj.UserID);                        //最后编辑人
                    dicFileds.Add("update_time", DBHelper.GetCurrentTime().Ticks.ToString());  //最后编辑时间
                }
                dicFileds.Add("Callback_corp", txt_cust_code.Tag.ToString());                  //客户ID
                dicFileds.Add("Callback_time", DBHelper.GetCurrentTime().Ticks.ToString());    //回访时间
                dicFileds.Add("Callback_type", cbo_cb_Callback_type.SelectedValue.ToString()); //回访类型
                dicFileds.Add("Callback_mode", cbo_cb_Callback_mode.SelectedValue.ToString()); //回访方式
                dicFileds.Add("title", txt_cb_title.Caption);                                  //回访标题
                dicFileds.Add("record", rtx_cb_record.Text);                                   //回访内容
                dicFileds.Add("Callback_by", txt_cb_Callback_by.Tag.ToString());               //被回访人员名称
                dicFileds.Add("Callback_by_org", txt_cb_Callback_by_org.Caption);              //被回访人员部门名称
                dicFileds.Add("Callback_by_phone", txt_cb_Callback_by_phone.Caption);          //被回访人电话
                dicFileds.Add("Callback_by_duty", txt_cb_Callback_by_duty.Caption);            //被回访人职务
                dicFileds.Add("handle_name", txt_handle_name.Tag.ToString());                  //经办人
                dicFileds.Add("handle_org", txt_cb_handle_org.Caption);                        //经办人部门名称
                var result = false;
                try
                {
                    result = DBHelper.Submit_AddOrEdit("保存客户回访", "tb_CustomerSer_Callback", "Callback_id", CallBackId, dicFileds);
                }
                catch (Exception ex)
                {
                    result = false;
                }
                MessageBoxEx.Show(result ? "保存成功!" : "保存失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
                if (result)
                {
                    UCCallBackManager.BindPageData();
                    _autoClose = false;
                    deleteMenuByTag(Tag.ToString(), UCCallBackManager.Name);
                }
            };
            #endregion
            #endregion
        }
Ejemplo n.º 2
0
        //初始化
        private void Init()
        {
            #region 设置功能按钮可见性
            UIAssistants.SetUCBaseFuncationVisible(this, new ObservableCollection <ButtonEx_sms>()
            {
                btnSave, btnCancel, btnSet, btnView, btnPrint
            });
            #endregion

            #region 初始化下拉框数据绑定
            CommonCtrl.CmbBindDict(cbo_cb_Callback_type, "sys_callback_type", false); //绑定回访类型
            CommonCtrl.CmbBindDict(cbo_cb_Callback_mode, "sys_callback_mode", false); //绑定回访方式
            CommonCtrl.CmbBindDict(cbo_member_class, "sys_member_grade", false);      //绑定会员等级
            CommonFuncCall.BindProviceComBox(cbo_province, "请选择");                    //绑定省份
            CommonFuncCall.BindCityComBox(cbo_city, "", "请选择");                       //绑定城市
            CommonFuncCall.BindCountryComBox(cbo_county, "", "请选择");                  //绑定县/区
            cbo_province.SelectedIndexChanged += ddlprovince_SelectedIndexChanged;
            cbo_city.SelectedIndexChanged     += ddlcity_SelectedIndexChanged;
            CommonCtrl.CmbBindDict(cbo_cust_type, "sys_customer_category", false);  //客户类别
            #endregion

            lbl_cb_create_by.Text = GlobalStaticObj.CurrUserCom_Name;
            lbl_cb_create_by.Tag  = GlobalStaticObj.UserID;
            if (windowStatus == WindowStatus.Edit || windowStatus == WindowStatus.View)
            {
                SetCustInfo();
                SetContInfo();
                SetCallbackInfo();
            }
            if (windowStatus == WindowStatus.View)
            {
                palQTop.Enabled = false;
            }
            #region 注册功能按钮事件
            #region  择客户信息
            txt_cust_code.ChooserClick += delegate
            {
                var frmCustomer = new frmCustomerInfo();
                var result      = frmCustomer.ShowDialog();
                if (result == DialogResult.OK)
                {
                    CustId             = frmCustomer.strCustomerId;
                    txt_cust_code.Tag  = CustId;
                    txt_cust_code.Text = frmCustomer.strCustomerNo;
                    SetCustInfo();
                }
            };
            dataGridViewEx1.CellContentClick += delegate(object sender, DataGridViewCellEventArgs args)
            {
                if (args.ColumnIndex < 0 || args.RowIndex < 0)
                {
                    return;
                }
                if (dataGridViewEx1.Columns[args.ColumnIndex] == drtxt_maintain_no)
                {
                    var ytServiceNo = CommonCtrl.IsNullToString(dataGridViewEx1.Rows[args.RowIndex].Cells[drtxt_maintain_id.Name].Value);
                    if (String.IsNullOrEmpty(CommonCtrl.IsNullToString(ytServiceNo)))
                    {
                        return;
                    }
                    var uc = new RepairQueryView(ytServiceNo);
                    uc.addUserControl(uc, "维修单-详细信息", "RepairQueryView" + ytServiceNo, Tag.ToString(),
                                      Name);
                }
            };
            #endregion

            #region  择被回访人
            txt_cb_Callback_by.ChooserClick += delegate
            {
                var frmContacts = new frmContacts();
                var result      = frmContacts.ShowDialog();
                if (result == DialogResult.OK)
                {
                    ContId = frmContacts.contID;
                    txt_cb_Callback_by.Tag           = ContId;
                    txt_cb_Callback_by.Text          = frmContacts.contName;
                    txt_cb_Callback_by_duty.Caption  = frmContacts.contDuty;
                    txt_cb_Callback_by_phone.Caption = frmContacts.contPhone;
                }
            };
            #endregion

            #region  择经办人
            txt_handle_name.ChooserClick += delegate
            {
                var chooser = new frmUsers();
                var result  = chooser.ShowDialog();
                if (result == DialogResult.OK)
                {
                    txt_handle_name.Text      = chooser.User_Name;
                    txt_handle_name.Tag       = chooser.User_ID;
                    txt_cb_handle_org.Caption = chooser.OrgName;
                }
            };
            #endregion

            //CancelEvent += (sender, args) => deleteMenuByTag(Tag.ToString(), UCCallBackManager.Name);
            CancelEvent += new ClickHandler(UCCallBackAddOrEdit_CancelEvent);

            #region 保存数据
            SaveEvent += delegate
            {
                var check = CheckValue();
                if (!check)
                {
                    return;
                }
                var dicFileds = new Dictionary <String, String>();
                if (windowStatus == WindowStatus.Add)
                {
                    dicFileds.Add("create_by", GlobalStaticObj.UserID);                       //创建人
                    dicFileds.Add("create_time", DBHelper.GetCurrentTime().Ticks.ToString()); //创建时间
                    dicFileds.Add("update_by", GlobalStaticObj.UserID);                       //最后编辑人
                    dicFileds.Add("update_time", DBHelper.GetCurrentTime().Ticks.ToString()); //最后编辑时间
                    dicFileds.Add("Callback_id", Guid.NewGuid().ToString());                  //客户ID
                    dicFileds.Add("status", "58b325d2-0792-4847-8e4a-22b3f25628f3");          //数据状态
                }
                else if (windowStatus == WindowStatus.Edit)
                {
                    DBHelper.BatchDeleteDataByWhere("删除客户与维修单关系", "tr_maintain_customer_callback", String.Format("callback_id = '{0}'", CallBackId));
                    dicFileds.Add("update_by", GlobalStaticObj.UserID);                        //最后编辑人
                    dicFileds.Add("update_time", DBHelper.GetCurrentTime().Ticks.ToString());  //最后编辑时间
                }
                dicFileds.Add("Callback_corp", txt_cust_code.Tag.ToString());                  //客户ID
                dicFileds.Add("Callback_time", DBHelper.GetCurrentTime().Ticks.ToString());    //回访时间
                dicFileds.Add("Callback_type", cbo_cb_Callback_type.SelectedValue.ToString()); //回访类型
                dicFileds.Add("Callback_mode", cbo_cb_Callback_mode.SelectedValue.ToString()); //回访方式
                dicFileds.Add("title", txt_cb_title.Caption);                                  //回访标题
                dicFileds.Add("record", rtx_cb_record.Text);                                   //回访内容
                dicFileds.Add("Callback_by", txt_cb_Callback_by.Tag.ToString());               //被回访人员名称
                dicFileds.Add("Callback_by_org", txt_cb_Callback_by_org.Caption);              //被回访人员部门名称
                dicFileds.Add("Callback_by_phone", txt_cb_Callback_by_phone.Caption);          //被回访人电话
                dicFileds.Add("Callback_by_duty", txt_cb_Callback_by_duty.Caption);            //被回访人职务
                dicFileds.Add("handle_name", txt_handle_name.Tag.ToString());                  //经办人
                dicFileds.Add("handle_org", txt_cb_handle_org.Caption);                        //经办人部门名称
                var result = false;
                try
                {
                    result = DBHelper.Submit_AddOrEdit("保存客户回访", "tb_CustomerSer_Callback", "Callback_id", CallBackId, dicFileds);
                    if (result)
                    {
                        const string sqlStr        = "INSERT INTO tr_maintain_customer_callback(id,maintain_id,customer_id ,callback_id) VALUES(@id,@maintain_id,@customer_id,@callback_id)";
                        var          list          = GetCheckRows();
                        var          sysSqlStrList = list.Select(str => new SysSQLString
                        {
                            cmdType = CommandType.Text, sqlString = sqlStr, Param = new Dictionary <string, string>
                            {
                                { "@id", Guid.NewGuid().ToString() }, { "@maintain_id", str }, { "@customer_id", txt_cust_code.Tag.ToString() }, { "@callback_id", String.IsNullOrEmpty(CallBackId) ? dicFileds["Callback_id"] : CallBackId }
                            }
                        }).ToList();
                        DBHelper.BatchExeSQLStringMultiByTrans("添加客户与维修单关系", sysSqlStrList);
                    }
                }
                catch (Exception ex)
                {
                    result = false;
                }
                MessageBoxEx.Show(result ? "保存成功!" : "保存失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
                if (result)
                {
                    UCCallBackManager.BindPageData();
                    _autoClose = false;
                    deleteMenuByTag(Tag.ToString(), UCCallBackManager.Name);
                }
            };
            #endregion
            #endregion
        }