private void btnMemberDelete_Click(object sender, EventArgs e) { try { if (dgvMember.SelectedRows.Count > 0 && APConfig.SweetAlert(ShowBoxType.confirm, string.Format("是否確定要刪除{0}筆?", dgvMember.SelectedRows.Count))) { List <string> sernolist = new List <string>(); string delSernoList = ""; foreach (DataGridViewRow row in dgvMember.SelectedRows) { sernolist.Add(string.Format("'{0}'", row.Cells["dgvMember_Serno"].Value.ToString())); } delSernoList = string.Join(",", sernolist); Roster entRoster = new Roster(APConfig.Conn); string sConditions = entRoster.getCondition(Roster.ncConditions.sernolist.ToString(), delSernoList); entRoster.deleteAll(sConditions); memberLoadData(ddlMemberPage.SelectedIndex + 1); APConfig.SweetAlert(ShowBoxType.alert, "刪除完成"); } } catch (Exception ex) { APConfig.SweetAlert(ShowBoxType.alert, string.Format("刪除失敗 {0}", ex.Message)); } }
private void btnMemberLeft_Click(object sender, EventArgs e) { if (APConfig.prevPage(ref ddlMemberPage)) { memberLoadData(ddlMemberPage.SelectedIndex + 1); } }
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 btnClose_Click(object sender, EventArgs e) { if (APConfig.SweetAlert(ShowBoxType.confirm, "確定要離開嗎?")) { this.Close(); Environment.Exit(Environment.ExitCode); } }
public Home() { InitializeComponent(); APConfig.LoadConfig(); AccountInfo view = new AccountInfo(APConfig.Conn); view.load(); int a = view.Count; }
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 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 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 memberLoadData(int pageNum) { int total = 0; dgvMember.Rows.Clear(); DataGridViewRowCollection rows = dgvMember.Rows; RosterInfo vRoster = new RosterInfo(APConfig.Conn); vRoster.Conditions = " 1=1 "; if (!string.IsNullOrEmpty(txtMemberName.Text)) { vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.name.ToString(), txtMemberName.Text); } if (!string.IsNullOrEmpty(txtMemberTel.Text)) { vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.phoneLike.ToString(), txtMemberTel.Text); } if (!string.IsNullOrEmpty(txtMemberAddr.Text)) { vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.address.ToString(), txtMemberAddr.Text); } if (!string.IsNullOrEmpty(txtMemberNo.Text)) { vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.noLike.ToString(), txtMemberNo.Text); } if (!string.IsNullOrEmpty(dpkMemberOrderSDTTM.Value.ToString()) && ckbMemberOrderDTTM.Checked) { vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.orderSDTTM.ToString(), dpkMemberOrderSDTTM.Value.ToString("yyyy/MM/dd")); } if (!string.IsNullOrEmpty(dpkMemberOrderEDTTM.Value.ToString()) && ckbMemberOrderDTTM.Checked) { vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.orderEDTTM.ToString(), dpkMemberOrderEDTTM.Value.ToString("yyyy/MM/dd")); } //組排序指令 if (dgvMember.SortedColumn == null) { vRoster.OrderBy = vRoster.getOptionOrderBy(RosterInfo.ncSort.Default.ToString()); } else { string sortname = dgvMember.SortedColumn.Name; string sortmode = APConfig.GetValueFromDescription <SortMode>(dgvMember.SortOrder.ToString()).ToString(); vRoster.OrderBy = string.Format("{0} {1}", vRoster.getOptionOrderBy(sortname), sortmode); } //查詢頁數初始化且自動跳轉至第一頁 if (pageNum == 0) { APConfig.loadPage(ddlMemberPage, vRoster.calculatePage(APConfig.PageCount)); return; } //塞入資料 lblMemberTotal.Text = vRoster.calculateCount().ToString(); DataSet ds = APConfig.GoPage(vRoster.SQLStatement, pageNum); foreach (DataRow dr in ds.Tables[0].Rows) { rows.Add(new Object[] { dr.ItemArray[0], dr.ItemArray[1], dr.ItemArray[2], dr.ItemArray[4], dr.ItemArray[5], dr.ItemArray[3], dr.ItemArray[6], dr.ItemArray[10], dr.ItemArray[11], dr.ItemArray[12] }); } //計算總金額 vRoster.load(); while (!vRoster.IsEof) { total += vRoster.RST_AMOUNT; vRoster.next(); } lblMemberAMTTotal.Text = string.Format("{0} 元", total.ToString()); }
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; } }
public Login() { InitializeComponent(); APConfig.LoadConfig(); }