資源描述:
《客戶資料管理模塊代碼--窗體功能設(shè)計》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、3.客戶資料管理模塊代碼--窗體功能設(shè)計--企業(yè)客戶資源管理系統(tǒng)客戶資料管理模塊用來實現(xiàn)客戶信息的添加、修改、刪除和查找功能。該窗體中使用了公共類OperateAndValidate中的相關(guān)方法分別對客戶聯(lián)系電話、傳真號碼、郵編和E-mail地址格式進(jìn)行驗證,只有在全部驗證都通過時,才可以進(jìn)行客戶信息的添加、修改和保存操作。=》公共類BaseOperate.cs和OperateAndValidate.cs源代碼代碼設(shè)計如下:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSyst
2、em.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Data.SqlClient;namespaceCRM.DataManage{publicpartialclassfrmClientManage:Form{/**聲明公共類BaseOperate和OperateAndVaildate的兩個全局對象,通過類對象調(diào)用類中的功能方法,然后聲明3個保護(hù)類型的全局變量,分別用于表示*SQL語句、數(shù)據(jù)表名和判斷用戶單擊的是“添加”按鈕還是“修改”按鈕,代碼如下:*/CRM.Base
3、Class.BaseOperateboperate=newCRM.BaseClass.BaseOperate();CRM.BaseClass.OperateAndValidateopAndvalidate=newCRM.BaseClass.OperateAndValidate();protectedstringM_str_sql="selectClientIDas客戶編號,CNameas客戶名稱,CStepas客戶等級,"+"CRootas客戶來源,CTradeas所屬行業(yè),CTypeas客戶類別,CAreaas所在區(qū)域,CPhoneas聯(lián)系電話,"+"CFaxas傳真號碼,CPo
4、stCodeas郵政編碼,CAddressas聯(lián)系地址,CEmailasEmail地址,CRemarkas備注fromtb_ClientInfo";protectedstringM_str_table="tb_ClientInfo";protectedintM_int_judge;publicfrmClientManage(){InitializeComponent();}/**frmClientManage窗體的Load事件中,通過調(diào)用公共類OperateAndVaildate中的cboxBind()方法和BaseOperate中的getds()方法分別對ComboBox控件進(jìn)行
5、數(shù)據(jù)綁定和*生成一個DataSet對象,然后利用生成的DataSet對象對DataGridView控件進(jìn)行數(shù)據(jù)綁定。實現(xiàn)代碼如下:*/privatevoidfrmClientManage_Load(objectsender,EventArgse){opAndvalidate.cboxBind("selectAreaNamefromtb_Area","tb_Area","AreaName",cboxCArea);DataSetmyds=boperate.getds(M_str_sql,M_str_table);dgvClientInfo.DataSource=myds.Tables[
6、0];if(myds.Tables[0].Rows.Count>0)tsbtnDel.Enabled=true;elsetsbtnDel.Enabled=false;}/**單擊“添加”按鍵,程序調(diào)用公共類OperateAndVaildate中的autoNum()方法生成一個新的編號,顯示在“客戶編號”文本框中,然后將“保存”按鈕的Enable屬性設(shè)置為true,并*給全局變量“M_int_judge”賦值為0。代碼如下:*/privatevoidtsbtnAdd_Click(objectsender,EventArgse){opAndvalidate.autoNum("selec
7、tClientIDfromtb_ClientInfo","tb_ClientInfo","ClientID","KH","1000001",txtClientCode);tsbtnSave.Enabled=true;M_int_judge=0;ClearText();}/**單擊“修改”按鈕,將“保存”按鈕的Enabled屬性設(shè)置為true,并給全局變量"M_int_judge"賦值為1,代碼如下:*/privatevoidtsbtnEdit_Click(object