超市进销存系统设计
歡迎添加微信互相交流學習哦!
項目源碼:https://gitee.com/oklongmm/biye
超市進銷存系統
?
-
- 設計目的
根據所學的數據庫原理與程序設計的知識,能夠針對一個小型的數據庫管理信息系統,進行系統的需求分析,系統設計,數據庫設計,編碼,測試等,完成題目要求的功能,從而達到掌握開發一個小型數據庫管理信息系統的目的。
?
-
- 設計內容
題目可根據自己熟悉的物品填充,例如圖書進銷存系統、電腦設備進銷存系統、藥品進銷存系統等等,下面以超市進銷存系統為例完成功能:
??? 以上功能可根據自己對不同物品主要的管理需求進行調整,可以增加或減少相應功能。
?
【需求分析】
對普通超市來講,涉及原材料的進貨渠道、銷售情況及庫存等方面的管理,管理的好與壞對超市的持久性至關重要。概括地說,用戶對進銷存系統的需求具有普遍性。超市進銷存銷售管理系統適用于超市采購、銷售和倉庫部門,對超市采購、銷售及倉庫的業務全過程進行有效控制和跟蹤。使用超市進銷存銷售管理系統可有效減少盲目采購、降低采購成本、合理控制庫存、減少資金占用并提高市場靈敏度,提升超市的市場競爭力。
【系統運行環境】
【系統設計】
超市進銷存銷售管理系統功能結構圖:
?
| 超市進銷存管理系統 |
| 銷售管理 |
| 進貨管理 |
| 庫存管理 |
| 系統維護 |
| 基本檔案 |
| 員工信息 |
| 供應商信息 |
| 商品進貨 |
| 商品查詢 |
| 商品銷售 |
| 商品退貨 |
| 庫存警報 |
| 庫存查詢 |
| 數據備份 |
| 數據還原 |
?
?
系統業務流程圖:
?
| 否 |
| 是 |
| 系統登 錄 |
| 是否登錄 |
| 系統主窗體 |
| 銷售管理 |
| 進貨管理 |
| 庫存管理 |
| 系統維護 |
| 基本檔案 |
?
?
【概念結構設計】
供應商信息實體E-R圖:
?
| 供應商信息表 |
| 備注 |
| 地址 |
| 加入時間 |
| 傳真 |
| 是否發布 |
| 供應商編號 |
| 供應商姓名 |
| 聯系人姓名 |
| 聯系電話 |
?
?
員工信息實體E-R圖:
?
| 員工信息表 |
| 家庭電話 |
| 員工職位 |
| 手機號碼 |
| 員工生日 |
| 是否發布 |
| 員工編號 |
| 員工姓名 |
| 登錄密碼 |
| 員工性別 |
| 所屬部門 |
| 家庭住址 |
| 登錄ID |
?
?
進貨信息實體E-R圖:
?
| 進貨信息表 |
| 應付金額 |
| 銷售單價 |
| 實付金額 |
| 商品數量 |
| 刪除標記 |
| 操作員編號 |
| 員工姓名 |
| 庫存名稱 |
| 貨物名稱 |
| 進貨單價 |
| 備注 |
| 進貨公司名稱 |
| 商品計量單位 |
| 進貨時間 |
?
?
【邏輯結構設計】
根據設計好的E-R圖在數據庫中建立各表,系統數據庫中各表的邏輯結構如下:
供應商信息表:
?
| 字段名 | 數據類型 | 長度 | 主鍵 | 描述 |
| CompanyID | varchar | 50 | 否 | 供應商編號 |
| CompanyName | nvarchar | 100 | 否 | 供應商姓名 |
| CompanyDirector | nvarchar | 50 | 否 | 聯系人姓名 |
| CompanyPhone | nvarchar | 20 | 否 | 聯系電話 |
| CompanyFax | nvarchar | 20 | 否 | 傳真 |
| CompanyAddress | nvarchar | 200 | 否 | 地址 |
| CompanyRemark | nvarchar | 400 | 否 | 備注 |
| ReDateTime | datetime | 8 | 否 | 加入日期 |
| Falg | int | 4 | 否 | 是否發布 |
員工信息表:
| 字段名 | 數據類型 | 長度 | 主鍵 | 描述 |
| EmpID | nvarchar | 20 | 是 | 員工編號 |
| EmpName | nvarchar | 20 | 否 | 員工姓名 |
| EmpLoginName | nvarchar | 20 | 否 | 登錄ID |
| EmpLoginPwd | nvarchar | 20 | 否 | 登錄密碼 |
| EmpSex | nvarchar | 4 | 否 | 員工性別 |
| EmpBirthday | datetime | 8 | 否 | 員工生日 |
| EmpDept | nvarchar | 20 | 否 | 所屬部門 |
| EmpPost | nvarchar | 20 | 否 | 員工職位 |
| EmpPhone | nvarchar | 20 | 否 | 家庭電話 |
| EmpPhoneM | nvarchar | 20 | 否 | 手機號碼 |
| EmpAddress | nvarchar | 200 | 否 | 家庭住址 |
| EmpFalg | int | 1 | 否 | 是否發布 |
進貨信息表:
| 字段名 | 數據類型 | 長度 | 主鍵 | 描述 |
| GoodsID | nvarchar | 20 | 是 | 商品編號 |
| EmpId | nvarchar | 20 | 否 | 操作員編號 |
| JhCompName | nvarchar | 100 | 否 | 進貨公司名稱 |
| DepotName | nvarchar | 20 | 否 | 倉庫名稱 |
| GoodsName | nvarchar | 50 | 否 | 貨物名稱 |
| GoodsNum | int | 4 | 否 | 商品數量 |
| GoodsUnit | nvarchar | 20 | 否 | 商品計量單位 |
| GoodsJhPrice | nvarchar | 8 | 否 | 進貨單價 |
| GoodsSellPrice | nvarchar | 8 | 否 | 銷售單價 |
| GoodsNeedPrice | nvarchar | 8 | 否 | 應付金額 |
| GoodsNoPrice | nvarchar | 8 | 否 | 實付金額 |
| GoodsRemark | nvarchar | 200 | 否 | 備注 |
| GoodTime | datetime | 8 | 否 | 進貨時間 |
| Falg | int | 4 | 否 | 刪除標記 |
?
【窗體設計】
登錄窗口:
?
主窗口:
?
員工基本信息窗體:
?
供應商信息窗體:
?
商品進貨窗體:
?
商品查詢窗體:
窗體頂端
【總結】
??? 該系統是用C#完成的,實現的功能比較全面,界面美觀。但是需要寫太多代碼,會遇到許多細節方面的問題(如:數據庫的連接、類的使用、函數的使用等等)。還有很多地方有待完善。通過這次的學習設計,對數據庫更加了解,還有很多不足的地方。對C#學的還不深,還要多學習,提高自己。
【主要代碼設計】
【員工基本信息窗體】
1.通過對員工信息的錄入,修改,刪除,保存進行操作,在對員工的信息錄入時候,員工姓名,登錄名稱和登錄密碼的相關操作是必須的 ,因為涉及到了下次登錄時候身份的鑒定,相關代碼如下:
??????? public int getPan()
??????? {
??????????? int intFalg1 = 0;
??????????? if (intFalg != 3)
??????????? {
??????????????? if (txtEmpName.Text == "")
??????????????? {
??????????????????? MessageBox.Show("員工姓名不能為空!", "提示");
??????????????????? txtEmpName.Focus();
??????????????????? return intFalg1;
??????????????? }
??????????????? if (txtEmpLoginName.Text == "")
??????????????? {
??????????????????? MessageBox.Show("登錄名稱不能為空!", "提示");
??????????????????? return intFalg1;
??????????????? }
??????????????? if (intFalg != 2)
??????????????? {
??????????????????? if (txtEmpLoginPwd.Text == "")
??????????????????? {
??????????????????????? MessageBox.Show("登錄密碼不能為空!", "提示");
??????????????????????? return intFalg1;
??????????????????? }
??????????????? }
???? 2.通過對員工的查詢,可以知道員工的信息,查詢可根據很多方面的信息而查到所向知道的員工的信息,所一就需要輸入查詢條件,根據查詢條件而知道所向知道的信息,比如員工姓名,性別,所屬部門,員工職位,姓名查詢是最準確并且速度的方法,性別,所屬部門,職位這些查詢條件是比較含糊的查詢,客戶通過自己想要的方式查到員工的信息,相關的代碼如下:
??????? private void txtOK_Click(object sender, EventArgs e)
??????? {
??????????? string P_Str_selectcondition = this.cbxCondition.Text;
??????????????? //Items[this.cbxCondition.SelectedIndex].ToString();
??????????? if (P_Str_selectcondition == null)
??????????? {
??????????????? MessageBox.Show("請選擇查詢條件!");
??????????????? return;
??????????? }
??????????? if (this.txtKeyWord.Text == "")
??????????? {
??????????????? MessageBox.Show("輸入查詢條件!");
??????????????? return;
??????????? }
??????????? switch (P_Str_selectcondition)
??????????? {
??????????????? case "員工姓名":
??????????????????? tbMenthod.tb_EmpInfoFind(txtKeyWord.Text,1,dataGridView1);
??????????????????? break;
?????? ?????????case "員工性別":
??????????????????? tbMenthod.tb_EmpInfoFind(txtKeyWord.Text, 2, dataGridView1);
??????????????????? break;
??????????????? case "所屬部門":
??????????????????? tbMenthod.tb_EmpInfoFind(txtKeyWord.Text, 3, dataGridView1);
??????????????? ????break;
??????????????? case "員工職位":
??????????????????? tbMenthod.tb_EmpInfoFind(txtKeyWord.Text, 4, dataGridView1);
??????????????????? break;
??????????????? default:
??????????????????? break;
??????????? }
??????? }
????? ?如果客戶 查詢到員工的信息之后,想做一些的修改 刪除,添加之類的修改,如果添加員工信息的話,則要錄入新員工的詳細信息,如修改的員工信息的話可根據某方面的信息進行相關的修該,如刪除員工信息的話,則要對員工的信息進行全部的刪除,并相應的保存到數據庫里面,方便下次客戶對員工的信息進行相關的操作,具體修改 ,刪除,添加的操作代碼如下:
??????? private void toolSave_Click(object sender, EventArgs e)
??????? {
??????????? if (getPan() == 1)
?????????? ?{
??????????????? if (intFalg == 1)
??????????????? {
??????????????????? if (tbMenthod.tb_EmpInfoFind(txtEmpLoginName.Text,"",1) == 1)
??????????????????? {
??????????????????????? MessageBox.Show("登錄名稱已被占用!!");
??????????????????????? txtEmpLoginName.Text = "";
??????????????????????? txtEmpLoginName.Focus();
??????????????????????? return;
??????????????????? }
???????????????????
??????????????????? if (tbMenthod.tb_EmpInfoAdd(EmpClass) == 1)
??????????????????? {
??????????????????????? MessageBox.Show("添加成功");
??????????????????????? intFalg = 0;
??????????????????????? tbMenthod.tb_EmpInfoFind("", 5, dataGridView1);
??????????????????????? ClearControls();
??????????????????????? ControlStatus();
??????????????????? }
??????????????????? else
????????? ??????????{
??????????????????????? MessageBox.Show("添加成失敗");
??????????????????????? intFalg = 0;
??????????????????????? //tbMenthod.tb_EmpInfoFind("2",dataGridView1);
??????????????????????? ClearControls();
??????????????????????? ControlStatus();
??? ????????????????}
??????????????? }
??????????????? if (intFalg == 2)
??????????????? {
??????????????????? if (tbMenthod.tb_EmpInfoUpdate(EmpClass)==1)
??????????????????? {
??????????????????????? MessageBox.Show("修改成功");
??????????????????????? intFalg = 0;
??????????????????????? tbMenthod.tb_EmpInfoFind("", 5, dataGridView1);
??????????????????????? ClearControls();
??????????????????????? ControlStatus();
??????????????????? }
??????????????????? else
??????????????????? {
??????????????????????? MessageBox.Show("修改成失敗");
??????????????????????? intFalg = 0;
??????????????????????? //tbMenthod.tb_EmpInfoFind("2",dataGridView1);
??????????????????????? ClearControls();
??????????????????????? ControlStatus();
??????????????????? }
??????????????? }
??????????????? if (intFalg == 3)
??????????????? {
??????????????????? if (tbMenthod.tb_EmpInfoDelete(EmpClass) == 1)
??????????????????? {
??????????????????????? MessageBox.Show("刪除成功");
??????????????????????? intFalg = 0;
??????????????????????? tbMenthod.tb_EmpInfoFind("", 5, dataGridView1);
??????????????????????? ClearControls();
??????????????????????? ControlStatus();
??????????????????? }
??????????????????? else
??????????????????? {
??????????????????????? MessageBox.Show("刪除失敗");
??????????????????????? intFalg = 0;
??????????????????????? ClearControls();
??????????????????????? ControlStatus();
??????????????????? }
??????????????? }
??????????? }
??????? }
【供應商信息窗體】
2對控件的清零狀態,方便進行相關的操作,即信息初始化,代碼如下:
??????? private void ClearControls()
??????? {
??????????? txtCompanyDirector.Text = "";
??????????? txtCompanyAddress.Text = "";
??????????? txtCompanyFax.Text = "";
??????????? txtCompanyName.Text = "";
??????????? txtCompanyPhone.Text = "";
??????????? txtCompanyRemark.Text = "";
??????????
??????? }
????? 2.1 通過對供應商的信息錄入,并保存到數據庫里面,此外應注意的是供應商的名稱,聯系電話,地址是必須的填寫的,否則不不可以錄入并進行相關操作的,如少填寫一項,會彈出相應的對話框,代碼如下:
??????? public int GetCount()
??????? {
??????????? int intReslult = 0;
??????????? if (intFalg == 1 || intFalg == 2)
??????????? {
??????????????? if (txtCompanyName.Text == "")
??????????????? {
??????????????????? MessageBox.Show("供應商名稱不能為空!", "提示");
??????????????????? return intReslult;
??????????????? }
??????????????? if (txtCompanyPhone.Text == "")
??????????????? {
??????????????????? MessageBox.Show("聯系電話不能為空!", "提示");
??????????????????? return intReslult;
??????????????? }
??????????????? if (txtCompanyDirector.Text == "")
??????????????? {
??????????????????? MessageBox.Show("地址不能為空!", "提示");
??????????????????? return intReslult;
??????????????? }
?????? ???2.2客戶對相關的信息進行操作之后,需要保存到數據庫,但是應注意的是相關的信息必須是準確的,避免下次信息調出的時候出現差錯,因為數據庫是共同享有的,所以必須保證供應商資料的準確性,通過保存之前的添加,修改,刪除操作并保存到數據庫的代碼如下:
??????? private void toolSave_Click(object sender, EventArgs e)
??????? {
??????????? if (GetCount() == 1)
??????????? {
?????????? ?????if (intFalg == 1)
??????????????? {
??????????????????? if (CompanyMenthod.tb_CompanyMenthodAdd(Company) == 1)
??????????????????? {
??????????????????????? if (intReturn == 1)
??????????????????????? {
??????????????????????????? frmGonYingShang frmCop= (frmGonYingShang)this.Owner;
??????????????????????????? jhgood.filltProd(frmCop.treeView1,frmCop.imageList1);
??????????????????????????? ClearControls();
??????????????????????????? ControlStatus();
??????????????????????????? intFalg = 0;
????????? ??????????????????this.Close();
???????????????????????????
???????????????????????
??????????????????????? }
??????????????????????? MessageBox.Show("添加成功");
??????????????????????? intFalg = 0;
??????????????????????? CompanyMenthod.tb_CompanyFind("", 3, dataGridView1);
??????????????????????? ClearControls();
??????????????????????? ControlStatus();
???????????????????????
??????????????????? }
??????????????????? else
??????????????????? {
??????????????????????? MessageBox.Show("添加失敗");
??????????? ????????????intFalg = 0;
??????????????????????? CompanyMenthod.tb_CompanyFind("", 3, dataGridView1);
??????????????????????? ClearControls();
??????????????????????? ControlStatus();
??????????????????? }
??????????????? }
??????????????? if (intFalg == 2)
??????????????? {
??????????????????? if (CompanyMenthod.tb_CompanyMenthodUpDate(Company) == 1)
??????????????????? {
??????????????????????? MessageBox.Show("修改成功");
??????????????????????? intFalg = 0;
??????????????????????? CompanyMenthod.tb_CompanyFind("", 3, dataGridView1);
??????????????????????? ClearControls();
??????????????????????? ControlStatus();
??????????????????? }
??????????????????? else
???? ???????????????{
??????????????????????? MessageBox.Show("修改失敗");
??????????????????????? intFalg = 0;
??????????????????????? CompanyMenthod.tb_CompanyFind("", 3, dataGridView1);
??????????????????????? ClearControls();
??????????????????????? ControlStatus();
??????????????????? }
??????????????? }
??????????????? if (intFalg ==3)
??????????????? {
??????????????????? if (CompanyMenthod.tb_CompanyMenthodDelete(Company) == 1)
??????????????????? {
??????????????????????? MessageBox.Show("刪除成功");
????????? ??????????????intFalg = 0;
??????????????????????? CompanyMenthod.tb_CompanyFind("", 3, dataGridView1);
??????????????????????? ClearControls();
??????????????????????? ControlStatus();
??????????????????? }
??????????????????? else
??????????????????? {
??????????????????????? MessageBox.Show("刪除失敗");
??????????????????????? intFalg = 0;
??????????????????????? CompanyMenthod.tb_CompanyFind("", 3, dataGridView1);
??????????????????????? ClearControls();
??????????????????????? ControlStatus();
??????????????????? }
??????????????? }
??????????? }
??????? }
?????? 2.3客戶對供應商的信息做好相關的操作之后,則方便其他客戶對供應商的資料查詢,可根據的供應商的名稱,負責人姓名而知道所想知道的相關信息,相關的代碼如下:
??????? private void txtOK_Click(object sender, EventArgs e)
??????? {
??????????? string P_Str_cmdtxt = String.Empty;
??????????? string P_Str_selectcondition = this.cbxCondition.Text;
??????????? if (P_Str_selectcondition == null)
??????????? {
??????????????? MessageBox.Show("請選擇查詢條件!");
??????????????? return;
??????????? }
??????????? if (this.txtKeyWord.Text == "")
??????????? {
??????????????? MessageBox.Show("輸入查詢條件!");
??????????????? return;
??????????? }
??????????? switch (P_Str_selectcondition)
??????????? {
??????????????? case "供應商名稱":
??????????????????? CompanyMenthod.tb_CompanyFind(txtKeyWord.Text,1,dataGridView1);
??????????????????? break;
??? ????????????case "負責人姓名":
??????????????????? CompanyMenthod.tb_CompanyFind(txtKeyWord.Text, 2, dataGridView1);
??????????????????? break;
??????????????? default:
??????????????????? break;
??????????? }
??????? }
【商品進貨窗體】
3定義方法getIntCount(),用于獲取表單的信息,在具體的實現上,將通過if語句驗證各字段的輸入的數據不為空,對應放入實現代碼如下:
??????? public int getIntCount()
??????? {
??????????? int intReslut = 0;
??????????? if (intFalg == 1)
??????????? {
??????????????? if (txtGoodsID.Text == "")
??????????????? {
??????????????????? MessageBox.Show("商品編號不能為空!");
??????????????????? return intReslut;
??????????????? }
??????????????? if (txtGoodsName.Text == "")
??????????????? {
??????????????????? MessageBox.Show("商品名稱不能為空!");
??????????????????? return intReslut;
??????????????? }
??????????????? if (txtJhCompName.Text == "")
??????????????? {
??????????????????? MessageBox.Show("供應商名稱不能為空!");
??????????????????? return intReslut;
??????????????? }
??????????????? if (txtEmpId.Text == "")
??????????????? {
??????????????????? MessageBox.Show("進貨人姓名不能為空!");
??????????????????? return intReslut;
??????????????? }
??????????????? if (txtGoodsNum.Text == "")
??????????????? {
??????????????????? MessageBox.Show("數量不能為空!");
??????????????????? return intReslut;
??????????????? }
??????????????? if (txtGoodsName.Text == "")
??????????????? {
??????????????????? MessageBox.Show("進貨單價不能為空!");
??????????????????? return intReslut;
??????????????? }
??????????? }
??????????? if (intFalg == 2)
??????????? {
??????????????? if (txtGoodsID.Text == "")
????????????? ??{
??????????????????? MessageBox.Show("商品編號不能為空!,選擇要修改記錄","提示");
??????????????????? return intReslut;
??????????????? }
??????????? }
??????????? if (intFalg == 3)
??????????? {
??????????????? if (txtGoodsID.Text == "")
??????????????? {
????????????? ??????MessageBox.Show("商品編號不能為空!,選擇要刪除記錄", "提示");
??????????????????? return intReslut;
??????????????? }
??????????? }
??????????? jhGood.strGoodsID = txtGoodsID.Text;
??????????? jhGood.strEmpId = txtEmpId.Text;
??????????? jhGood.strJhCompName = txtGoodsName.Text;
??????????? jhGood.strDepotName = cmbDepotName.Text;
??????????? jhGood.strGoodsNum = Convert.ToInt32(txtGoodsNum.Text);
??????????? jhGood.strGoodsName = txtGoodsName.Text;
??????????? jhGood.strGoodsUnit = cmbGoodsUnit.Text;
??????????? jhGood.deGoodsJhPrice = txtGoodsJhPrice.Text;
??????????? jhGood.deGoodsNeedPrice = txtGoodsNeedPrice.Text;
??????????? jhGood.deGoodsNoPrice = txtGoodsNoPrice.Text;
??????????? jhGood.deGoodsSellPrice = txtGoodsSellPrice.Text;
??????????? jhGood.strGoodsRemark = txtGoodsRemark.Text;
??????????? jhGood.DaGoodTime = dateTimePicker1.Value;
??????????? if (intFalg != 3)
??????????? {
??????????????? jhGood.Falg = 0;
??????????? }
??????????? else
??????????? {
??????????????? jhGood.Falg = 1;
??????????? }
??????? ????intReslut = 1;
??????????? return intReslut;
??????? }
3.1加載時顯示所有的商品信息,將結果綁定到DataGirdView控件上,對應的實現代碼如下:
??????? private void frmJhGoodsInfo_Load(object sender, EventArgs e)
??????? {
??????????? jhMenthod.tb_JhGoodsInfoFind("", 5, dataGridView1);
???? ???}
3.2在上述代碼中,通過調用方法FillControls()顯示了單擊新機的詳細內容,方法FillControls()的具體實現代碼如下:
??????? private void FillControls()
??????? {
??????????? try
??????????? {
???????????????
??????????????? SqlDataReader sqldr = jhMenthod.tb_JhGoodsInfoFind(this.dataGridView1[0, this.dataGridView1.CurrentCell.RowIndex].Value.ToString(),1);
??????????????? sqldr.Read();
??????????????? if (sqldr.HasRows)
??????????????? {
???????????????????? txtEmpId.Text=sqldr[1].ToString();
????????????????????? txtGoodsName.Text=sqldr[4].ToString();
????????????????????? cmbDepotName.Text = sqldr[3].ToString();
???????????????????
?????????????????? txtGoodsNum.Text=sqldr[5].ToString();
??????????????????? cmbGoodsUnit.Text=sqldr[6].ToString();
??????????????????? txtGoodsJhPrice.Text=sqldr[7].ToString();
??????????????????? txtGoodsNeedPrice.Text=sqldr[9].ToString();
????????????????? txtGoodsNoPrice.Text=sqldr[10].ToString();
??????????????????? txtGoodsSellPrice.Text=sqldr[8].ToString();
??????????????????? txtGoodsRemark.Text=sqldr[11].ToString();
??????????????????? txtJhCompName.Text = sqldr[2].ToString();
????????????????
??????????????????? txtGoodsID.Text = sqldr[0].ToString();
?????????????????? txtGoodsID.Enabled = false;
??????????????? }
??????????? }
??????????? catch (Exception ee)
??????????? {
??????????????? MessageBox.Show(ee.ToString());
??????????? }
??????? }
??????? 3.3單擊【添加】按鈕可以添加新的進貨信息,單擊【修改】按鈕可以對進貨信息進行修改,單擊【保存】按鈕后可以將修改后的內容進行保存,單擊【刪除】按鈕,可以刪除選擇的進貨信息,對應的實現代碼如下:
??????? private void toolSave_Click(object sender, EventArgs e)
??????? {
??????????? if (getIntCount() == 1)
??????????? {
??????????????? if (intFalg == 1)
??????????????? {
??????????????????? if (jhMenthod.tb_JhGoodsInfoMenthodAdd(jhGood)==2)
??????????????????? {
??????????????????????? MessageBox.Show("添加成功","提示");
??????????????????????? intFalg = 0;
??????????????????????? jhMenthod.tb_JhGoodsInfoFind("",5,dataGridView1);
??????????????????????? ControlStatus();
??????????????????????? ClearContorl();
??????????????????? }
??????????????????? else
????????? ??????????{
??????????????????????? MessageBox.Show("添加失敗", "提示");
??????????????????????? intFalg = 0;
??????????????????????? jhMenthod.tb_JhGoodsInfoFind("", 5, dataGridView1);
??????????????????????? ControlStatus();
??????????????????????? ClearContorl();
??????????????????? }
??????????????? }
??????????????? if (intFalg == 2)
??????????????? {
??????????????????? if (jhMenthod.tb_JhGoodsInfoMenthodUpdate(jhGood)==1)
??????????????????? {
??????????????????????? MessageBox.Show("修改成功", "提示");
??????? ????????????????intFalg = 0;
??????????????????????? jhMenthod.tb_JhGoodsInfoFind("", 5, dataGridView1);
??????????????????????? ControlStatus();
??????????????????????? ClearContorl();
??????????????????? }
??????????????????? else
??????????????????? {
??????????????????????? MessageBox.Show("修改失敗", "提示");
??????????????????????? intFalg = 0;
??????????????????????? jhMenthod.tb_JhGoodsInfoFind("", 5, dataGridView1);
??????????????????????? ControlStatus();
??????????????????????? ClearContorl();
??????? ????????????}
??????????????? }
??????????????? if (intFalg == 3)
??????????????? {
??????????????????? if (jhMenthod.tb_JhGoodsInfoMenthodDelete(jhGood)==1)
??????????????????? {
??????????????????????? MessageBox.Show("刪除成功", "提示");
???????????????????? ???intFalg = 0;
??????????????????????? jhMenthod.tb_JhGoodsInfoFind("", 5, dataGridView1);
??????????????????????? ControlStatus();
??????????????????????? ClearContorl();
??????????????????? }
??????????????????? else
??????????????????? {
????????????? ??????????MessageBox.Show("刪除失敗", "提示");
??????????????????????? intFalg = 0;
??????????????????????? jhMenthod.tb_JhGoodsInfoFind("", 5, dataGridView1);
??????????????????????? ControlStatus();
??????????????????????? ClearContorl();
??????????????????? }
??????????????? }
??????????? }
??????? }
3.4DataGirdView控件中的某些信息后,對應的各項信息會在對應的文本框中顯示,對應的實現代碼如下:
??????? private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
??????? {
??????????? if (intFalg == 2 || intFalg == 3)
??????????? {
??????????????? FillControls();
??????????? }
??????? }
??????? private void txtGoodsJhPrice_TextChanged(object sender, EventArgs e)
??????? {
?????????? if (txtGoodsNum.Text != "")
??????????? {
??????????????? txtGoodsNeedPrice.Text = Convert.ToString(Convert.ToInt32(txtGoodsJhPrice.Text)*Convert.ToInt32(txtGoodsNum.Text));
??????????? }
??????? }
??????? private void txtGoodsSellPrice_KeyPress(object sender, KeyPressEventArgs e)
??????? {
??????????? if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar)&&e.KeyChar!='.')
??????????? {
??????????????? MessageBox.Show("請輸入數字");
??????????????? e.Handled = true;
??????????? }
??????? }
??????? private void txtGoodsNum_KeyPress(object sender, KeyPressEventArgs e)
??????? {
??????????? if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar))
??????????? {
??????????????? MessageBox.Show("請輸入數字");
??????????????? e.Handled = true;
??????????? }
??????? }
??????? private void txtGoodsJhPrice_KeyPress(object sender, KeyPressEventArgs e)
??????? {
??????????? if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != '.')
??????????? {
??????????????? MessageBox.Show("請輸入數字");
??????????????? e.Handled = true;
??????????? }
??????? }
?
??????? private void txtGoodsNoPrice_KeyPress(object sender, KeyPressEventArgs e)
??????? {
??????????? if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != '.')
??????????? {
??????????????? MessageBox.Show("請輸入數字");
??????????????? e.Handled = true;
??????????? }
??????? }
??????? private void button1_Click(object sender, EventArgs e)
??????? {
??????????? frmGonYingShang frmgong = new frmGonYingShang();
??????????? frmgong.Owner = this;
??????????? frmgong.ShowDialog();
??????? }
??????? private void tollDelete_Click(object sender, EventArgs e)
??????? {
??????????? ControlStatus();
??????????? ClearContorl();
??????????? intFalg = 3;
??????? }
}
}
【商品查詢窗體】
private void button1_Click(object sender, EventArgs e)
??????? {
??????????????????? if(comboBox1.Text=="")
??????????????????? {
??????????????????????? MessageBox.Show("請選擇查詢條件!");
??????????????????????? return;
??????????????????? }
??????????????????? if(comboBox1.Text!=""&&comboBox1.Text!="查詢所有信息"&& textBox1.Text=="")
??????????????????? {
??????????????????????? MessageBox.Show("請輸入查查信息");
??????????????????????? return;
? ??????????????????}
??????????????????? switch (comboBox1.Text)
??????????????????? {
??????????????????????? case "商品編號"://"商品編號":
??????????????????????????? jhMenthod.tb_JhGoodsInfoFind(textBox1.Text,1,dataGridView1);
??????????????????????????? comboBox1.SelectedIndex = 0;
??????????????????????????? break;
??????????????????????? case "商品名稱"://商品名稱"
??????????????????????????? jhMenthod.tb_JhGoodsInfoFind(textBox1.Text, 2, dataGridView1);
??????????????????????????? comboBox1.SelectedIndex = 0;
?????? ?????????????????????break;
??????????????????????? case "查詢所有信息"://"所有信息":
??????????????????????????? jhMenthod.tb_JhGoodsInfoFind(textBox1.Text, 5, dataGridView1);
??????????????????????????? comboBox1.SelectedIndex = 0;
??????????????????????????? break;
??????????????????? }
}
總結
- 上一篇: linux 共享库目录,Linux共享库
- 下一篇: mysql 连接 iOS_iOS连接my