




已阅读5页,还剩7页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Pukuimin版权所有只是一般的操作步骤点击菜单打开manage窗体的代码 com.suohang.Client.Sale.Customer.CustomerInfomationManageForm form = new com.suohang.Client.Sale.Customer.CustomerInfomationManageForm(); UserPermissionHelper permHelper = UserPermissionHelper.getInstance(); permHelper.initControlStatusByPermission(form); string strTitle = 客户管理; InsertMenuItem(form, strTitle);manage窗体 继承窗体 GuiForm 界面上DataGridView名称为:dataGridView变量定义数据操作类对象定义DictionaryService dalDictionary = (DictionaryService)FetchRemoteObjectHelper.Instance.getRemoteObject(typeof(DictionaryService), DictionaryService.soap);Model类定义public com.suohang.MiddleInter.Model.CustomerManageModel model = new com.suohang.MiddleInter.Model.CustomerManageModel();其它变量定义 private DataTable mainTableData = new DataTable(); / / 本页面DataTable / public DataTable MainTableData get return mainTableData; set mainTableData = value; / / DataGridViewRow中的行元素 / public DataGridViewRow row; private string currentId; / / 编号 / public string CurrentId get return currentId; set currentId = value; Form_Load事件代码initData();数据初始化窗体控件初始化 DataGridView.AutoGenerateColumns = false;下拉框初始化 / / 初始化选择框数据 / private void initData() /数据状态信息 DataTable dt = (DataTable)(this.dalDictionary.getDictionaryList(data_stat).Value; ComboDataListHelp.initDataToCombo(dt, boBoxDataStatus, false, true); if (dt != null & dt.Rows.Count 0) boBoxDataStatus.SelectedValue = F;/默认选中有效 其它初始化增加、编辑、查看按钮 CustomerInfomationRecordForm AddForm = new CustomerInfomationRecordForm(this,null, FormModelPolicy.ADD); AddForm.ShowDialog();删除记录 if (this.DataGridView.Rows.Count0 & this.DataGridView.SelectedRows!=null) if (this.DataGridView.SelectedRows.Count 1) MessageBox.Show(只能一次删除一条数据!, 错误, MessageBoxButtons.OK, MessageBoxIcon.Error); return; DialogResult result = MessageBox.Show(您确定要删除选定记录吗?, 提示, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result.Equals(DialogResult.Yes) try model = new CustomerManageModel(); model.ID = (int)this.DataGridView.CurrentRow.Cellsid.Value; ; dalCustomerManage.setCustomerInfo(3, model);/按id删除记录 DataRowView drv = this.DataGridView.CurrentRow.DataBoundItem as DataRowView; drv.Delete(); catch (com.suohang.MiddleInter.SHException.SHAppException ex) MessageBox.Show(删除出错啦! + ex.ErrorMessage, 错误, MessageBoxButtons.OK, MessageBoxIcon.Error); return; else MessageBox.Show(请至少选择一条记录!, 错误, MessageBoxButtons.OK, MessageBoxIcon.Error); 搜索数据 / / 搜索数据 / public void searchResult() model.CustomerName = textBoxCustomerName.Text.Trim(); if (comboBoxBusiUserId.SelectedValue.ToString() != ) model.BussinessUserID = Convert.ToInt32(comboBoxBusiUserId.SelectedValue); else model.BussinessUserID = int.MinValue; 获取页面上的查询条件 mainTableData = (DataTable)(dalCustomerManage.getCustomerInfo(model).Value); /查数据库获取数据 DataGridView.DataSource = mainTableData; CommonFunctions.LocateRow(this.DataGridView, MainTableData, id, CurrentId, CUST_NAM);/数据定位 this.DataGridView.Refresh(); if (mainTableData.Rows.Count = 0) MessageBox.Show(未找到相关数据,您可以改变查询条件重新查询!,提示,MessageBoxButtons.OK,MessageBoxIcon.Information); 行绘制事件,为DataGridView每行写上序号/方法内的代码直接复制过去,找到对应的事件,选择此方法private void DataGridView_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, this.DataGridView.RowHeadersWidth - 4, e.RowBounds.Height); TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), this.DataGridView.RowHeadersDefaultCellStyle.Font, rectangle, this.DataGridView.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right); 完毕!Record窗体变量定义数据操作类对象定义 DictionaryService dalDictionary = (DictionaryService)FetchRemoteObjectHelper.Instance.getRemoteObject(typeof(DictionaryService), DictionaryService.soap); CustomerManagerService dalCustominf = (CustomerManagerService)FetchRemoteObjectHelper.Instance.getRemoteObject(typeof(CustomerManagerService), CustomerManagerService.soap);Model类定义private CustomerManageModel model = null;其它变量定义 / / combobox数据是否已经初始化 / private bool isInited = false;/有Index_Change事件时才需要定义 / / 唯一编号,用来存储Edit数据时的唯一标识 / public Int64 CustomerCd = Int64.MinValue; / / 主键,用来定位父窗体数据 / public int CustomerId = int.MinValue; private CustomerInfomationManageForm PForm = null; / / CustomerInfomationManageForm窗体对象 / public CustomerInfomationManageForm pForm get return PForm; set PForm = value; private DataGridViewRow row = null; / / 接收父窗体中DataGridView选中的行 / public DataGridViewRow Row get return row; set row = value; Form_Load事件代码 initComboboxData();/初始化下拉框 initControlStatus(FormType);/初始化控件状态 initData();/修改和查看时 加载数据到界面上数据初始化初始化下拉框数据 / / 初始化下拉框数据 / private void initComboboxData() try /数据状态信息 DataTable dt = (DataTable)(this.dalDictionary.getDictionaryList(data_stat).Value; ComboDataListHelp.initDataToCombo(dt, boBoxDataStatCd, true, false); if (dt != null & dt.Rows.Count 0) boBoxDataStatCd.SelectedValue = F;/默认选中有效 / isInited = true;/有Index_Change事件时才要 Index_Change_Event();/有Index_Change事件时才要 catch (Exception er) MessageBox.Show(er.ToString(); 初始化窗体控件状态 / / 初始化控件状态 / / private void initControlStatus(string mode) / 调用控件状态通用初始化方法 com.suohang.Common.CommonFunctions.InitControlStatus(this, mode); #region 非通用初始化的特殊处理 if (FormModelPolicy.isViewModel(FormType) ButtonEditContact.Enabled = ButtonAddContact.Enabled = false; #endregion 查看或修改界面显示数据 / / 从DataRow中取出数据 / / CustomerInfomationManageForm中的DataGridViewCustomerInfo的列名 / private string GetFromRow(string ColumeName) string value1 = StringHelper.IsNull(Row.CellsColumeName.Value,); return value1; / / 加载原始数据到界面上 / private void initData() if (FormModelPolicy.isEditModel(FormType) | FormModelPolicy.isViewModel(FormType)/操作为修改、查看时才查找数据 if (Row != null) try this.CustomerCd = Int64.Parse(GetFromRow(CUST_CD); comboBoxDataStatCd.SelectedValue = GetFromRow(DATA_STAT_CD); / catch (Exception er) MessageBox.Show(er.ToString(); 保存之前从界面上获取数据 / / 获取界面上输入的值 / / private CustomerManageModel GetDataFromControl() CustomerManageModel model = new CustomerManageModel(); model.ID = CustomerId; model.CustomerCD = CustomerCd; model.CustomerName = textBoxCustName.Text.Trim(); model.ChargeStatusCD = comboBoxChrgStatCd.SelectedValue.ToString(); model.ChargeEndDay = int.Parse(StringHelper.IsNull(guiNumTextBoxChrgEndDay.Text, 0);/不填时默认值为0/ return model; 保存之前检查数据 / / 检查数据有效性 / / private bool checkInput() #region 常规有效性检查 /* * exec pro_sys_generate_input_check_code model_nam varchar(200),table_nam varchar(200) * model_nam :model类名称 * table_nam :对应表名 */ if (StringHelper.isStringEmpty(this.textBoxCustName.Text) DialogResult result = MessageBox.Show(客户名称不能为空!, 错误, MessageBoxButtons.OK, MessageBoxIcon.Error); this.textBoxCustName.Focus(); return false; #endregion #region 非常规性输入有效性检验 if (textBoxCompanyFax.Text.Trim() = ) MessageBox.Show(请填写公司传真, 提示, MessageBoxButtons.OK, MessageBoxIcon.Error); return false; if (comboBoxDataStatCd.SelectedItem = null | comboBoxDataStatCd.SelectedIndex = 0) MessageBox.Show(请选择数据状态, 提示, MessageBoxButtons.OK, MessageBoxIcon.Error); return false; #endregion return true; 保存数据 / / 保存数据 saveData() / / private bool saveData() try if (checkInput() model = GetDataFromControl(); object obj = dalCustominf.isExistCustomer(model).Value;/检查重复性 int iResult = int.Parse(obj.ToString();/为0表示没有记录 if (iResult 0) if (model.ID != iResult)/不等于当前Id-表示存在另外的记录,不是当前正在编辑的记录 MessageBox.Show(客户名称或显示名称已存在!n, 保存提示, MessageBoxButtons.OK, MessageBoxIcon.Information); return false; string result = ; if (FormModelPolicy.isAddModel(FormType) result = (string)dalCustominf.setCustomerInfo(1, model).Value; MessageBox.Show(添加客户信息成功!); else if (Fo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 中国广电莆田市2025秋招笔试行测题库及答案行业解决方案经理岗
- 2025年彩票招聘考试题及答案
- 安徽地区中石化2025秋招面试半结构化模拟题及答案炼油工艺技术岗
- 中国联通潮州市2025秋招供应链采购类专业追问清单及参考回答
- 中国联通乐山市2025秋招面试典型题目及答案
- 儋州市中储粮2025秋招安全环保岗高频笔试题库含答案
- 中国联通肇庆市2025秋招行业常识50题速记
- 国家能源漳州市2025秋招计算机与自动化类面试追问及参考回答
- 中国联通益阳市2025秋招计算机类专业追问清单及参考回答
- 中国移动铁岭市2025秋招综合管理类专业追问清单及参考回答
- 卒中后抑郁的中西医治疗
- 劳保穿戴安全知识培训课件
- 超薄磨耗层施工技术交底
- 2025年成人高考专升本政治真题及答案
- 配送管理实务试卷及答案
- 精神病人福利院建设项目建议书
- 2025-2030中国N-甲基苯胺市场深度调查与前景预测分析报告
- 中医护理学基础理论测试题(附答案)
- 2025至2030年中国雪崩光电二极管行业市场现状调查及前景战略研判报告
- 2025年湖北省中考语文试卷真题(含标准答案)
- 2025年国有企业土地使用权出让合同标准文本
评论
0/150
提交评论