模块开发过程小总结1.docx
- 文档编号:29852473
- 上传时间:2023-07-27
- 格式:DOCX
- 页数:16
- 大小:19.07KB
模块开发过程小总结1.docx
《模块开发过程小总结1.docx》由会员分享,可在线阅读,更多相关《模块开发过程小总结1.docx(16页珍藏版)》请在冰豆网上搜索。
模块开发过程小总结1
只是一般的操作步骤
点击菜单打开manage窗体的代码
com.suohang.Client.Sale.Customer.CustomerInfomationManageFormform=newcom.suohang.Client.Sale.Customer.CustomerInfomationManageForm();
UserPermissionHelperpermHelper=UserPermissionHelper.getInstance();
permHelper.initControlStatusByPermission(form);
stringstrTitle="客户管理";
InsertMenuItem(form,strTitle);
manage窗体
继承窗体
GuiForm
界面上DataGridView名称为:
dataGridView
变量定义
数据操作类对象定义
DictionaryServicedalDictionary=(DictionaryService)FetchRemoteObjectHelper.Instance.getRemoteObject(typeof(DictionaryService),"DictionaryService.soap");
……………………
Model类定义
publiccom.suohang.MiddleInter.Model.CustomerManageModelmodel=newcom.suohang.MiddleInter.Model.CustomerManageModel();
其它变量定义
privateDataTablemainTableData=newDataTable();
///
///本页面DataTable
///
publicDataTableMainTableData
{
get{returnmainTableData;}
set{mainTableData=value;}
}
///
///DataGridViewRow中的行元素
///
publicDataGridViewRowrow;
privatestringcurrentId;
///
///编号
///
publicstringCurrentId
{
get{returncurrentId;}
set{currentId=value;}
}
Form_Load事件代码
initData();
数据初始化
窗体控件初始化
DataGridView.AutoGenerateColumns=false;
下拉框初始化
///
///初始化选择框数据
///
privatevoidinitData()
{
//数据状态信息
DataTabledt=
(DataTable)(this.dalDictionary.getDictionaryList("data_stat")).Value;
ComboDataListHelp.initDataToCombo(dt,boBoxDataStatus,false,true);
if(dt!
=null&&dt.Rows.Count>0)
{
boBoxDataStatus.SelectedValue="F";//默认选中有效
}
}
其它初始化
……
增加、编辑、查看按钮
CustomerInfomationRecordFormAddForm=newCustomerInfomationRecordForm(this,null,FormModelPolicy.ADD);
AddForm.ShowDialog();
删除记录
if(this.DataGridView.Rows.Count>0&&this.DataGridView.SelectedRows!
=null)
{
if(this.DataGridView.SelectedRows.Count>1)
{
MessageBox.Show("只能一次删除一条数据!
","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
return;
}
DialogResultresult=MessageBox.Show("您确定要删除选定记录吗?
","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question,MessageBoxDefaultButton.Button2);
if(result.Equals(DialogResult.Yes))
{
try
{
model=newCustomerManageModel();
model.ID=(int)this.DataGridView.CurrentRow.Cells["id"].Value;;
dalCustomerManage.setCustomerInfo(3,model);//按id删除记录
DataRowViewdrv=this.DataGridView.CurrentRow.DataBoundItemasDataRowView;
drv.Delete();
}
catch(com.suohang.MiddleInter.SHException.SHAppExceptionex)
{
MessageBox.Show("删除出错啦!
"+ex.ErrorMessage,"错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
return;
}
}
}
else
{
MessageBox.Show("请至少选择一条记录!
","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
搜索数据
///
///搜索数据
///
publicvoidsearchResult()
{
model.CustomerName=textBoxCustomerName.Text.Trim();
if(comboBoxBusiUserId.SelectedValue.ToString()!
="")
model.BussinessUserID=Convert.ToInt32(comboBoxBusiUserId.SelectedValue);
elsemodel.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每行写上序号
//方法内的代码直接复制过去,找到对应的事件,选择此方法
privatevoidDataGridView_RowPostPaint
(objectsender,DataGridViewRowPostPaintEventArgse)
{
Rectanglerectangle=newRectangle(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窗体
变量定义
数据操作类对象定义
DictionaryServicedalDictionary=(DictionaryService)FetchRemoteObjectHelper.Instance.getRemoteObject(typeof(DictionaryService),"DictionaryService.soap");
CustomerManagerServicedalCustominf=(CustomerManagerService)FetchRemoteObjectHelper.Instance.getRemoteObject(typeof(CustomerManagerService),"CustomerManagerService.soap");
Model类定义
privateCustomerManageModelmodel=null;
其它变量定义
///
///combobox数据是否已经初始化
///
privateboolisInited=false;//有Index_Change事件时才需要定义
///
///唯一编号,用来存储Edit数据时的唯一标识
///
publicInt64CustomerCd=Int64.MinValue;
///
///主键,用来定位父窗体数据
///
publicintCustomerId=int.MinValue;
privateCustomerInfomationManageFormPForm=null;
///
///CustomerInfomationManageForm窗体对象
///
publicCustomerInfomationManageFormpForm
{
get{returnPForm;}
set{PForm=value;}
}
privateDataGridViewRowrow=null;
///
///接收父窗体中DataGridView选中的行
///
publicDataGridViewRowRow
{
get{returnrow;}
set{row=value;}
}
Form_Load事件代码
initComboboxData();//初始化下拉框
initControlStatus(FormType);//初始化控件状态
initData();//修改和查看时加载数据到界面上
数据初始化
初始化下拉框数据
///
///初始化下拉框数据
///
privatevoidinitComboboxData()
{
try
{
//数据状态信息
DataTabledt=(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(Exceptioner)
{
MessageBox.Show(er.ToString());
}
}
初始化窗体控件状态
///
///初始化控件状态
///
///
privatevoidinitControlStatus(stringmode)
{
//调用控件状态通用初始化方法
com.suohang.Common.CommonFunctions.InitControlStatus(this,mode);
#region非通用初始化的特殊处理
if(FormModelPolicy.isViewModel(FormType))
{
ButtonEditContact.Enabled=ButtonAddContact.Enabled=false;
}
#endregion
}
查看或修改界面显示数据
///
///从DataRow中取出数据
///
///
///
privatestringGetFromRow(stringColumeName)
{
stringvalue1=StringHelper.IsNull(Row.Cells[ColumeName].Value,"");
returnvalue1;
}
///
///加载原始数据到界面上
///
privatevoidinitData()
{
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(Exceptioner)
{
MessageBox.Show(er.ToString());
}
}
}
}
保存之前从界面上获取数据
///
///获取界面上输入的值
///
///
privateCustomerManageModelGetDataFromControl()
{
CustomerManageModelmodel=newCustomerManageModel();
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
//………………………………………………………………
returnmodel;
}
保存之前检查数据
///
///检查数据有效性
///
///
privateboolcheckInput()
{
#region常规有效性检查
/**
*execpro_sys_generate_input_check_code@model_namvarchar(200),@table_namvarchar(200)
*@model_nam:
model类名称
*@table_nam:
对应表名
***********************************************************************/
if(StringHelper.isStringEmpty(this.textBoxCustName.Text))
{
DialogResultresult=MessageBox.Show("客户名称不能为空!
","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
this.textBoxCustName.Focus();
returnfalse;
}
#endregion
#region非常规性输入有效性检验
if(textBoxCompanyFax.Text.Trim()=="")
{
MessageBox.Show("请填写公司传真","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
returnfalse;
}
if(comboBoxDataStatCd.SelectedItem==null||comboBoxDataStatCd.SelectedIndex==0)
{
MessageBox.Show("请选择数据状态","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
returnfalse;
}
#endregion
returntrue;
}
保存数据
///
///保存数据saveData()
///
///
privateboolsaveData()
{
try
{
if(checkInput())
{
model=GetDataFromControl();
objectobj=dalCustominf.isExistCustomer(model).Value;//检查重复性
intiResult=int.Parse(obj.ToString());//为0表示没有记录
if(iResult>0)
{
if(model.ID!
=iResult)//不等于当前Id--表示存在另外的记录,不是当前正在编辑的记录
{
MessageBox.Show("客户名称或显示名称已存在!
\n","保存提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
returnfalse;
}
}
stringresult="";
if(FormModelPolicy.isAddModel(FormType))
{
result=(string)dalCustominf.setCustomerInfo(1,model).Value;
MessageBox.Show("添加客户信息成功!
");
}
elseif(FormModelPolicy.isEditModel(FormType))
{
result=(string)dalCustominf.setCustomerInfo(2,model).Value;
MessageBox.Show("修改客户信息成功!
");
}
FormType=FormModelPolicy.DEFAULT;
pForm.CurrentId=result;//id值用来在searchResult中定位
pForm.searchResult();//父窗体数据刷新
returntrue;
}
else
{
returnfalse;
}
}
catch(Exceptionex)//SHAppException
{
MessageBox.Show("保存出错啦!
"+ex.ToString(),"错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
returnfalse;
}
}
下拉框选择改变时的函数
///
///SelectedIndexChanged触发的函数
///
privatevoidIndex_Change_Event()
{
if(isInited)//加载完成后才触发事件
{
DataTabledt=newDataTable();
stringtypecd=th
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 模块 开发 过程 总结