private void RunDeleteData() { try { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsReversalConfig CRC = new Configuration.ClsReversalConfig(); CRC.ReversalID = txtReversalID.Text; SIS.DBClass.DBClassReversal DBCR = new DBClass.DBClassReversal(); if (MyDb.AuthPK(CRC.ReversalID, "ReversalID", "Reversal") == true) { if (DBCR.DeleteOneData(CRC.ReversalID)) { MessageBox.Show("刪除[" + CRC.ReversalID + "]沖銷單資料成功", "刪除沖銷單資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("刪除[" + CRC.ReversalID + "]沖銷單資料失敗", "刪除沖銷單資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在[ " + CRC.ReversalID + " ]沖銷單資料!!(資料不存在)", "資料刪除"); } } catch (Exception ex) { MessageBox.Show("錯誤訊息:" + ex.Message.ToString(), "發生例外"); } }
/// <summary> /// 刪除資料庫的某一筆資料 /// </summary> private void RunDeleteData() { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsManufacturerConfig CMC = new Configuration.ClsManufacturerConfig(); CMC.ManufacturerID = txtManufacturerID.Text; CMC.CNAME = txtCNAME.Text; CMC.ENAME = txtENAME.Text; CMC.UnifiedBusinessNo = mtbUnifiedBusinessNo.Text; SIS.DBClass.DBClassManufacturerInfo DBCMI = new DBClass.DBClassManufacturerInfo(); if (MyDb.AuthPK(CMC.ManufacturerID, "ManufacturerID", "ManufacturerInfo") == true) { if (DBCMI.DeleteOneData(CMC.ManufacturerID)) { MessageBox.Show("刪除[" + CMC.ManufacturerID + "-" + CMC.CNAME + "]公司資料成功", "刪除廠商資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("刪除[" + CMC.ManufacturerID + "-" + CMC.CNAME + "]公司資料失敗", "刪除廠商資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在[ " + CMC.ManufacturerID + "-" + CMC.CNAME + " ]廠商資料!!(資料不存在)", "資料刪除"); } }
private void RunDeleteData() { try { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsPurchaseConfig CPC = new Configuration.ClsPurchaseConfig(); CPC.PurchaseID = txtPurchaseID.Text; SIS.DBClass.DBClassPurchaseMaster DBCPM = new DBClass.DBClassPurchaseMaster(); if (MyDb.AuthPK(CPC.PurchaseID, "PurchaseID", "PurchaseMaster") == true) { if (DBCPM.DeleteMasterDetailsData(CPC.PurchaseID)) { MessageBox.Show("刪除[" + CPC.PurchaseID + "]採購單資料成功", "刪除採購單資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("刪除[" + CPC.PurchaseID + "]採購單資料失敗", "刪除採購單資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在[ " + CPC.PurchaseID + " ]採購單資料!!(資料不存在)", "資料刪除"); } } catch (Exception ex) { MessageBox.Show("錯誤訊息:" + ex.Message.ToString(), "發生例外"); } }
private void RunDeleteData() { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsItemsConfig CIC = new Configuration.ClsItemsConfig(); CIC.ItemsID = txtItemsID.Text; CIC.NAME = txtNAME.Text; SIS.DBClass.DBClassItemsInfo DBCII = new DBClass.DBClassItemsInfo(); if (MyDb.AuthPK(CIC.ItemsID, "ItemsID", "ItemsInfo") == true) { if (DBCII.DeleteOneData(CIC.ItemsID)) { MessageBox.Show("刪除[" + CIC.ItemsID + "-" + CIC.NAME + "]商品資料成功", "刪除商品資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("刪除[" + CIC.ItemsID + "-" + CIC.NAME + "]商品資料失敗", "刪除商品資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在[ " + CIC.ItemsID + "-" + CIC.NAME + " ]商品資料!!(資料不存在)", "資料刪除"); } }
private void RunDeleteData(SIS.Configuration.Items[] OldItems) { try { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsShipConfig CSC = new Configuration.ClsShipConfig(); CSC.ShipID = txtShipID.Text; SIS.DBClass.DBClassShipMaster DBCSM = new DBClass.DBClassShipMaster(); if (MyDb.AuthPK(CSC.ShipID, "ShipID", "ShipMaster") == true) { if (DBCSM.DeleteMasterDetailsData(CSC.ShipID, OldItems)) { MessageBox.Show("刪除[" + CSC.ShipID + "]出貨單資料成功", "刪除出貨單資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("刪除[" + CSC.ShipID + "]出貨單資料失敗", "刪除出貨單資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在[ " + CSC.ShipID + " ]出貨單資料!!(資料不存在)", "資料刪除"); } } catch (Exception ex) { MessageBox.Show("錯誤訊息:" + ex.Message.ToString(), "發生例外"); } }
private void RunDeleteData() { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsEmployeeConfig CEC = new Configuration.ClsEmployeeConfig(); CEC.EmployeeID = txtEmployeeID.Text; CEC.CNAME = txtCNAME.Text; SIS.DBClass.DBClassEmployeeInfo DBCEI = new DBClass.DBClassEmployeeInfo(); if (MyDb.AuthPK(CEC.EmployeeID, "EmployeeID", "EmployeeInfo") == true) { if (DBCEI.DeleteOneData(CEC.EmployeeID)) { MessageBox.Show("刪除[" + CEC.EmployeeID + "-" + CEC.CNAME + "]職員資料成功", "刪除職員資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("刪除[" + CEC.EmployeeID + "-" + CEC.CNAME + "]職員資料失敗", "刪除職員資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在[ " + CEC.EmployeeID + "-" + CEC.CNAME + " ]職員資料!!(資料重複)", "資料刪除"); } }
/// <summary> /// 將TreeView權限內容寫入資料庫中 /// </summary> /// <param name="TNs">傳入節點集合例如:TreeView1.Nodes</param> private void TreeViewNodesAuthorityToDB(TreeNodeCollection TNs) { SIS.DBClass.DBClsSysUserAuthority DbSUA = new SIS.DBClass.DBClsSysUserAuthority(); My.MyDatabase MyDb = new My.MyDatabase(); if (TNs.Count != 0) { foreach (TreeNode TN in TNs) { if (MyDb.AuthPK(tSSL_UserId.Text, "UserId", TN.Tag.ToString(), "FuncId", "SysUserAuthority")) { DbSUA.UpdateAuthStatus(tSSL_UserId.Text, TN.Tag.ToString(), TN.Checked); } else { DbSUA.InsertData(tSSL_UserId.Text, TN.Tag.ToString(), TN.Checked); } if (TN.Nodes.Count > 0) { TreeViewNodesAuthorityToDB(TN.Nodes); } } } }
private void RunUpdateData() { try { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsReversalConfig CRC = new Configuration.ClsReversalConfig(); CRC.ReversalID = txtReversalID.Text; CRC.ReversalDate = dtpReversalDate.Value.ToString("yyyy年MM月dd日"); CRC.ReversalStaff = cboReversalStaff.Text; if (rdoReversalShip.Checked == true) { CRC.ReversalType = "Customer"; } else { CRC.ReversalType = "Manufacturer"; } CRC.CustomerOrManufacturer = txtCustomerOrManufacturer.Text; CRC.StockIDOrShipID = txtStockIDOrShipID.Text; CRC.PaymentAmount = int.Parse(txtPaymentAmount.Text); CRC.ReversalAmount = int.Parse(mtbReversalAmount.Text); CRC.IsReversal = cbxIsReversal.Checked; CRC.PaymentType = cboPaymentType.Text.Split('-')[1]; CRC.Notes = rtbNotes.Text.Replace("'", "''"); SIS.DBClass.DBClassReversal DBCR = new DBClass.DBClassReversal(); if (MyDb.AuthPK(CRC.ReversalID, "ReversalID", "Reversal") == true) { if (DBCR.Update(CRC)) { MessageBox.Show("更新[" + CRC.ReversalID + "]沖銷單資料成功", "更新沖銷單資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("更新[" + CRC.ReversalID + "]沖銷單資料失敗", "更新沖銷單資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在[ " + CRC.ReversalID + " ]沖銷單資料!!(資料不存在)", "資料更新"); } } catch (Exception ex) { MessageBox.Show("錯誤訊息:" + ex.Message.ToString(), "發生例外"); } }
/// <summary> /// 將資料寫入資料庫中 /// </summary> private void RunInsertData() { try { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsPurchaseConfig CPC = new Configuration.ClsPurchaseConfig(); CPC.PurchaseID = txtPurchaseID.Text; CPC.PurchaseDate = dtpPurchaseDate.Value.ToString("yyyy年MM月dd日"); CPC.DeliveryDate = dtpDeliveryDate.Value.ToString("yyyy年MM月dd日"); CPC.ManufacturerID = cboManufacturer.Text.Substring(0, cboManufacturer.Text.IndexOf("-")); CPC.PurchaseStaff = cboPurchaseStaff.Text; CPC.PurchasePhone = mtbPurchasePhone.Text; CPC.DeliveryAddress = cboDeliveryAddress.Text; CPC.PaymentType = cboPaymentType.Text.Split('-')[1]; CPC.BusinessTaxStockTaxRate = int.Parse(txtBusinessTaxStockTaxRate.Text); CPC.TotalPreTax = int.Parse(txtTotalPreTax.Text); CPC.Tax = int.Parse(txtTax.Text); CPC.TotalAfterTax = int.Parse(txtTotalAfterTax.Text); CPC.Notes = rtbNotes.Text.Replace("'", "''"); CPC.PurchaseItems = getItemsValueFromDataGridView(dgvPurchaseDetails); //SIS.DBClass.DBClassPurchaseMaster DBCPM = new DBClass.DBClassPurchaseMaster(); //實作工廠模式(Factory Pattern) var Processor = SIS.Configuration.SISProcessorFactory.getInstance(SIS.Configuration.SISOperating.Purchase); if (MyDb.AuthPK(CPC.PurchaseID, "PurchaseID", "PurchaseMaster") == false) { if (Processor.Insert(CPC)) //DBCPM.InsertData(CPC) { MessageBox.Show("新增[" + CPC.PurchaseID + "]採購單資料成功", "新增採購單資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("新增[" + CPC.PurchaseID + "]採購單資料失敗", "新增採購單資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫已存在[ " + CPC.PurchaseID + " ]採購單資料!!(資料重複)", "資料新增"); } } catch (Exception ex) { MessageBox.Show("錯誤訊息:" + ex.Message.ToString(), "發生例外"); } }
/// <summary> /// 更新資料庫中的相關資料 /// </summary> private void RunUpdateData(SIS.Configuration.Items[] OldItems) { try { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsRMAConfig CRC = new Configuration.ClsRMAConfig(); CRC.RMAID = txtRMAID.Text; CRC.RMADate = dtpRMADate.Value.ToString("yyyy年MM月dd日"); CRC.RMAType = RMAType; CRC.TotalPreTax = int.Parse(txtTotalPreTax.Text); CRC.Tax = int.Parse(txtTax.Text); CRC.TotalAfterTax = int.Parse(txtTotalAfterTax.Text); CRC.StockIDOrShipID = txtStockIDOrShipID.Text; CRC.BusinessTax = int.Parse(txtBusinessTax.Text); CRC.AmountPaid = int.Parse(mtbAmountPaid.Text); CRC.UnpaidAmount = int.Parse(txtUnpaidAmount.Text); CRC.RMAAmount = int.Parse(mtbRMAAmount.Text); CRC.Staff = cboStaff.Text; CRC.PaymentType = cboPaymentType.Text.Split('-')[1]; CRC.Notes = rtbNotes.Text.Replace("'", "''"); CRC.RMAItems = getItemsValueFromDataGridView(dgvRMADetails); SIS.DBClass.DBClassRMAMaster DBCRM = new DBClass.DBClassRMAMaster(); if (MyDb.AuthPK(CRC.RMAID, "RMAID", "RMAMaster") == true) { if (DBCRM.Update(CRC, OldItems)) { MessageBox.Show("更新[" + CRC.RMAID + "]退貨單資料成功", "更新退貨單資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("更新[" + CRC.RMAID + "]退貨單資料失敗", "更新退貨單資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在[ " + CRC.RMAID + " ]退貨單資料!!(資料不存在)", "資料更新"); } } catch (Exception ex) { MessageBox.Show("錯誤訊息:" + ex.Message.ToString(), "發生例外"); } }
/// <summary> /// 加入事件資料於資料庫中 /// </summary> /// <param name="UserId">使用者編號</param> /// <param name="EventType">事件類型,包含:資訊,錯誤,警告,危險等四種</param> /// <param name="Action">對系統所執行動作</param> /// <param name="Details">動作詳細描述</param> public bool AddEventData(string UserId, string EventType, string Actions, string Details) { ArrayList arrList = new ArrayList(); string EventId; //事件編號 string EventTime; //事件觸發時間 bool IsInsertOK = false; //用來存放bool值,作為判斷新增資料是否成功 EventId = My.MyMethod.RunID("EV"); EventTime = DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss"); arrList.Clear(); arrList.Insert(0, EventId); arrList.Insert(1, EventTime); arrList.Insert(2, EventType); arrList.Insert(3, UserId); arrList.Insert(4, Actions); arrList.Insert(5, Details); My.MyDatabase MyDB = new My.MyDatabase(); //檢查要插入的資料其主鍵值(Primary Key)是否有重複,若有重複則會回傳True if (MyDB.AuthPK(EventId, "EventId", "WinApEvents")) { //MessageBox.Show("資料已經存在,請重新送出填寫表單!!", "主鍵值驗證失敗"); return(false); } else { IsInsertOK = InsertData(arrList); //呼叫InsertData方法來進行資料新增動作 if (IsInsertOK) { //MessageBox.Show("資料新增成功!!", "資料新增"); return(true); } else { //MessageBox.Show("資料新增失敗!!", "資料新增"); return(false); } } }
private void RunUpdateData(SIS.Configuration.Items[] OldItems) { try { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsShipConfig CSC = new Configuration.ClsShipConfig(); CSC.ShipID = txtShipID.Text; CSC.ShipDate = dtpShipDate.Value.ToString("yyyy年MM月dd日"); CSC.TotalPreTax = int.Parse(txtTotalPreTax.Text); CSC.Tax = int.Parse(txtTax.Text); CSC.TotalAfterTax = int.Parse(txtTotalAfterTax.Text); CSC.CustomerID = cboCustomer.Text.Substring(0, cboCustomer.Text.IndexOf("-")); CSC.BusinessTaxShipTaxRate = int.Parse(txtBusinessTaxShipTaxRate.Text); CSC.AmountPaid = int.Parse(mtbAmountPaid.Text); CSC.UnpaidAmount = int.Parse(txtUnpaidAmount.Text); CSC.ShipStaff = cboShipStaff.Text; CSC.PaymentType = cboPaymentType.Text.Split('-')[1]; CSC.Notes = rtbNotes.Text.Replace("'", "''"); CSC.ShipItems = getItemsValueFromDataGridView(dgvShipDetails); SIS.DBClass.DBClassShipMaster DBCSM = new DBClass.DBClassShipMaster(); if (MyDb.AuthPK(CSC.ShipID, "ShipID", "ShipMaster") == true) { if (DBCSM.Update(CSC, OldItems)) { MessageBox.Show("更新[" + CSC.ShipID + "]出貨單資料成功", "更新出貨單資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("更新[" + CSC.ShipID + "]出貨單資料失敗", "更新出貨單資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在[ " + CSC.ShipID + " ]出貨單資料!!(資料不存在)", "資料更新"); } } catch (Exception ex) { MessageBox.Show("錯誤訊息:" + ex.Message.ToString(), "發生例外"); } }
/// <summary> /// 將資料寫入資料庫中 /// </summary> private void RunInsertData() { try { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsStockConfig CSC = new Configuration.ClsStockConfig(); CSC.StockID = txtStockID.Text; CSC.StockDate = dtpStockDate.Value.ToString("yyyy年MM月dd日"); CSC.TotalPreTax = int.Parse(txtTotalPreTax.Text); CSC.Tax = int.Parse(txtTax.Text); CSC.TotalAfterTax = int.Parse(txtTotalAfterTax.Text); CSC.ManufacturerID = cboManufacturer.Text.Substring(0, cboManufacturer.Text.IndexOf("-")); CSC.BusinessTaxStockTaxRate = int.Parse(txtBusinessTaxStockTaxRate.Text); CSC.AmountPaid = int.Parse(mtbAmountPaid.Text); CSC.UnpaidAmount = int.Parse(txtUnpaidAmount.Text); CSC.StockStaff = cboStockStaff.Text; CSC.PaymentType = cboPaymentType.Text.Split('-')[1]; CSC.Notes = rtbNotes.Text.Replace("'", "''"); CSC.StockItems = getItemsValueFromDataGridView(dgvStockDetails); SIS.DBClass.DBClassStockMaster DBCSM = new DBClass.DBClassStockMaster(); if (MyDb.AuthPK(CSC.StockID, "StockID", "StockMaster") == false) { if (DBCSM.InsertData(CSC)) { MessageBox.Show("新增[" + CSC.StockID + "]進貨單資料成功", "新增進貨單資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("新增[" + CSC.StockID + "]進貨單資料失敗", "新增進貨單資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫已存在[ " + CSC.StockID + " ]進貨單資料!!(資料重複)", "資料新增"); } } catch (Exception ex) { MessageBox.Show("錯誤訊息:" + ex.Message.ToString(), "發生例外"); } }
/// <summary> /// 將資料寫入資料庫中 /// </summary> private void RunInsertData() { try { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsItemsConfig CIC = new Configuration.ClsItemsConfig(); CIC.ItemsID = txtItemsID.Text; CIC.NAME = txtNAME.Text; CIC.ItemsType = cboItemsType.Text.Substring(0, cboItemsType.Text.IndexOf("-")); CIC.Specifications = txtSpecifications.Text.Replace("'", "''"); //將一個單引號置換成二個單引號避免SQL語法錯誤 CIC.ItemsUnit = cboItemsUnit.Text; CIC.SellingPrice = int.Parse(mtbSellingPrice.Text); CIC.CostPrice = int.Parse(mtbCostPrice.Text); CIC.MSRP = int.Parse(mtbMSRP.Text); CIC.ManufacturerID = cboManufacturer.Text.Substring(0, cboManufacturer.Text.IndexOf("-")); CIC.Inventory = int.Parse(mtbInventory.Text); CIC.SafeInventory = int.Parse(mtbSafeInventory.Text); CIC.Notes = rtbNotes.Text.Replace("'", "''"); SIS.DBClass.DBClassItemsInfo DBCII = new DBClass.DBClassItemsInfo(); if (MyDb.AuthPK(CIC.ItemsID, "ItemsID", "ItemsInfo") == false) { if (DBCII.InsertData(CIC)) { MessageBox.Show("新增[" + CIC.ItemsID + "-" + CIC.NAME + "]商品資料成功", "新增商品資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("新增[" + CIC.ItemsID + "-" + CIC.NAME + "]商品資料失敗", "新增商品資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫已存在[ " + CIC.ItemsID + "-" + CIC.NAME + " ]商品資料!!(資料重複)", "資料新增"); } } catch (Exception ex) { MessageBox.Show("錯誤訊息:" + ex.Message.ToString(), "發生例外"); } }
/// <summary> /// 將資料寫入資料庫中 /// </summary> private void RunInsertData() { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsEmployeeConfig CEC = new Configuration.ClsEmployeeConfig(); CEC.EmployeeID = txtEmployeeID.Text; CEC.CNAME = txtCNAME.Text; CEC.ENAME = txtENAME.Text; string FilePath = Application.StartupPath + "\\Photos\\Employee\\" + "NoPicture.bmp"; CEC.Photos = My.MyFileIO.FileToByteArray(FilePath); CEC.Sex = cboSex.Text; CEC.Birthday = dtpBirthday.Value.ToString("yyyy年MM月dd日"); CEC.BooldType = cboBooldType.Text; CEC.ID = mtbID.Text; CEC.PresentAddress = txtPresentAddress.Text; CEC.Professional = txtProfessional.Text; CEC.HireDate = dtpHireDate.Value.ToString("yyyy年MM月dd日"); CEC.Positions = txtPosition.Text; CEC.Background = txtBackground.Text; CEC.Phone = mtbPhone.Text; CEC.Status = cboStatus.Text; SIS.DBClass.DBClassEmployeeInfo DBCEI = new DBClass.DBClassEmployeeInfo(); if (MyDb.AuthPK(CEC.EmployeeID, "EmployeeID", "EmployeeInfo") == false) { if (DBCEI.ParameterInsertData(CEC)) { MessageBox.Show("新增[" + CEC.EmployeeID + "-" + CEC.CNAME + "]職員資料成功", "新增職員資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("新增[" + CEC.EmployeeID + "-" + CEC.CNAME + "]職員資料失敗", "新增職員資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫已存在[ " + CEC.EmployeeID + "-" + CEC.CNAME + " ]職員資料!!(資料重複)", "資料新增"); } }
private void RunUpdateData() { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsEmployeeConfig CEC = new Configuration.ClsEmployeeConfig(); CEC.EmployeeID = txtEmployeeID.Text; CEC.CNAME = txtCNAME.Text; CEC.ENAME = txtENAME.Text; CEC.Photos = My.MyMethod.ImageToByte(PicPhotos.Image); CEC.Sex = cboSex.Text; CEC.Birthday = dtpBirthday.Value.ToString("yyyy年MM月dd日"); CEC.BooldType = cboBooldType.Text; CEC.ID = mtbID.Text; CEC.PresentAddress = txtPresentAddress.Text; CEC.Professional = txtProfessional.Text; CEC.HireDate = dtpHireDate.Value.ToString("yyyy年MM月dd日"); CEC.Positions = txtPosition.Text; CEC.Background = txtBackground.Text; CEC.Phone = mtbPhone.Text; CEC.Status = cboStatus.Text; SIS.DBClass.DBClassEmployeeInfo DBCEI = new DBClass.DBClassEmployeeInfo(); if (MyDb.AuthPK(CEC.EmployeeID, "EmployeeID", "EmployeeInfo") == true) { if (DBCEI.ParameterUpdateData(CEC)) { MessageBox.Show("更新[" + CEC.EmployeeID + "-" + CEC.CNAME + "]職員資料成功", "更新職員資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("更新[" + CEC.EmployeeID + "-" + CEC.CNAME + "]職員資料失敗", "更新職員資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在[ " + CEC.EmployeeID + "-" + CEC.CNAME + " ]職員資料!!(資料不存在)", "資料更新"); } }
private void RunUpdateData() { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsCompanyConfig CCC = new Configuration.ClsCompanyConfig(); CCC.CompanyID = txtCompanyID.Text; CCC.CNAME = txtCNAME.Text; CCC.ENAME = txtENAME.Text; CCC.UnifiedBusinessNo = mtbUnifiedBusinessNo.Text; CCC.CompanyType = cboCompanyType.Text; CCC.Owner = txtOwner.Text; CCC.Contact = txtContact.Text; CCC.Phone = mtbPhone.Text; CCC.MobilePhone = mtbMobilePhone.Text; CCC.Fax = mtbFax.Text; CCC.Address = txtAddress.Text; CCC.WebSite = txtWebSite.Text; CCC.Notes = rtbNotes.Text; SIS.DBClass.DBClassCompanyInfo DBCCI = new DBClass.DBClassCompanyInfo(); if (MyDb.AuthPK(CCC.CompanyID, "CompanyID", "CompanyInfo") == true) { if (DBCCI.Update(CCC)) { MessageBox.Show("更新[" + CCC.CompanyID + "-" + CCC.CNAME + "]公司資料成功", "更新公司資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("更新[" + CCC.CompanyID + "-" + CCC.CNAME + "]公司資料失敗", "更新公司資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在[ " + CCC.CompanyID + "-" + 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 + " ]客戶資料!!(資料重複)", "資料新增"); } }
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 + " ]客戶資料!!(資料不存在)", "資料更新"); } }
private void RunUpdateData() { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsItemsConfig CIC = new Configuration.ClsItemsConfig(); CIC.ItemsID = txtItemsID.Text; CIC.NAME = txtNAME.Text; CIC.ItemsType = cboItemsType.Text.Substring(0, cboItemsType.Text.IndexOf("-")); CIC.Specifications = txtSpecifications.Text.Replace("'", "''"); CIC.ItemsUnit = cboItemsUnit.Text; CIC.SellingPrice = int.Parse(mtbSellingPrice.Text); CIC.CostPrice = int.Parse(mtbCostPrice.Text); CIC.MSRP = int.Parse(mtbMSRP.Text); CIC.ManufacturerID = cboManufacturer.Text.Substring(0, cboManufacturer.Text.IndexOf("-")); CIC.Inventory = int.Parse(mtbInventory.Text); CIC.SafeInventory = int.Parse(mtbSafeInventory.Text); CIC.Notes = rtbNotes.Text.Replace("'", "''"); SIS.DBClass.DBClassItemsInfo DBCII = new DBClass.DBClassItemsInfo(); if (MyDb.AuthPK(CIC.ItemsID, "ItemsID", "ItemsInfo") == true) { if (DBCII.Update(CIC)) { MessageBox.Show("更新[" + CIC.ItemsID + "-" + CIC.NAME + "]商品資料成功", "更新商品資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("更新[" + CIC.ItemsID + "-" + CIC.NAME + "]商品資料失敗", "更新商品資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在[ " + CIC.ItemsID + "-" + CIC.NAME + " ]商品資料!!(資料不存在)", "資料更新"); } }
/// <summary> /// 將資料寫入資料庫中 /// </summary> private void RunInsertData() { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsManufacturerConfig CMC = new Configuration.ClsManufacturerConfig(); CMC.ManufacturerID = txtManufacturerID.Text; CMC.CNAME = txtCNAME.Text; CMC.ENAME = txtENAME.Text; CMC.UnifiedBusinessNo = mtbUnifiedBusinessNo.Text; CMC.Owner = txtOwner.Text; CMC.Contact = txtContact.Text; CMC.Phone = mtbPhone.Text; CMC.MobilePhone = mtbMobilePhone.Text; CMC.Fax = mtbFax.Text; CMC.Address = txtAddress.Text; CMC.WebSite = txtWebSite.Text; CMC.Notes = rtbNotes.Text; SIS.DBClass.DBClassManufacturerInfo DBCMI = new DBClass.DBClassManufacturerInfo(); if (MyDb.AuthPK(CMC.ManufacturerID, "ManufacturerID", "ManufacturerInfo") == false) { if (DBCMI.InsertData(CMC)) { MessageBox.Show("新增[" + CMC.ManufacturerID + "-" + CMC.CNAME + "]公司資料成功", "新增廠商資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("新增[" + CMC.ManufacturerID + "-" + CMC.CNAME + "]廠商資料失敗", "新增廠商資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫已存在[ " + CMC.ManufacturerID + "-" + CMC.CNAME + " ]廠商資料!!(資料重複)", "資料新增"); } }
private void RunUpdateData() { try { My.MyDatabase MyDb = new My.MyDatabase(); SIS.Configuration.ClsTakeStockConfig CTSC = new Configuration.ClsTakeStockConfig(); CTSC.TakeStockID = txtTakeStockID.Text; CTSC.TakeStockDate = dtpTakeStockDate.Value.ToString("yyyy年MM月dd日"); CTSC.TakeStockStaff = cboTakeStockStaff.Text; CTSC.Notes = rtbNotes.Text.Replace("'", "''"); CTSC.TakeStockItems = getItemsValueFromDataGridView(dgvTakeStockItemsInfo); SIS.DBClass.DBClassTakeStockMaster DBCTSM = new DBClass.DBClassTakeStockMaster(); if (MyDb.AuthPK(CTSC.TakeStockID, "TakeStockID", "TakeStockMaster") == true) { if (DBCTSM.Update(CTSC)) { MessageBox.Show("更新[" + CTSC.TakeStockID + "]盤點單資料成功", "更新盤點單資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("更新[" + CTSC.TakeStockID + "]盤點單資料失敗", "更新盤點單資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在[ " + CTSC.TakeStockID + " ]更新單資料!!(資料不存在)", "資料更新"); } } catch (Exception ex) { MessageBox.Show("錯誤訊息:" + ex.Message.ToString(), "發生例外"); } }
/// <summary> /// 更新資料庫內的圖片二進位資料 /// </summary> /// <remarks></remarks> public void UpdateImageIntoDB(string photoFilePath) { ArrayList arrList = new ArrayList(); arrList.Clear(); string FilePath = photoFilePath; string EmployeeID = this.txtEmployeeID.Text; //將圖片檔案轉換成二進位資料 byte[] Photos = My.MyFileIO.FileToByteArray(FilePath); arrList.Insert(0, EmployeeID); //職員編號 arrList.Insert(1, Photos); //相片 SIS.DBClass.DBClassEmployeeInfo DBCEmployeeInfo = new DBClass.DBClassEmployeeInfo(); My.MyDatabase myDB = new My.MyDatabase(); if (myDB.AuthPK(EmployeeID, "EmployeeID", "EmployeeInfo") == true) { if (DBCEmployeeInfo.ParameterUpdateData(arrList)) { MessageBox.Show("更新" + EmployeeID + "- 圖片資料成功", "更新職員資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue(); } else { MessageBox.Show("更新" + EmployeeID + "-圖片資料失敗", "更新職員資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在 " + EmployeeID + "-職員資料!!", "圖片資料無法更新"); return; } }
/// <summary> /// 將資料寫入資料庫中 /// </summary> private void RunInsertData(string PageName) { ArrayList arrList = new ArrayList(); My.MyDatabase MyDb = new My.MyDatabase(); switch (PageName) { case "tabPage1": //一般使用者 SIS.DBClass.DBClassUserInfo DbUI = new SIS.DBClass.DBClassUserInfo(); string UserId = this.txtUserId.Text; string CNAME = this.txtCNAME.Text; string ENAME = this.txtENAME.Text; string Sex = this.cboSex.Text; string Birthday = this.dtpBirthday.Value.ToString("yyyy年MM月dd日"); string BoolType = this.cboBooldType.Text; string ID = this.mtbID.Text; string PresentAddress = this.txtPresentAddress.Text; string Phone = mtbPhone.Text; arrList.Clear(); arrList.Insert(0, UserId); arrList.Insert(1, CNAME); arrList.Insert(2, ENAME); arrList.Insert(3, Sex); arrList.Insert(4, Birthday); arrList.Insert(5, BoolType); arrList.Insert(6, ID); arrList.Insert(7, PresentAddress); arrList.Insert(8, Phone); if (MyDb.AuthPK(UserId, "UserId", "UserInfo") == false) { if (DbUI.InsertData(arrList)) { MessageBox.Show("新增" + UserId + "-" + CNAME + "一般使用者資料成功", "新增人員資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue1(); if (InsertNewLoginAccount(UserId, "Users")) { MessageBox.Show("帳號:[" + UserId + "]建立成功,預設密碼為[12345],登入系統後請記得變更。", "建立登入系統帳號成功"); } } else { MessageBox.Show("新增" + UserId + "-" + CNAME + "一般使用者資料失敗", "新增人員資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫已存在 " + UserId + "-" + CNAME + " 人員資料!!(資料重複)", "資料新增"); } break; case "tabPage2": //進銷存管理者 SIS.DBClass.DBClassManagementInfo DbMI = new SIS.DBClass.DBClassManagementInfo(); string UserId2 = this.txtUserId2.Text; string CNAME2 = this.txtCNAME2.Text; string ENAME2 = this.txtENAME2.Text; string Sex2 = this.cboSex2.Text; string Birthday2 = this.dtpBirthday2.Value.ToString("yyyy年MM月dd日"); string BoolType2 = this.cboBooldType2.Text; string ID2 = this.mtbID2.Text; string PresentAddress2 = this.txtPresentAddress2.Text; string Phone2 = mtbPhone2.Text; string Title = cboTitle.Text; arrList.Clear(); arrList.Insert(0, UserId2); arrList.Insert(1, CNAME2); arrList.Insert(2, ENAME2); arrList.Insert(3, Sex2); arrList.Insert(4, Birthday2); arrList.Insert(5, BoolType2); arrList.Insert(6, ID2); arrList.Insert(7, PresentAddress2); arrList.Insert(8, Phone2); arrList.Insert(9, Title); if (MyDb.AuthPK(UserId2, "UserId", "ManagementInfo") == false) { if (DbMI.InsertData(arrList)) { MessageBox.Show("新增" + UserId2 + "-" + CNAME2 + "進銷存管理者資料成功", "新增人員資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue2(); if (InsertNewLoginAccount(UserId2, "Management")) { MessageBox.Show("帳號:[" + UserId2 + "]建立成功,預設密碼為[12345],登入系統後請記得變更。", "建立登入系統帳號成功"); } } else { MessageBox.Show("新增" + UserId2 + "-" + CNAME2 + "進銷存管理者資料失敗", "新增人員資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫已存在 " + UserId2 + "-" + CNAME2 + " 人員資料!!(資料重複)", "資料新增"); } break; } }
/// <summary> /// 更新資料庫資料 /// </summary> private void RunUpdateData(string PageName) { ArrayList arrList = new ArrayList(); My.MyDatabase MyDb = new My.MyDatabase(); switch (PageName) { case "tabPage1": //一般使用者 SIS.DBClass.DBClassUserInfo DbUI = new SIS.DBClass.DBClassUserInfo(); string UserId = this.txtUserId.Text; string CNAME = this.txtCNAME.Text; string ENAME = this.txtENAME.Text; string Sex = this.cboSex.Text; string Birthday = this.dtpBirthday.Value.ToString("yyyy年MM月dd日"); string BoolType = this.cboBooldType.Text; string ID = this.mtbID.Text; string PresentAddress = this.txtPresentAddress.Text; string Phone = mtbPhone.Text; arrList.Clear(); arrList.Insert(0, UserId); arrList.Insert(1, CNAME); arrList.Insert(2, ENAME); arrList.Insert(3, Sex); arrList.Insert(4, Birthday); arrList.Insert(5, BoolType); arrList.Insert(6, ID); arrList.Insert(7, PresentAddress); arrList.Insert(8, Phone); //資料存在才進行更新動作 if (MyDb.AuthPK(UserId, "UserId", "UserInfo") == true) { if (DbUI.Update(arrList)) { MessageBox.Show("更新" + UserId + "-" + CNAME + "一般使用者資料成功", "更新人員資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue1(); } else { MessageBox.Show("更新" + UserId + "-" + CNAME + "一般使用者資料失敗", "更新人員資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在 " + UserId + "-" + CNAME + " 人員資料!!(無法更新)", "資料更新"); } break; case "tabPage2": //進銷存管理者 SIS.DBClass.DBClassManagementInfo DbMI = new SIS.DBClass.DBClassManagementInfo(); string UserId2 = this.txtUserId2.Text; string CNAME2 = this.txtCNAME2.Text; string ENAME2 = this.txtENAME2.Text; string Sex2 = this.cboSex2.Text; string Birthday2 = this.dtpBirthday2.Value.ToString("yyyy年MM月dd日"); string BoolType2 = this.cboBooldType2.Text; string ID2 = this.mtbID2.Text; string PresentAddress2 = this.txtPresentAddress2.Text; string Phone2 = mtbPhone2.Text; string Title = cboTitle.Text; arrList.Clear(); arrList.Insert(0, UserId2); arrList.Insert(1, CNAME2); arrList.Insert(2, ENAME2); arrList.Insert(3, Sex2); arrList.Insert(4, Birthday2); arrList.Insert(5, BoolType2); arrList.Insert(6, ID2); arrList.Insert(7, PresentAddress2); arrList.Insert(8, Phone2); arrList.Insert(9, Title); if (MyDb.AuthPK(UserId2, "UserId", "ManagementInfo") == true) { if (DbMI.Update(arrList)) { MessageBox.Show("更新" + UserId2 + "-" + CNAME2 + "進銷存管理者資料成功", "更新人員資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue2(); } else { MessageBox.Show("更新" + UserId2 + "-" + CNAME2 + "進銷存管理者資料失敗", "更新人員資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在 " + UserId2 + "-" + CNAME2 + " 人員資料!!(無法更新)", "資料更新"); } break; } }
/// <summary> /// 刪除資料庫資料 /// </summary> private void RunDeleteData(string PageName) { ArrayList arrList = new ArrayList(); My.MyDatabase MyDb = new My.MyDatabase(); switch (PageName) { case "tabPage1": //一般使用者 SIS.DBClass.DBClassUserInfo DbUI = new SIS.DBClass.DBClassUserInfo(); string UserId = this.txtUserId.Text; string CNAME = this.txtCNAME.Text; //資料存在才進行更新動作 if (MyDb.AuthPK(UserId, "UserId", "UserInfo") == true) { if (DbUI.DeleteOneData(UserId)) { MessageBox.Show("刪除" + UserId + "-" + CNAME + "一般使用者資料成功", "刪除人員資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue1(); } else { MessageBox.Show("刪除" + UserId + "-" + CNAME + "一般使用者資料失敗", "刪除人員資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在 " + UserId + "-" + CNAME + " 人員資料!!(無法刪除)", "資料刪除"); } break; case "tabPage2": //進銷存管理者 SIS.DBClass.DBClassManagementInfo DbMI = new SIS.DBClass.DBClassManagementInfo(); string UserId2 = this.txtUserId2.Text; string CNAME2 = this.txtCNAME2.Text; if (MyDb.AuthPK(UserId2, "UserId", "ManagementInfo") == true) { if (DbMI.DeleteOneData(UserId2)) { MessageBox.Show("刪除" + UserId2 + "-" + CNAME2 + "進銷存管理者資料成功", "刪除人員資料", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDefaultValue2(); } else { MessageBox.Show("刪除" + UserId2 + "-" + CNAME2 + "進銷存管理者資料失敗", "刪除人員資料", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("對不起,資料庫不存在 " + UserId2 + "-" + CNAME2 + " 人員資料!!(無法刪除)", "資料刪除"); } break; } }