private void ddlProvince_SelectedIndexChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(ddlProvince.SelectedValue.ToString())) { CommonFuncCall.BindCityComBox(ddlCity, ddlProvince.SelectedValue.ToString(), "全部"); CommonFuncCall.BindCountryComBox(ddlArea, ddlCity.SelectedValue.ToString(), "全部"); } else { CommonFuncCall.BindCityComBox(ddlCity, "", "全部"); CommonFuncCall.BindCountryComBox(ddlArea, "", "全部"); } }
private void ddlprovince_SelectedIndexChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(cbo_province.SelectedValue.ToString())) { CommonFuncCall.BindCityComBox(cbo_city, cbo_province.SelectedValue.ToString(), "请选择"); CommonFuncCall.BindCountryComBox(cbo_county, cbo_city.SelectedValue.ToString(), "请选择"); } else { CommonFuncCall.BindCityComBox(cbo_city, "", "请选择"); CommonFuncCall.BindCountryComBox(cbo_county, "", "请选择"); } }
private void cboprovince_SelectedIndexChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(cboprovince.SelectedValue.ToString())) { CommonFuncCall.BindCityComBox(cbocity, cboprovince.SelectedValue.ToString(), "请选择"); CommonFuncCall.BindCountryComBox(cbocounty, cbocity.SelectedValue.ToString(), "请选择"); } else { CommonFuncCall.BindCityComBox(cbocity, "", "请选择"); CommonFuncCall.BindCountryComBox(cbocounty, "", "请选择"); } if (errContrl == this.cboprovince) { errContrl = null; errorProvider1.Clear(); } }
/// <summary> /// 绑定下拉框信息 /// </summary> void BindDllInfo() { ddlSupplierType.Items.Clear(); ddlCompanyNature.Items.Clear(); ddlState.Items.Clear(); //绑定供应商分类 CommonFuncCall.BindComBoxDataSource(ddlSupplierType, "sys_supplier_category", "全部"); //绑定企业性质类型 CommonFuncCall.BindComBoxDataSource(ddlCompanyNature, "sys_enterprise_property", "全部"); CommonFuncCall.BindProviceComBox(ddlProvince, "全部"); CommonFuncCall.BindCityComBox(ddlCity, "", "全部"); CommonFuncCall.BindCountryComBox(ddlArea, "", "全部"); ddlState.DataSource = DataSources.EnumToList(typeof(DataSources.EnumStatus), true); ddlState.ValueMember = "Value"; ddlState.DisplayMember = "Text"; }
/// <summary> /// 绑定下拉框信息 /// </summary> private void BindDllInfo() { ddlsup_type.Items.Clear(); ddlunit_properties.Items.Clear(); ddlcredit_class.Items.Clear(); ddlprice_type.Items.Clear(); //绑定供应商分类 CommonFuncCall.BindComBoxDataSource(ddlsup_type, "sys_supplier_category", "请选择"); //绑定企业性质类型 CommonFuncCall.BindComBoxDataSource(ddlunit_properties, "sys_enterprise_property", "请选择"); //绑定信用等级类型 CommonFuncCall.BindComBoxDataSource(ddlcredit_class, "sys_enterprise_credit_class", "请选择"); //绑定价格商类型 CommonFuncCall.BindComBoxDataSource(ddlprice_type, "sys_price_type", "请选择"); CommonFuncCall.BindProviceComBox(ddlprovince, "请选择"); CommonFuncCall.BindCityComBox(ddlcity, "", "请选择"); CommonFuncCall.BindCountryComBox(ddlcounty, "", "请选择"); }
private void FuncationRegiste() //事件注册 { #region 数据表数据选择 //单元格数据转换 dgv_table.CellFormatting += (sender, args) => ConvertDataGridColumnsData(args); //数据行双击事件 dgv_table.CellDoubleClick += delegate(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) { return; } var value = dgv_table.Rows[e.RowIndex].Cells[cust_id.Name].Value; if (value == null) { return; } var id = value.ToString(); var ucCustomerView = new UCCustomerViews { Id = id, UCCustomerManager = this }; addUserControl(ucCustomerView, "客户详细信息", "UCCustomerViews" + id, Tag.ToString(), Name); } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; #endregion #region 数据翻页 pageQ.PageIndexChanged += delegate { BindPageData(); }; #endregion #region 清除按钮事件 btn_clear.Click += delegate { try { UIAssistants.ClearQueryControlValue(pnl_query); } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; #endregion #region 查询 btn_query.Click += (sender, args) => { pageQ.PageIndex = 1; pageQ.RecordCount = 0; BindPageData(); }; #endregion #region 新增 btnAdd.Click += delegate { try { var ucCustomerAddOrEdit = new UCCustomerAddOrEdit { UCCustomerManager = this, windowStatus = WindowStatus.Add }; addUserControl(ucCustomerAddOrEdit, "客户信息新增", "UCCustomerAddOrEdit-Add", Tag.ToString(), Name); } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; #endregion #region 制 btnCopy.Click += delegate { try { var id = ""; var dataView = UIAssistants.GetDataGridCheckRows(dgv_table, colCheck, cust_id, TableName); if (dataView == null) { return; } foreach (DataRowView rowView in dataView) { id = rowView["cust_id"].ToString(); break; } var ucCustomerAddOrEdit = new UCCustomerAddOrEdit { UCCustomerManager = this, windowStatus = WindowStatus.Copy, Id = id }; addUserControl(ucCustomerAddOrEdit, "客户信息拷贝", "UCCustomerAddOrEdit-Copy" + ucCustomerAddOrEdit.Id, Tag.ToString(), Name); } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; #endregion #region 编辑 btnEdit.Click += delegate { try { var id = ""; var dataView = UIAssistants.GetDataGridCheckRows(dgv_table, colCheck, cust_id, TableName); if (dataView == null) { return; } foreach (DataRowView rowView in dataView) { id = rowView["cust_id"].ToString(); break; } var ucCustomerAddOrEdit = new UCCustomerAddOrEdit { UCCustomerManager = this, windowStatus = WindowStatus.Edit, Id = id }; addUserControl(ucCustomerAddOrEdit, "客户信息编辑", "UCCustomerAddOrEdit-Edit" + ucCustomerAddOrEdit.Id, Tag.ToString(), Name); } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; #endregion #region 除 btnDelete.Click += delegate { try { var selectedRows = UIAssistants.GetDataGridCheckRows(dgv_table, colCheck, cust_id); if (selectedRows.Count == 0) { MessageBoxEx.Show("请选择删除记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (MessageBoxEx.Show("确认要删除吗?", "提示", MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } //var comField = new Dictionary<string, string> { { "enable_flag", "0" } }; //flag = DBHelper.BatchUpdateDataByIn("删除三包服务单", TableName, comField, "tg_id", selectedRows.ToArray()); var comField = new Dictionary <string, string> { { "enable_flag", "0" } }; var flag = DBHelper.BatchUpdateDataByIn("批量删除客户档案", "tb_customer", comField, "cust_id", selectedRows.ToArray()); foreach (var selectedRow in selectedRows) { var crmIdDt = DBHelper.GetTable("查询客户档案信息", "tb_customer", "cust_crm_guid", String.Format("cust_id = '{0}'", selectedRow), "", ""); if (crmIdDt != null && crmIdDt.Rows.Count == 1) { DBHelper.WebServHandler("删除客户档案", EnumWebServFunName.UpLoadCustomer, new tb_customer { cust_crm_guid = CommonCtrl.IsNullToString(crmIdDt.Rows[0][0]), status = "0" }); } } 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); } } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); MessageBoxEx.Show("删除失败!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }; #endregion #region 省市区联动 cboprovince.SelectedIndexChanged += delegate { try { if (!string.IsNullOrEmpty(cboprovince.SelectedValue.ToString())) { CommonFuncCall.BindCityComBox(cbocity, cboprovince.SelectedValue.ToString(), "市"); CommonFuncCall.BindCountryComBox(cbocounty, cbocity.SelectedValue.ToString(), "区/县"); } else { CommonFuncCall.BindCityComBox(cbocity, "", "市"); CommonFuncCall.BindCountryComBox(cbocounty, "", "区/县"); } } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; cbocity.SelectedIndexChanged += delegate { try { if (!string.IsNullOrEmpty(cbocity.SelectedValue.ToString())) { CommonFuncCall.BindCountryComBox(cbocounty, cbocity.SelectedValue.ToString(), "区/县"); } else { CommonFuncCall.BindCountryComBox(cbocounty, "", "区/县"); } } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; #endregion #region 启用停用事件 StatusEvent += delegate { try { var listSql = new List <SQLObj>(); const string opName = "修改客户档案状态"; var strStatus = Convert.ToInt16(_eStatus).ToString(CultureInfo.InvariantCulture); string msg; if (_eStatus == DataSources.EnumStatus.Start) //启用 { StatusSql(listSql, _tiList, strStatus); //停用的ti_list改为启用 msg = "启用"; } else//停用 { StatusSql(listSql, _qiList, strStatus);//启用的qi_list 改为停用 msg = "停用"; } if (MessageBoxEx.Show("确认要" + msg + "吗?", "提示", MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } if (DBHelper.BatchExeSQLMultiByTrans(opName, listSql)) { btnStatus.Enabled = false; BindPageData(); MessageBoxEx.Show(msg + "成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBoxEx.Show(msg + "失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; #endregion #region 数据表格事件 dgv_table.CellContentClick += delegate(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex != 0) { return; } _qiList.Clear(); _tiList.Clear(); _eStatus = new DataSources.EnumStatus(); foreach (DataGridViewRow row in dgv_table.Rows) { if (!Convert.ToBoolean(row.Cells[0].EditedFormattedValue)) { continue; } if (row.Cells["status"].EditedFormattedValue.ToString() == DataSources.EnumStatus.Start.GetDescription()) //表格中是启用 { _qiList.Add(row.Cells["cust_id"].EditedFormattedValue.ToString()); } else//表格中是停用 { _tiList.Add(row.Cells["cust_id"].EditedFormattedValue.ToString()); } } BtnStatus(_qiList, _tiList); } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; dgv_table.HeadCheckChanged += delegate { try { _qiList.Clear(); _tiList.Clear(); _eStatus = new DataSources.EnumStatus(); foreach (DataGridViewRow row in dgv_table.Rows) { if (Convert.ToBoolean(row.Cells[0].Value)) { if (row.Cells["status"].Value.ToString() == DataSources.EnumStatus.Start.GetDescription())//表格中是启用 { _qiList.Add(row.Cells["cust_id"].Value.ToString()); } else//表格中是停用 { _tiList.Add(row.Cells["cust_id"].Value.ToString()); } } } BtnStatus(_qiList, _tiList); } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; #endregion #region 根据选择的数据判断功能按钮的显示状态 dgv_table.CellMouseUp += delegate { try { var dataView = UIAssistants.GetDataGridCheckRows(dgv_table, colCheck, cust_id, TableName); if (dataView == null) { btnCopy.Enabled = false; btnEdit.Enabled = false; btnDelete.Enabled = false; return; } var isYt = dataView.Cast <DataRowView>().Any(rowView => CommonCtrl.IsNullToString(rowView["data_source"]) == "2"); var listField = UIAssistants.GetDataGridCheckRows(dgv_table, colCheck, cust_id); if (listField.Count == 0) { btnCopy.Enabled = false; btnEdit.Enabled = false; btnDelete.Enabled = false; } else { btnCopy.Enabled = true; btnEdit.Enabled = true; btnDelete.Enabled = true; } if (isYt) { btnEdit.Enabled = false; btnDelete.Enabled = false; } } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; #endregion }
//初始化 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 }
/// <summary> /// 绑定下拉框信息 /// </summary> private void BindDllInfo() { CommonFuncCall.BindProviceComBox(ddlprovince, "请选择"); CommonFuncCall.BindCityComBox(ddlcity, "", "请选择"); CommonFuncCall.BindCountryComBox(ddlcounty, "", "请选择"); }
//初始化 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 }
private void FuncationRegiste() //事件注册 { #region 数据表数据选择 //单元格数据转换 dgv_table.CellFormatting += (sender, args) => ConvertDataGridColumnsData(args); //数据行双击事件 dgv_table.CellDoubleClick += delegate(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) { return; } var value = dgv_table.Rows[e.RowIndex].Cells[cust_id.Name].Value; if (value == null) { return; } var id = value.ToString(); var ucCustomerView = new UCCustomerViews { Id = id, UCCustomerManager = this }; addUserControl(ucCustomerView, "客户详细信息", "UCCustomerViews" + id, Tag.ToString(), Name); } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; //ViewEvent += delegate //{ // try // { // if (dgv_table.SelectedRows.Count != 1) return; // var value = dgv_table.SelectedRows[0].Cells[cust_id.Name].Value; // if (value == null) return; // var id = value.ToString(); // var ucCustomerView = new UCCustomerViews // { // Id = id, // UCCustomerManager = this // }; // addUserControl(ucCustomerView, "客户详细信息", "UCCustomerViews" + id, Tag.ToString(), Name); // } // catch (Exception ex) // { // LogService4Customer.WriteLog(1, ex); // } //}; #endregion #region 数据翻页 pageQ.PageIndexChanged += delegate { BindPageData(); }; #endregion #region 清除按钮事件 btn_clear.Click += delegate { try { UIAssistants.ClearQueryControlValue(pnl_query); } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; #endregion #region 查询 btn_query.Click += (sender, args) => { pageQ.PageIndex = 1; pageQ.RecordCount = 0; BindPageData(); }; #endregion #region 预览事件 btnView.Click += delegate { businessPrint.Preview(dgv_table.GetBoundData()); } ; #endregion #region 打印事件 btnPrint.Click += delegate { businessPrint.Print(dgv_table.GetBoundData()); }; #endregion #region 设置事件 btnSet.Click += delegate { businessPrint.PrintSet(dgv_table); } ; #endregion #region 导出事件 btnExport.Click += delegate { if (this.dgv_table.Rows.Count == 0) { return; } try { string fileName = "客户档案" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls"; ExcelHandler.ExportExcel(fileName, dgv_table); } catch (Exception ex) { Utility.Log.Log.writeLineToLog("【客户档案】" + ex.Message, "server"); MessageBoxEx.ShowWarning("导出失败!"); } }; #endregion #region 新增 btnAdd.Click += delegate { try { var ucCustomerAddOrEdit = new UCCustomerAddOrEdit { UCCustomerManager = this, windowStatus = WindowStatus.Add }; addUserControl(ucCustomerAddOrEdit, "客户信息新增", "UCCustomerAddOrEdit-Add", Tag.ToString(), Name); } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; #endregion #region 制 btnCopy.Click += delegate { try { var id = ""; var dataView = UIAssistants.GetDataGridCheckRows(dgv_table, colCheck, cust_id, TableName); if (dataView == null) { return; } foreach (DataRowView rowView in dataView) { id = rowView["cust_id"].ToString(); break; } var ucCustomerAddOrEdit = new UCCustomerAddOrEdit { UCCustomerManager = this, windowStatus = WindowStatus.Copy, Id = id }; addUserControl(ucCustomerAddOrEdit, "客户信息拷贝", "UCCustomerAddOrEdit-Copy" + ucCustomerAddOrEdit.Id, Tag.ToString(), Name); } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; #endregion #region 编辑 btnEdit.Click += delegate { try { var id = ""; var dataView = UIAssistants.GetDataGridCheckRows(dgv_table, colCheck, cust_id, TableName); if (dataView == null) { return; } foreach (DataRowView rowView in dataView) { id = rowView["cust_id"].ToString(); break; } var ucCustomerAddOrEdit = new UCCustomerAddOrEdit { UCCustomerManager = this, windowStatus = WindowStatus.Edit, Id = id }; addUserControl(ucCustomerAddOrEdit, "客户信息编辑", "UCCustomerAddOrEdit-Edit" + ucCustomerAddOrEdit.Id, Tag.ToString(), Name); } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; #endregion #region 除 btnDelete.Click += delegate { try { var selectedRows = UIAssistants.GetDataGridCheckRows(dgv_table, colCheck, cust_id); if (selectedRows.Count == 0) { MessageBoxEx.Show("请选择删除记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (MessageBoxEx.Show("确认要删除吗?", "提示", MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } //var comField = new Dictionary<string, string> { { "enable_flag", "0" } }; //flag = DBHelper.BatchUpdateDataByIn("删除三包服务单", TableName, comField, "tg_id", selectedRows.ToArray()); var comField = new Dictionary <string, string> { { "enable_flag", "0" } }; var flag = DBHelper.BatchUpdateDataByIn("批量删除客户档案", "tb_customer", comField, "cust_id", selectedRows.ToArray()); foreach (var selectedRow in selectedRows) { var crmIdDt = DBHelper.GetTable("查询客户档案信息", "tb_customer", "cust_crm_guid", String.Format("cust_id = '{0}'", selectedRow), "", ""); if (crmIdDt != null && crmIdDt.Rows.Count == 1) { BeginInvoke(new MethodInvoker(delegate() { DBHelper.WebServHandler("删除客户档案", EnumWebServFunName.UpLoadCustomer, new tb_customer { cust_crm_guid = CommonCtrl.IsNullToString(crmIdDt.Rows[0][0]), status = "1", accessories_discount = 0, agency = "", bank_account = "", bank_account_person = "", billing_account = "", billing_address = "", billing_name = "", business_scope = "", city = "", com_constitution = "", country = "", county = "", create_by = "", create_time = 0, credit_account_period = 0, credit_line = 0, credit_rating = "", cust_address = "", cust_code = "", cust_email = "", cust_fax = "", cust_id = "", cust_name = "", cust_phone = "", cust_quick_code = "", cust_relation = "", cust_remark = "", cust_short_name = "", cust_tel = "", cust_type = "", cust_website = "", data_source = "", enable_flag = "", ent_qualification = "", enterprise_nature = "", indepen_legalperson = "", institution_code = "", is_member = "", legal_person = "", market_segment = "", member_class = "", member_number = "", member_period_validity = 0, open_bank = "", price_type = "", province = "", registered_capital = "", sap_code = "", tax_num = "", update_by = "", update_time = 0, vehicle_structure = "", workhours_discount = 0, yt_customer_manager = "", yt_sap_code = "", zip_code = "" }); })); } } 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); } } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); MessageBoxEx.Show("删除失败!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }; #endregion #region 省市区联动 cboprovince.SelectedIndexChanged += delegate { try { if (!string.IsNullOrEmpty(cboprovince.SelectedValue.ToString())) { CommonFuncCall.BindCityComBox(cbocity, cboprovince.SelectedValue.ToString(), "市"); CommonFuncCall.BindCountryComBox(cbocounty, cbocity.SelectedValue.ToString(), "区/县"); } else { CommonFuncCall.BindCityComBox(cbocity, "", "市"); CommonFuncCall.BindCountryComBox(cbocounty, "", "区/县"); } } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; cbocity.SelectedIndexChanged += delegate { try { if (!string.IsNullOrEmpty(cbocity.SelectedValue.ToString())) { CommonFuncCall.BindCountryComBox(cbocounty, cbocity.SelectedValue.ToString(), "区/县"); } else { CommonFuncCall.BindCountryComBox(cbocounty, "", "区/县"); } } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; #endregion #region 启用停用事件 StatusEvent += delegate { try { var listSql = new List <SQLObj>(); const string opName = "修改客户档案状态"; var strStatus = Convert.ToInt16(_eStatus).ToString(CultureInfo.InvariantCulture); string msg; if (_eStatus == DataSources.EnumStatus.Start) //启用 { StatusSql(listSql, _tiList, strStatus); //停用的ti_list改为启用 msg = "启用"; } else//停用 { StatusSql(listSql, _qiList, strStatus);//启用的qi_list 改为停用 msg = "停用"; } if (MessageBoxEx.Show("确认要" + msg + "吗?", "提示", MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } if (DBHelper.BatchExeSQLMultiByTrans(opName, listSql)) { btnStatus.Enabled = false; BindPageData(); MessageBoxEx.Show(msg + "成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBoxEx.Show(msg + "失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; #endregion #region 数据表格事件 dgv_table.CellContentClick += delegate(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex != 0) { return; } _qiList.Clear(); _tiList.Clear(); _eStatus = new DataSources.EnumStatus(); foreach (DataGridViewRow row in dgv_table.Rows) { if (!Convert.ToBoolean(row.Cells[0].EditedFormattedValue)) { continue; } if (row.Cells["status"].EditedFormattedValue.ToString() == DataSources.EnumStatus.Start.GetDescription()) //表格中是启用 { _qiList.Add(row.Cells["cust_id"].EditedFormattedValue.ToString()); } else//表格中是停用 { _tiList.Add(row.Cells["cust_id"].EditedFormattedValue.ToString()); } } BtnStatus(_qiList, _tiList); } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; dgv_table.HeadCheckChanged += delegate { try { _qiList.Clear(); _tiList.Clear(); _eStatus = new DataSources.EnumStatus(); foreach (DataGridViewRow row in dgv_table.Rows) { if (Convert.ToBoolean(row.Cells[0].Value)) { if (row.Cells["status"].Value.ToString() == DataSources.EnumStatus.Start.GetDescription())//表格中是启用 { _qiList.Add(row.Cells["cust_id"].Value.ToString()); } else//表格中是停用 { _tiList.Add(row.Cells["cust_id"].Value.ToString()); } } } BtnStatus(_qiList, _tiList); } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; #endregion #region 根据选择的数据判断功能按钮的显示状态 dgv_table.CellMouseUp += delegate { try { var dataView = UIAssistants.GetDataGridCheckRows(dgv_table, colCheck, cust_id, TableName); if (dataView == null) { btnCopy.Enabled = false; btnEdit.Enabled = false; btnDelete.Enabled = false; return; } var isYt = dataView.Cast <DataRowView>().Any(rowView => CommonCtrl.IsNullToString(rowView["data_source"]) == "2"); var listField = UIAssistants.GetDataGridCheckRows(dgv_table, colCheck, cust_id); if (listField.Count == 0) { btnCopy.Enabled = false; btnEdit.Enabled = false; btnDelete.Enabled = false; } else { btnCopy.Enabled = true; btnEdit.Enabled = true; btnDelete.Enabled = true; } if (isYt) { btnEdit.Enabled = false; btnDelete.Enabled = false; } } catch (Exception ex) { LogService4Customer.WriteLog(1, ex); } }; #endregion }