private void itemInfoAdd() { #region 判斷 string msg = ""; if (string.IsNullOrEmpty(txtAmount.Text)) { msg = "請輸入金額"; } else if (!int.TryParse(txtAmount.Text, out int n)) { msg = "金額欄位請輸入數字"; } else if (string.IsNullOrEmpty(txtName.Text)) { msg = "請選擇商品資訊"; } if (!string.IsNullOrEmpty(msg)) { APConfig.SweetAlert(ShowBoxType.alert, msg); return; } #endregion DataGridViewRowCollection rows = dgvItem.Rows; rows.Add(new Object[] { ddlVendor.SelectedItem.ToString(), txtName.Text, txtType.Text, txtColor.Text, txtSize.Text, txtAmount.Text, dpkImportDTTM.Value.ToShortDateString(), txtComment.Text }); clearPage(); loadTotalAmount(); }
private void btnPhraseDelete_Click(object sender, EventArgs e) { try { if (dgvPhrase.SelectedRows.Count > 0 && APConfig.SweetAlert(ShowBoxType.confirm, string.Format("是否確定要刪除{0}筆?", dgvPhrase.SelectedRows.Count))) { List <string> sernolist = new List <string>(); string delSernoList = ""; foreach (DataGridViewRow row in dgvPhrase.SelectedRows) { sernolist.Add(string.Format("'{0}'", row.Cells["dgvPhrase_Serno"].Value.ToString())); } delSernoList = string.Join(",", sernolist); Phrase ent = new Phrase(APConfig.Conn); string sConditions = ent.getCondition(Phrase.ncConditions.sernolist.ToString(), delSernoList); ent.deleteAll(sConditions); phraseLoadData(); APConfig.SweetAlert(ShowBoxType.alert, "刪除完成"); } } catch (Exception ex) { APConfig.SweetAlert(ShowBoxType.alert, string.Format("刪除失敗 {0}", ex.Message)); } }
private void btnDelete_Click(object sender, EventArgs e) { try { dgvInventory.EndEdit(); List <string> sernolist = new List <string>(); string delSernoList = ""; foreach (DataGridViewRow row in dgvInventory.Rows) { DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells[1]; if ((bool)chk.Value) { sernolist.Add(row.Cells["dgvInventory_Serno"].Value.ToString()); } } delSernoList = APConfig.sqlArrayFormat(string.Join(",", sernolist)); Inventory ent = new Inventory(APConfig.Conn); string sConditions = ent.getCondition(Inventory.ncConditions.sernolist.ToString(), delSernoList); ent.deleteAll(sConditions); APConfig.SweetAlert(ShowBoxType.alert, "刪除完成"); this.Close(); } catch (Exception ex) { APConfig.SweetAlert(ShowBoxType.alert, string.Format("刪除失敗 {0}", ex.Message)); } }
private void btnInventoryDelete_Click(object sender, EventArgs e) { try { if (dgvInventory.SelectedRows.Count > 0) { List <string> sernolist = new List <string>(); string delSernoList = ""; foreach (DataGridViewRow row in dgvInventory.SelectedRows) { sernolist.Add(row.Cells["dgvInventory_Serno"].Value.ToString()); } delSernoList = APConfig.sqlArrayFormat(string.Join(",", sernolist)); using (var form = new PickInventoryDelete(mode.View, delSernoList)) { panelInventory.Visible = false; panelMask.Visible = true; var result = form.ShowDialog(); panelInventory.Visible = true; panelMask.Visible = false; } inventoryLoadData(ddlInventoryPage.SelectedIndex + 1); } } catch (Exception ex) { APConfig.SweetAlert(ShowBoxType.alert, string.Format("刪除失敗 {0}", ex.Message)); } }
private void login() { if (checkLogin()) { AccountInfo view = new AccountInfo(APConfig.Conn); view.Conditions = view.getCondition(AccountInfo.ncConditions.ACCOUNT.ToString(), txtLoginAccount.Text); if (view.load()) { if (view.ACT_PASSWORD != txtLoginPassword.Text) { APConfig.SweetAlert(ShowBoxType.alert, "密碼錯誤!"); } else { APConfig.AccountName = view.ACT_NAME; APConfig.SweetAlert(ShowBoxType.alert, string.Format("歡迎使用!\r\n{0}", view.ACT_NAME)); this.Hide(); Main form = new Main(); form.ShowDialog(); this.Close(); } } else { APConfig.SweetAlert(ShowBoxType.alert, "查無此帳號!"); } } }
private void dgvItem_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { DataGridViewRow row = this.dgvItem.SelectedRows[0]; string status = row.Cells["dgvItem_Status"].Value.ToString(); if (status == InventoryStatus.已出貨.ToString()) { this.Hide(); InventoryExportEdit form = new InventoryExportEdit(mode, row.Cells["dgvItem_Serno"].Value.ToString()); form.ShowDialog(); this.Close(); } else if (status == InventoryStatus.庫存中.ToString()) { this.Hide(); InventoryImportEdit form = new InventoryImportEdit(mode, row.Cells["dgvItem_Serno"].Value.ToString()); form.ShowDialog(); this.Close(); } else if (status == InventoryStatus.已退貨.ToString()) { this.Hide(); InventoryReturnEdit form = new InventoryReturnEdit(mode, row.Cells["dgvItem_Serno"].Value.ToString()); form.ShowDialog(); this.Close(); } else { APConfig.SweetAlert(ShowBoxType.alert, "請聯繫Hugo!"); this.Close(); } }
private void itemInfoAdd() { #region 判斷 string msg = ""; if (string.IsNullOrEmpty(serno)) { msg = "請選取進貨單!"; } else if (string.IsNullOrEmpty(txtExportAmount.Text)) { msg = "請輸入出貨金額"; } else if (!int.TryParse(txtExportAmount.Text, out int n)) { msg = "出貨金額欄位請輸入數字"; } else if (dpkExportDTTM.Value < dpkImportDTTM.Value) { msg = "出貨日期無法小於進貨日期!"; } if (!string.IsNullOrEmpty(msg)) { APConfig.SweetAlert(ShowBoxType.alert, msg); return; } #endregion DataGridViewRowCollection rows = dgvItem.Rows; rows.Add(new Object[] { serno, txtCode.Text, txtName.Text, txtType.Text, txtColor.Text, txtExportAmount.Text, ddlDealer.SelectedItem.ToString(), dpkExportDTTM.Value.ToShortDateString(), txtExportComment.Text }); clearTextBox(); loadTotalAmount(); }
private void btnClose_Click(object sender, EventArgs e) { if (APConfig.SweetAlert(ShowBoxType.confirm, "確定要離開嗎?")) { this.Close(); Environment.Exit(Environment.ExitCode); } }
private void btnOK_Click(object sender, EventArgs e) { if (mode == mode.Add && checkAdd()) { int count = 0; foreach (DataGridViewRow row in dgvItem.Rows) { Inventory ent = new Inventory(APConfig.Conn); ent.INV_SERNO = row.Cells["dgvItem_Serno"].Value.ToString(); ent.ModifyFields = string.Format("{0};{1};{2};{3};{4};{5}" , Inventory.ncFields.INV_STATUS.ToString() , Inventory.ncFields.INV_RETURNAMT.ToString() , Inventory.ncFields.INV_RETURNDTTM.ToString() , Inventory.ncFields.INV_RETURNCOMMENT.ToString() , Inventory.ncFields.INV_MODIFIEDBY.ToString() , Inventory.ncFields.INV_MODIFIEDDTTM.ToString()); ent.INV_STATUS = InventoryStatus.已退貨.ToString(); ent.INV_RETURNAMT = Convert.ToInt32(row.Cells["dgvItem_Amount"].Value); ent.INV_RETURNCOMMENT = row.Cells["dgvItem_Comment"].Value.ToString(); ent.INV_RETURNDTTM = DateTime.Parse(row.Cells["dgvItem_ImportDTTM"].Value.ToString()); ent.INV_MODIFIEDBY = APConfig.AccountName; ent.INV_MODIFIEDDTTM = DateTime.Now; count += ent.update(); } APConfig.SweetAlert(ShowBoxType.alert, string.Format("退貨完成!\r\n新增 {0} 件退貨單", count.ToString())); this.DialogResult = DialogResult.OK; this.Close(); } else if (mode == mode.Edit && checkAdd()) { Inventory ent = new Inventory(APConfig.Conn); ent.INV_SERNO = serno; ent.ModifyFields = string.Format("{0};{1};{2};{3};{4}" , Inventory.ncFields.INV_RETURNAMT.ToString() , Inventory.ncFields.INV_RETURNDTTM.ToString() , Inventory.ncFields.INV_RETURNCOMMENT.ToString() , Inventory.ncFields.INV_MODIFIEDBY.ToString() , Inventory.ncFields.INV_MODIFIEDDTTM.ToString()); ent.INV_RETURNAMT = Convert.ToInt32(txtReturnAmount.Text); ent.INV_RETURNDTTM = DateTime.Parse(dpkReturnDTTM.Value.ToString()); ent.INV_RETURNCOMMENT = txtReturnComment.Text; ent.INV_MODIFIEDBY = APConfig.AccountName; ent.INV_MODIFIEDDTTM = DateTime.Now; ent.update(); APConfig.SweetAlert(ShowBoxType.alert, "修改完成"); this.DialogResult = DialogResult.OK; this.Close(); } else if (mode == mode.View) { this.DialogResult = DialogResult.OK; this.Close(); } else { return; } }
private void hugo() { APConfig.AccountName = "Hugo"; APConfig.SweetAlert(ShowBoxType.alert, string.Format("歡迎使用!\r\n{0}", "HUGO")); this.Hide(); Main form = new Main(); form.ShowDialog(); this.Close(); }
private void btnItemDel_Click(object sender, EventArgs e) { if (APConfig.SweetAlert(ShowBoxType.confirm, "是否確定要刪除?")) { foreach (DataGridViewRow row in dgvItem.SelectedRows) { dgvItem.Rows.RemoveAt(row.Index); } } loadTotalCount(); }
private void btnOK_Click(object sender, EventArgs e) { if (mode == mode.Add && check()) { Phrase ent = new Phrase(APConfig.Conn); ent.PHS_SERNO = My.GenSerNo(); ent.PHS_CATEGORY = ddlCategory.SelectedItem.ToString(); ent.PHS_NAME = txtName.Text; ent.PHS_INDEX = txtIndex.Text; ent.PHS_TYPE = txtType.Text; ent.PHS_COLOR = txtColor.Text; ent.PHS_SIZE = txtSize.Text; ent.PHS_MODIFIEDBY = APConfig.AccountName; ent.PHS_MODIFIEDDTTM = DateTime.Now; ent.insert(); APConfig.SweetAlert(ShowBoxType.alert, "新增完成"); this.DialogResult = DialogResult.OK; this.Close(); } else if (mode == mode.Edit && check()) { Phrase ent = new Phrase(APConfig.Conn); ent.PHS_SERNO = serno; ent.ModifyFields = string.Format("{0};{1};{2};{3},{4},{5},{6}" , Phrase.ncFields.PHS_NAME.ToString() , Phrase.ncFields.PHS_INDEX.ToString() , Phrase.ncFields.PHS_TYPE.ToString() , Phrase.ncFields.PHS_SIZE.ToString() , Phrase.ncFields.PHS_COLOR.ToString() , Phrase.ncFields.PHS_MODIFIEDBY.ToString() , Phrase.ncFields.PHS_MODIFIEDDTTM.ToString()); ent.PHS_NAME = txtName.Text; ent.PHS_INDEX = txtIndex.Text; ent.PHS_TYPE = txtType.Text; ent.PHS_COLOR = txtColor.Text; ent.PHS_SIZE = txtSize.Text; ent.PHS_MODIFIEDBY = APConfig.AccountName; ent.PHS_MODIFIEDDTTM = DateTime.Now; ent.update(); APConfig.SweetAlert(ShowBoxType.alert, "修改完成"); this.DialogResult = DialogResult.OK; this.Close(); } else if (mode == mode.View) { this.DialogResult = DialogResult.OK; this.Close(); } else { return; } }
private bool checkLogin() { string msg = ""; string pattern = @"^[a-zA-Z0-9]+$"; //判斷只有英文數字 if (!Regex.Match(txtLoginAccount.Text, pattern).Success || !Regex.Match(txtLoginPassword.Text, pattern).Success) { APConfig.SweetAlert(ShowBoxType.alert, "欄位內容只能包含英文數字!"); return(false); } return(true); }
private void btnSubmit_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(checkSubmit())) { Account entAccount = new Account(APConfig.Conn); entAccount.ACT_SERNO = My.GenSerNo(); entAccount.ACT_NAME = txtName.Text; entAccount.ACT_ACCOUNT = txtAccount.Text; entAccount.ACT_PASSWORD = txtPassword.Text; entAccount.ACT_CREATEDTTM = DateTime.Now; entAccount.insert(); APConfig.SweetAlert(ShowBoxType.alert, "新增完成!"); } }
public static ComboBox loadPage(ComboBox c, int maxPage) { c.Items.Clear(); for (int i = 1; i <= maxPage; i++) { c.Items.Add(i.ToString()); } if (c.Items.Count > 0) { c.SelectedIndex = 0; } else { APConfig.SweetAlert(ShowBoxType.alert, "查無資料"); } return(c); }
private string checkSubmit() { string msg = ""; string pattern = @"^[a-zA-Z0-9]+$"; //判斷只有英文數字 bool isEmpty = false; foreach (Control pages in this.Controls) { if (pages is Panel) { Panel panel = pages as Panel; if (panel.Name.ToString() == "panelSubmit") { foreach (Control c in pages.Controls) { if (c is BunifuMetroTextbox) { BunifuMetroTextbox textBox = c as BunifuMetroTextbox; if (textBox.Text == string.Empty) { msg = "欄位不能為空值!"; isEmpty = true; } else if (!Regex.Match(textBox.Text, pattern).Success) { msg = "欄位內容只能包含英文數字!"; isEmpty = true; } } } } } } if (!isEmpty && txtPassword.Text != txtPassword2.Text) { msg = "密碼輸入不相同!"; } if (!string.IsNullOrEmpty(msg)) { APConfig.SweetAlert(ShowBoxType.alert, msg); } return(msg); }
private void itemInfoAdd() { #region 判斷 string msg = ""; if (string.IsNullOrEmpty(serno)) { msg = "請選取庫存!"; } else if (string.IsNullOrEmpty(txtReturnAmount.Text)) { msg = "請輸入退貨金額"; } else if (!int.TryParse(txtReturnAmount.Text, out int n)) { msg = "退貨金額欄位請輸入數字"; } else if (dpkReturnDTTM.Value < dpkDTTM.Value) { msg = "出貨日期無法小於進貨日期!"; } foreach (DataGridViewRow row in dgvItem.Rows) { if (serno == row.Cells["dgvItem_Serno"].Value.ToString()) { msg = "該筆資料已存在列表!"; break; } } if (!string.IsNullOrEmpty(msg)) { APConfig.SweetAlert(ShowBoxType.alert, msg); return; } #endregion DataGridViewRowCollection rows = dgvItem.Rows; rows.Add(new Object[] { serno, txtCode.Text, txtName.Text, txtType.Text, txtColor.Text, txtReturnAmount.Text, dpkReturnDTTM.Value.ToShortDateString(), txtReturnComment.Text }); clearPage(); loadRowColor(); loadTotalAmount(); }
private void btnBackUp_Click(object sender, EventArgs e) { if (APConfig.SweetAlert(ShowBoxType.confirm, "是否確定要備份?")) { try { SqlConnection conn = new SqlConnection(APConfig.Conn.getConnectionString()); SqlCommand cmd = new SqlCommand(string.Empty, conn); conn.Open(); cmd.Parameters.Clear(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "sp_BackupData"; SqlParameter result = cmd.Parameters.Add("@result", SqlDbType.Int); result.Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); if (Convert.ToInt32(result.Value) == 1) { APConfig.SweetAlert(ShowBoxType.alert, "備份成功!"); } else { APConfig.SweetAlert(ShowBoxType.alert, "備份失敗!"); } conn.Close(); conn.Dispose(); } catch (Exception ex) { APConfig.SweetAlert(ShowBoxType.alert, string.Format("備份失敗!{0}", ex.Message)); } } }
private void loadData(string pserno) { if (string.IsNullOrEmpty(pserno)) { APConfig.SweetAlert(ShowBoxType.alert, "載入失敗!聯繫Hugo!"); } else { InventoryInfo view = new InventoryInfo(APConfig.Conn); view.Conditions = " 1=1 "; view.Conditions += " AND " + view.getCondition(InventoryInfo.ncConditions.serno.ToString(), pserno); if (view.load()) { serno = view.INV_SERNO; txtCode.Text = view.INV_VENDOR; txtName.Text = view.INV_NAME; txtColor.Text = view.INV_COLOR; txtType.Text = view.INV_TYPE; txtAmount.Text = view.INV_INAMT.ToString(); dpkDTTM.Value = view.INV_INDTTM; txtComment.Text = view.INV_INCOMMENT; } } }
private bool check() { string msg = ""; bool isEmpty = false; if (string.IsNullOrEmpty(txtName.Text)) { msg = "欄位不能為空值!"; isEmpty = true; } if (!isEmpty) { PhraseInfo view = new PhraseInfo(APConfig.Conn); view.Conditions = " 1=1 "; view.Conditions += " AND " + view.getCondition(PhraseInfo.ncConditions.category.ToString(), ddlCategory.SelectedItem.ToString()); view.Conditions += " AND " + view.getCondition(PhraseInfo.ncConditions.EQname.ToString(), txtName.Text); if (isItem) { view.Conditions += " AND " + view.getCondition(PhraseInfo.ncConditions.EQsize.ToString(), txtSize.Text); view.Conditions += " AND " + view.getCondition(PhraseInfo.ncConditions.EQtype.ToString(), txtType.Text); view.Conditions += " AND " + view.getCondition(PhraseInfo.ncConditions.EQcolor.ToString(), txtColor.Text); } if (view.calculateCount() > 0) { msg = "項目已存在!請確認!"; } } if (!string.IsNullOrEmpty(msg)) { APConfig.SweetAlert(ShowBoxType.alert, msg); } return(string.IsNullOrEmpty(msg) ? true : false); }
private bool checkAdd() { string msg = ""; if (mode == mode.Add && dgvItem.RowCount <= 0) { msg = "商品資訊無法為空!"; } else if (mode == mode.Edit && string.IsNullOrEmpty(txtReturnAmount.Text)) { msg = "退金額無法為空!"; } else if (dpkReturnDTTM.Value < dpkDTTM.Value) { msg = "退貨日期無法小於進貨日期!"; } if (!string.IsNullOrEmpty(msg)) { APConfig.SweetAlert(ShowBoxType.alert, msg); } return(string.IsNullOrEmpty(msg) ? true : false); }
private bool checkAdd() { string msg = ""; if (mode == mode.Add && dgvItem.RowCount <= 0) { msg = "商品資訊無法為空!"; } else if (mode == mode.Edit && string.IsNullOrEmpty(txtAmount.Text)) { msg = "商品金額無法為空!"; } else if (mode == mode.Edit && string.IsNullOrEmpty(txtName.Text)) { msg = "商品名稱無法為空!"; } if (!string.IsNullOrEmpty(msg)) { APConfig.SweetAlert(ShowBoxType.alert, msg); } return(string.IsNullOrEmpty(msg) ? true : false); }
private void btnOK_Click(object sender, EventArgs e) { if (mode == mode.Add && checkAdd()) { int newCount = 0; foreach (DataGridViewRow row in dgvItem.Rows) { Inventory ent = new Inventory(APConfig.Conn); ent.INV_SERNO = My.GenSerNo(); ent.INV_STATUS = InventoryStatus.庫存中.ToString(); ent.INV_VENDOR = row.Cells["dgvItem_Vendor"].Value.ToString(); ent.INV_NAME = row.Cells["dgvItem_Name"].Value.ToString(); ent.INV_TYPE = row.Cells["dgvItem_Type"].Value.ToString(); ent.INV_COLOR = row.Cells["dgvItem_Color"].Value.ToString(); ent.INV_SIZE = row.Cells["dgvItem_Size"].Value.ToString(); ent.INV_INCOMMENT = row.Cells["dgvItem_Comment"].Value.ToString(); ent.INV_INAMT = Convert.ToInt32(row.Cells["dgvItem_Amount"].Value); ent.INV_INDTTM = DateTime.Parse(row.Cells["dgvItem_ImportDTTM"].Value.ToString()); ent.INV_MODIFIEDBY = APConfig.AccountName; ent.INV_MODIFIEDDTTM = DateTime.Now; newCount += ent.insert(); } APConfig.SweetAlert(ShowBoxType.alert, string.Format("進貨完成!\r\n新增 {0} 件進貨單 ", newCount.ToString())); this.DialogResult = DialogResult.OK; this.Close(); } else if (mode == mode.Edit && checkAdd()) { Inventory ent = new Inventory(APConfig.Conn); ent.INV_SERNO = serno; ent.ModifyFields = string.Format("{0};{1};{2};{3};{4};{5},{6},{7},{8},{9}" , Inventory.ncFields.INV_NAME.ToString() , Inventory.ncFields.INV_TYPE.ToString() , Inventory.ncFields.INV_COLOR.ToString() , Inventory.ncFields.INV_SIZE.ToString() , Inventory.ncFields.INV_INAMT.ToString() , Inventory.ncFields.INV_INDTTM.ToString() , Inventory.ncFields.INV_INCOMMENT.ToString() , Inventory.ncFields.INV_MODIFIEDBY.ToString() , Inventory.ncFields.INV_MODIFIEDDTTM.ToString() , Inventory.ncFields.INV_VENDOR.ToString()); ent.INV_NAME = txtName.Text; ent.INV_TYPE = txtType.Text; ent.INV_SIZE = txtSize.Text; ent.INV_COLOR = txtColor.Text; ent.INV_INAMT = Convert.ToInt32(txtAmount.Text); ent.INV_INDTTM = DateTime.Parse(dpkImportDTTM.Value.ToString()); ent.INV_INCOMMENT = txtComment.Text; ent.INV_MODIFIEDBY = APConfig.AccountName; ent.INV_MODIFIEDDTTM = DateTime.Now; ent.INV_VENDOR = ddlVendor.SelectedItem.ToString(); ent.update(); APConfig.SweetAlert(ShowBoxType.alert, "修改完成"); this.DialogResult = DialogResult.OK; this.Close(); } else if (mode == mode.View) { this.DialogResult = DialogResult.OK; this.Close(); } else { return; } }
private bool checkAdd() { string msg = ""; int n, count = 0; string[] condReqName = { "txtMobile1", "txtMobile2", "txtPhone" }; //判斷欄位三個至少填一個 string[] condName = { "txtName", "txtNo" }; //必填欄位 string[] condNumberName = { "txtAmount" }; //判斷數字欄位 foreach (Control c in this.Controls) { if (c is BunifuMetroTextbox) { BunifuMetroTextbox textBox = c as BunifuMetroTextbox; if (condName.Contains(textBox.Name) && textBox.Text == string.Empty) { msg = "必要欄位不能為空值!"; } else if (condReqName.Contains(textBox.Name) && textBox.Text == string.Empty) { count++; } else if (condNumberName.Contains(textBox.Name) && textBox.Text != string.Empty) { if (!int.TryParse(textBox.Text, out n)) { msg = "金額欄位請輸入數字"; } } } else if (c is BunifuDropdown) { BunifuDropdown dropdown = c as BunifuDropdown; if (dropdown.selectedIndex == -1) { msg = "欄位不能為空值!"; } } } if (count == condReqName.Length) { msg = "電話欄位至少輸入一欄!"; } if (string.IsNullOrEmpty(msg) && mode == mode.Add) { foreach (DataGridViewRow row in dgvItem.Rows) { if (txtNo.Text == row.Cells["dgvItem_No"].Value.ToString()) { msg = "該訂單編號已經存在列表中!請重複確認!!"; break; } } } if (string.IsNullOrEmpty(msg) && mode == mode.Add) { RosterInfo vRoster = new RosterInfo(APConfig.Conn); vRoster.Conditions = vRoster.getCondition(RosterInfo.ncConditions.no.ToString(), txtNo.Text); if (vRoster.calculateCount() > 0) { msg = "該訂單編號已經有資料!請重複確認!"; } } if (!string.IsNullOrEmpty(msg)) { APConfig.SweetAlert(ShowBoxType.alert, msg); } return(string.IsNullOrEmpty(msg) ? true : false); }
private void btnOK_Click(object sender, EventArgs e) { if (mode == mode.Add) { if (dgvItem.Rows.Count == 0) { this.DialogResult = DialogResult.OK; this.Close(); return; } int count = 0; foreach (DataGridViewRow row in dgvItem.Rows) { Roster ent = new Roster(APConfig.Conn); ent.RST_SERNO = My.GenSerNo(); ent.RST_NO = row.Cells["dgvItem_No"].Value.ToString(); ent.RST_NAME = row.Cells["dgvItem_Name"].Value.ToString(); ent.RST_PHONE = row.Cells["dgvItem_Phone"].Value.ToString(); ent.RST_MOBILE1 = row.Cells["dgvItem_Mobile1"].Value.ToString(); ent.RST_MOBILE2 = row.Cells["dgvItem_Mobile2"].Value.ToString(); ent.RST_AMOUNT = Convert.ToInt32(row.Cells["dgvItem_Amount"].Value.ToString()); ent.RST_ORDERDTTM = DateTime.Parse(row.Cells["dgvItem_OrderDTTM"].Value.ToString()); ent.RST_ADDR = row.Cells["dgvItem_Addr"].Value.ToString(); ent.RST_COMMENT1 = row.Cells["dgvItem_Comment1"].Value.ToString(); ent.RST_COMMENT2 = row.Cells["dgvItem_Comment2"].Value.ToString(); ent.RST_COMMENT3 = row.Cells["dgvItem_Comment3"].Value.ToString(); ent.RST_INSERTBY = APConfig.AccountName; ent.RST_INSERTDTTM = DateTime.Now; ent.RST_MODIFIEDBY = APConfig.AccountName; ent.RST_MODIFIEDDTTM = DateTime.Now; count += ent.insert(); } APConfig.SweetAlert(ShowBoxType.alert, string.Format("訂單登記完成!\r\n新增 {0} 件", count.ToString())); this.DialogResult = DialogResult.OK; this.Close(); } else if (mode == mode.Edit) { Roster ent = new Roster(APConfig.Conn); ent.RST_SERNO = serno; ent.ModifyFields = string.Format("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10};{11};{12}" , Roster.ncFields.RST_NO.ToString() , Roster.ncFields.RST_NAME.ToString() , Roster.ncFields.RST_PHONE.ToString() , Roster.ncFields.RST_MOBILE1.ToString() , Roster.ncFields.RST_MOBILE2.ToString() , Roster.ncFields.RST_AMOUNT.ToString() , Roster.ncFields.RST_ORDERDTTM.ToString() , Roster.ncFields.RST_ADDR.ToString() , Roster.ncFields.RST_COMMENT1.ToString() , Roster.ncFields.RST_COMMENT2.ToString() , Roster.ncFields.RST_COMMENT3.ToString() , Roster.ncFields.RST_MODIFIEDBY.ToString() , Roster.ncFields.RST_MODIFIEDDTTM.ToString()); ent.RST_NO = txtNo.Text; ent.RST_NAME = txtName.Text; ent.RST_PHONE = txtPhone.Text; ent.RST_MOBILE1 = txtMobile1.Text; ent.RST_MOBILE2 = txtMobile2.Text; ent.RST_AMOUNT = Convert.ToInt32(txtAmount.Text); ent.RST_ORDERDTTM = DateTime.Parse(dpkOrderDTTM.Value.ToString()); ent.RST_ADDR = txtAddr.Text; ent.RST_COMMENT1 = txtComment1.Text; ent.RST_COMMENT2 = txtComment2.Text; ent.RST_COMMENT3 = txtComment3.Text; ent.RST_MODIFIEDBY = APConfig.AccountName; ent.RST_MODIFIEDDTTM = DateTime.Now; ent.update(); APConfig.SweetAlert(ShowBoxType.alert, "修改完成"); this.DialogResult = DialogResult.OK; this.Close(); } else if (mode == mode.View) { this.DialogResult = DialogResult.OK; this.Close(); } else { return; } }