private void RunDeleteData() { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsCustomerConfig CCC = new Configuration.ClsCustomerConfig(); CCC.CustomerID = txtCustomerID.Text; CCC.CNAME = txtCNAME.Text; SIS.DBClass.DBClassCustomerInfo DBCCI = new DBClass.DBClassCustomerInfo(); if (MyDb.AuthPK(CCC.CustomerID, "CustomerID", "CustomerInfo") == true) { if (DBCCI.DeleteOneData(CCC.CustomerID)) { MessageBox.Show("刪除[" + CCC.CustomerID + "-" + CCC.CNAME + "]客戶資料成功", "刪除客戶資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("刪除[" + CCC.CustomerID + "-" + CCC.CNAME + "]客戶資料失敗", "刪除客戶資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在[ " + CCC.CustomerID + "-" + CCC.CNAME + " ]客戶資料!!(資料重複)", "資料刪除"); } }
private void RunUpdateData() { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsCustomerConfig CCC = new Configuration.ClsCustomerConfig(); CCC.CustomerID = txtCustomerID.Text; CCC.CNAME = txtCNAME.Text; CCC.ENAME = txtENAME.Text; CCC.Photos = My.MyMethod.ImageToByte(PicPhotos.Image); CCC.Birthday = dtpBirthday.Value.ToString("yyyy年MM月dd日"); CCC.CustomerType = cboCustomerType.Text; CCC.Phone = mtbPhone.Text; CCC.MobilePhone = mtbMobilePhone.Text; CCC.Fax = mtbFax.Text; CCC.Address = txtAddress.Text; CCC.Notes = rtbNotes.Text; SIS.DBClass.DBClassCustomerInfo DBCCI = new DBClass.DBClassCustomerInfo(); if (MyDb.AuthPK(CCC.CustomerID, "CustomerID", "CustomerInfo") == true) { if (DBCCI.ParameterUpdateData(CCC)) { MessageBox.Show("更新[" + CCC.CustomerID + "-" + CCC.CNAME + "]客戶資料成功", "更新客戶資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("更新[" + CCC.CustomerID + "-" + CCC.CNAME + "]客戶資料失敗", "更新客戶資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在[ " + CCC.CustomerID + "-" + CCC.CNAME + " ]客戶資料!!(資料不存在)", "資料更新"); } }
/// <summary> /// 將資料寫入資料庫中 /// </summary> private void RunInsertData() { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsCustomerConfig CCC = new Configuration.ClsCustomerConfig(); CCC.CustomerID = txtCustomerID.Text; CCC.CNAME = txtCNAME.Text; CCC.ENAME = txtENAME.Text; string FilePath = Application.StartupPath + "\\Photos\\Customer\\" + "NoPicture.bmp"; CCC.Photos = My.MyFileIO.FileToByteArray(FilePath); CCC.Birthday = dtpBirthday.Value.ToString("yyyy年MM月dd日"); CCC.CustomerType = cboCustomerType.Text; CCC.Phone = mtbPhone.Text; CCC.MobilePhone = mtbMobilePhone.Text; CCC.Fax = mtbFax.Text; CCC.Address = txtAddress.Text; CCC.Notes = rtbNotes.Text; SIS.DBClass.DBClassCustomerInfo DBCCI = new DBClass.DBClassCustomerInfo(); if (MyDb.AuthPK(CCC.CustomerID, "CustomerID", "CustomerInfo") == false) { if (DBCCI.ParameterInsertData(CCC)) { MessageBox.Show("新增[" + CCC.CustomerID + "-" + CCC.CNAME + "]客戶資料成功", "新增客戶資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("新增[" + CCC.CustomerID + "-" + CCC.CNAME + "]客戶資料失敗", "新增客戶資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫已存在[ " + CCC.CustomerID + "-" + CCC.CNAME + " ]客戶資料!!(資料重複)", "資料新增"); } }
/// <summary> /// 更新資料庫內的圖片二進位資料 /// </summary> /// <remarks></remarks> public void UpdateImageIntoDB(string photoFilePath) { ArrayList arrList = new ArrayList(); arrList.Clear(); string FilePath = photoFilePath; string CustomerID = this.txtCustomerID.Text; //將圖片檔案轉換成二進位資料 byte[] Photos = My.MyFileIO.FileToByteArray(FilePath); arrList.Insert(0, CustomerID); //職員編號 arrList.Insert(1, Photos); //相片 SIS.DBClass.DBClassCustomerInfo DBCCustomerInfo = new DBClass.DBClassCustomerInfo(); My.MyDatabase myDB = new My.MyDatabase(); if (myDB.AuthPK(CustomerID, "CustomerID", "CustomerInfo") == true) { if (DBCCustomerInfo.ParameterUpdateData(arrList)) { MessageBox.Show("更新" + CustomerID + "- 圖片資料成功", "更新客戶資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("更新" + CustomerID + "-圖片資料失敗", "更新客戶資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在 " + CustomerID + "-客戶資料!!", "圖片資料無法更新"); return; } }