private void clslit4_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } bool flag = false; string text = DateTime.Now.ToString("yyyyMMdd"); string text2 = clslit4.CurrentRow.Cells["cropGuideId"].Value.ToString(); string text3 = clslit4.CurrentRow.Cells["pestGuideId"].Value.ToString(); string text4 = clslit4.CurrentRow.Cells["pesticideId"].Value.ToString(); string text5 = clslit4.CurrentRow.Cells["formcode1"].Value.ToString(); string text6 = clslit4.CurrentRow.Cells["content"].Value.ToString(); string[] strWhereParameterArray = new string[6] { text2, text3, text4, text5, text6, text }; if (((DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Select, "hs.*", "HyScope as hs", "hs.cropId={0} and hs.pestId={1} and hs.pesticideId={2} and hs.formCode={3} and hs.contents={4} and hs.regStoreName ='' and hs.isDelete in ('N','') ", "", null, strWhereParameterArray, CommandOperationType.ExecuteReaderReturnDataTable)).Rows.Count > 0) { string[] strWhereParameterArray2 = new string[1] { fpg.realcropcode }; DataTable dataTable = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Select, "name", "HyCrop", "code={0}", "", null, strWhereParameterArray2, CommandOperationType.ExecuteReaderReturnDataTable); string[] strWhereParameterArray3 = new string[1] { fpg.pestcode }; DataTable dataTable2 = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Select, "name", "HyBlight", "code={0}", "", null, strWhereParameterArray3, CommandOperationType.ExecuteReaderReturnDataTable); if (Program.SystemMode == 1) { frs.addOnecommodity(clslit4.CurrentRow.Cells[1].Value.ToString(), fpg.realcropcode, fpg.pestcode, dataTable.Rows[0]["name"].ToString(), dataTable2.Rows[0]["name"].ToString()); frs.setfocus(); frs.Show(); } else { frsm.addOnecommodity(clslit4.CurrentRow.Cells[1].Value.ToString(), fpg.realcropcode, fpg.pestcode, dataTable.Rows[0]["name"].ToString(), dataTable2.Rows[0]["name"].ToString()); frsm.setfocus(); frsm.Show(); } Hide(); return; } string[] strWhereParameterArray4 = new string[6] { text2, text3, text4, text5, text6, text }; DataTable dataTable3 = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Select, "hs.*", "HyScope as hs", "hs.cropId={0} and hs.pestId={1} and hs.pesticideId={2} and hs.formCode={3} and hs.contents={4} and hs.approveDate != '' and (hs.approveDate + 19190000) >= CAST ({5} as INTEGER) and hs.regStoreName !='' and hs.regStoreName !='99999999' and hs.isDelete in ('N','') ", "", null, strWhereParameterArray4, CommandOperationType.ExecuteReaderReturnDataTable); if (dataTable3.Rows.Count > 0) { flag = true; foreach (DataRow row in dataTable3.Rows) { string[] strWhereParameterArray5 = new string[4] { row["pesticideId"].ToString(), row["formCode"].ToString(), row["contents"].ToString(), row["regStoreName"].ToString() }; DataTable dataTable4 = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Select, "hg.GDSNO", "HyLicence as hl,hypos_GOODSLST as hg", "hl.pesticideId ={0} and hl.formCode={1} and hl.contents={2} and hl.licType = hg.licType and hl.licNo = hg.domManufId and hl.domManufId in (" + row["regStoreName"].ToString() + ") and hl.isDelete='N' and hg.status !='D' ", "", null, strWhereParameterArray5, CommandOperationType.ExecuteReaderReturnDataTable); if (dataTable4.Rows.Count <= 0) { continue; } foreach (DataRow row2 in dataTable4.Rows) { barcodelist.Add(row2["GDSNO"].ToString()); } } } if (flag && barcodelist.Count > 0) { bool flag2 = false; foreach (string item in barcodelist) { if (item.Equals(clslit4.CurrentRow.Cells[1].Value.ToString())) { flag2 = true; } } if (flag2) { string[] strWhereParameterArray6 = new string[1] { fpg.realcropcode }; DataTable dataTable5 = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Select, "name", "HyCrop", "code={0}", "", null, strWhereParameterArray6, CommandOperationType.ExecuteReaderReturnDataTable); string[] strWhereParameterArray7 = new string[1] { fpg.pestcode }; DataTable dataTable6 = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Select, "name", "HyBlight", "code={0}", "", null, strWhereParameterArray7, CommandOperationType.ExecuteReaderReturnDataTable); if (Program.SystemMode == 1) { frs.addOnecommodity(clslit4.CurrentRow.Cells[1].Value.ToString(), fpg.realcropcode, fpg.pestcode, dataTable5.Rows[0]["name"].ToString(), dataTable6.Rows[0]["name"].ToString()); frs.setfocus(); frs.Show(); } else { frsm.addOnecommodity(clslit4.CurrentRow.Cells[1].Value.ToString(), fpg.realcropcode, fpg.pestcode, dataTable5.Rows[0]["name"].ToString(), dataTable6.Rows[0]["name"].ToString()); frsm.setfocus(); frsm.Show(); } Hide(); return; } List <string> list = new List <string>(); foreach (string item2 in barcodelist) { string[] strWhereParameterArray8 = new string[1] { item2 }; DataTable dataTable7 = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Select, "brandName", "hypos_GOODSLST", "GDSNO={0}", "", null, strWhereParameterArray8, CommandOperationType.ExecuteReaderReturnDataTable); list.Add(dataTable7.Rows[0]["brandName"].ToString()); } list = Enumerable.ToList(Enumerable.Distinct(list)); string text7 = ""; foreach (string item3 in list) { text7 = text7 + "[" + item3 + "]"; } AutoClosingMessageBox.Show("此用藥配對尚於資料保護期間,僅可選擇" + text7 + "用藥"); } else { string[] strWhereParameterArray9 = new string[1] { fpg.realcropcode }; DataTable dataTable8 = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Select, "name", "HyCrop", "code={0}", "", null, strWhereParameterArray9, CommandOperationType.ExecuteReaderReturnDataTable); string[] strWhereParameterArray10 = new string[1] { fpg.pestcode }; DataTable dataTable9 = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Select, "name", "HyBlight", "code={0}", "", null, strWhereParameterArray10, CommandOperationType.ExecuteReaderReturnDataTable); if (Program.SystemMode == 1) { frs.addOnecommodity(clslit4.CurrentRow.Cells[1].Value.ToString(), fpg.realcropcode, fpg.pestcode, dataTable8.Rows[0]["name"].ToString(), dataTable9.Rows[0]["name"].ToString()); frs.setfocus(); frs.Show(); } else { frsm.addOnecommodity(clslit4.CurrentRow.Cells[1].Value.ToString(), fpg.realcropcode, fpg.pestcode, dataTable8.Rows[0]["name"].ToString(), dataTable9.Rows[0]["name"].ToString()); frsm.setfocus(); frsm.Show(); } Hide(); } }
private void btn_enter_Click(object sender, EventArgs e) { string text = ""; string text2 = (cb_adjustType.SelectedItem as ComboboxItem).Value.ToString(); string text3 = (cb_adjustType.SelectedItem as ComboboxItem).Text; if (string.IsNullOrEmpty(text2)) { text += "請選擇調整理由\n"; } if ("請輸入調整數字".Equals(tb_adjustCount.Text) || string.IsNullOrEmpty(tb_adjustCount.Text)) { text += "請輸入調整數字\n"; } if (!string.IsNullOrEmpty(text)) { AutoClosingMessageBox.Show(text); return; } try { string text4 = tb_adjustCount.Text; if (_strAdjustPlusOrMinus.Equals("minus")) { text4 = "-" + tb_adjustCount.Text; } else if (_strAdjustPlusOrMinus.Equals("plus")) { text4 = "+" + tb_adjustCount.Text; } string text5 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); l_inventoryCountTotal.Text = (int.Parse(l_inventoryCountTotal.Text) + int.Parse(text4)).ToString(); dataGridView1.Rows.Insert(0, text5, text3, "", text4); DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_GOODSLST set inventory = {1} WHERE GDSNO = {0}", new string[2] { _GDSNO, l_inventoryCountTotal.Text }, CommandOperationType.ExecuteNonQuery); string[,] strFieldArray = new string[6, 2] { { "AdjustNo", getNewAdjustNo() }, { "GDSNO", _GDSNO }, { "adjustType", text2 }, { "adjustCount", text4 }, { "updateDate", text5 }, { "GoodsTotalCountLog", l_inventoryCountTotal.Text } }; DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Insert, "", "hypos_InventoryAdjustment", null, null, strFieldArray, null, CommandOperationType.ExecuteNonQuery); string[,] strFieldArray2 = new string[1, 2] { { "UpdateDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") } }; DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Update, "", "hypos_GOODSLST", " GDSNO = {0} ", "", strFieldArray2, new string[1] { _GDSNO }, CommandOperationType.ExecuteNonQuery); if (text2.Equals("0") || text2.Equals("K")) { AutoClosingMessageBox.Show("此調整不會回傳防檢局,僅供店內管理使用"); } cb_adjustType.SelectedIndex = 0; tb_adjustCount.Text = ""; } catch (FormatException) { AutoClosingMessageBox.Show("金額格式錯誤"); } catch (Exception) { MessageBox.Show("調整錯誤"); } }
private void btn_importList_Click(object sender, EventArgs e) { AutoClosingMessageBox.Show("尚未開發"); }
private void btn_enter_Click(object sender, EventArgs e) { string text = ""; if (sDate.Checked && eDate.Checked) { DateTime t = Convert.ToDateTime(sDate.Value); DateTime t2 = Convert.ToDateTime(eDate.Value); if (DateTime.Compare(t, t2) > 0) { text += "起日不可大於迄日,請重新設定\n"; } } if (sellNo.Text == "請輸入銷售單號" && tb_MemberName.Text == "請輸入會員姓名" && tb_phone.Text == "請輸入會員電話" && !sDate.Checked && !eDate.Checked) { text += "必須輸入查詢條件\n"; } if (!"".Equals(text)) { AutoClosingMessageBox.Show(text); return; } if (sellNo.Text != "請輸入銷售單號") { dt = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Select, "*", "hypos_main_sell", "sellNo={0}", "", null, new string[1] { sellNo.Text }, CommandOperationType.ExecuteReaderReturnDataTable); if (dt.Rows.Count > 0) { switchForm(new frmMainShopSimpleReturnWithMoney(dt.Rows[0]["sellNo"].ToString(), "frmSearchSell_Return", "")); } else { AutoClosingMessageBox.Show("銷售單不存在,請正確輸入銷售單編號"); } return; } int num = 0; List <string> list = new List <string>(); string text2 = "SELECT distinct hms.sellNo,hms.sellTime,hms.memberId,hms.items,hcr.Name,hcr.Mobile ,hcr.IdNo,hcr.CompanyIdNo,hms.cash,hms.Credit,hms.sum FROM hypos_main_sell as hms left outer join hypos_CUST_RTL as hcr on hms.memberId= hcr.VipNo join hypos_detail_sell on hms.sellNo = hypos_detail_sell.sellNo WHERE 1=1 "; if (tb_MemberName.Text != "請輸入會員姓名") { if ("非會員".Equals(tb_MemberName.Text)) { text2 += " AND hcr.Name is null"; } else { text2 = text2 + " AND hcr.Name like {" + num + "}"; list.Add("%" + tb_MemberName.Text.ToString().Trim() + "%"); num++; } } if (tb_phone.Text != "請輸入會員電話") { text2 = text2 + " AND (hcr.Telphone like {" + num + "} or hcr.Mobile like {" + num + "})"; list.Add("%" + tb_phone.Text.ToString().Trim() + "%"); num++; } if (tb_barcode.Text != "請輸入商品編號") { text2 = text2 + " and hypos_detail_sell.barcode like {" + num + "}"; list.Add("%" + tb_barcode.Text.ToString().Trim() + "%"); num++; } if (sDate.Checked) { string str = sDate.Text.ToString(); str += " 00:00:00"; text2 = text2 + " AND hms.sellTime >= {" + num + "}"; list.Add(str); num++; } if (eDate.Checked) { string str2 = eDate.Text.ToString(); str2 += " 23:59:59"; text2 = text2 + " AND hms.sellTime <= {" + num + "}"; list.Add(str2); num++; } DataTable dataTable = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, text2, list.ToArray(), CommandOperationType.ExecuteReaderReturnDataTable); switchForm(new frmSearchSellResult(dataTable, "frmSearchSell_Return")); }
private void btn_back_Click(object sender, EventArgs e) { base.DialogResult = DialogResult.Cancel; AutoClosingMessageBox.Show("不設定批號或製造日期無法選入商品"); Close(); }
private void dialogSetBatchNoAndMFGdate2_Load(object sender, EventArgs e) { try { dateTimePicker0.Value = DateTime.Today; dateTimePicker0.Checked = false; string strTableName = "hypos_GOODSLST as hg left outer join HyLicence as hl on hg.licType =hl.licType and hg.domManufId =hl.licNo"; string strWhereClause = "hg.GDSNO ={0} AND ((hg.ISWS ='Y' and hg.CLA1NO ='0302' and hg.licType = hl.licType and hg.domManufId = hl.licNo) OR (hg.ISWS ='N' and hg.CLA1NO ='0302') OR hg.CLA1NO ='0303' OR hg.CLA1NO ='0305' OR hg.CLA1NO ='0308') AND (hl.isDelete='N' or hl.isDelete is null) "; dt = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Select, "hg.inventory,hg.GDSNO,hg.spec,hg.capacity,hg.GDName,hg.formCode,hg.CName,hg.contents,hg.brandName,hg.CLA1NO,hg.ISWS", strTableName, strWhereClause, "", null, new string[1] { _GDSNO }, CommandOperationType.ExecuteReaderReturnDataTable); if (dt.Rows.Count > 0) { l_GDName.Text = "【" + dt.Rows[0]["GDName"].ToString() + "-" + dt.Rows[0]["CName"].ToString() + "】批號與製造日期設定"; } else { AutoClosingMessageBox.Show("店內碼錯誤!"); Close(); } string sql = "select p.POSBatchNo, p.BatchNo, p.MFGDate, p.barcode, p.num, p.PurchaseNo, (select b.backlogQuantity from hypos_BatchNo_log as b where p.POSBatchNo = b.POSBatchNo order by b.createDate desc limit 1) as backlogQuantity from hypos_PurchaseGoodsBatchNo_log as p where p.barcode = {0} and backlogQuantity <> 0 and p.BatchNo <> ''and p.PurchaseNo in (select PurchaseNo from hypos_PurchaseGoods_Master)"; DataTable dataTable = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, sql, new string[1] { _GDSNO }, CommandOperationType.ExecuteReaderReturnDataTable); if (dataTable.Rows.Count > 0) { foreach (DataRow row in dataTable.Rows) { string text = DataBaseUtilities.DBOperation(Program.ConnectionString, "SELECT SupplierNo FROM hypos_PurchaseGoods_Master where PurchaseNo = {0}", new string[1] { row["PurchaseNo"].ToString() }, CommandOperationType.ExecuteScalar).ToString(); string str = DataBaseUtilities.DBOperation(Program.ConnectionString, "SELECT SupplierName FROM hypos_Supplier where SupplierNo = {0}", new string[1] { text }, CommandOperationType.ExecuteScalar).ToString(); string text2 = string.IsNullOrEmpty(row["backlogQuantity"].ToString()) ? "0" : row["backlogQuantity"].ToString(); uc = new CommodityInfo(); uc.setMemberIdNo(""); uc.setHiddenGDSNO(_GDSNO); uc.setMemberVipNo("進貨單號:" + row["PurchaseNo"].ToString()); uc.setCommodityName("進貨廠商:" + str); uc.setCommodityClass("批號:" + row["BatchNo"].ToString().PadRight(20, ' ') + " 製造日期:" + row["MFGDate"].ToString()); uc.setHiddenBatchNo(row["BatchNo"].ToString()); uc.setHiddenMFGDate(row["MFGDate"].ToString()); uc.setHiddenPOSBatchNo(row["POSBatchNo"].ToString()); uc.setlabe1(""); infolist.Rows.Add(uc, text2, "選擇"); infolist.CurrentCell = infolist.Rows[infolist.RowCount - 1].Cells[0]; } foreach (DataGridViewRow item in (IEnumerable)infolist.Rows) { item.Height = 100; } } else { AutoClosingMessageBox.Show("目前沒有任何此商品的進貨批號設定紀錄"); } } catch (Exception) { } tb_BatchNo.Select(); }
private void btn_ExportTradeReport_Click(object sender, EventArgs e) { FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); if (folderBrowserDialog.ShowDialog() != DialogResult.OK) { return; } string selectedPath = folderBrowserDialog.SelectedPath; string text = selectedPath + str_file_location + str_file_name + _strFromDate.Replace("-", "") + "-" + _strToDate.Replace("-", "") + str_file_type; FileInfo file = new FileInfo(text); int num = 2; if (!File.Exists(text)) { wb = HSSFWorkbook.Create(InternalWorkbook.CreateWorkbook()); sh = (HSSFSheet)wb.CreateSheet("Sheet1"); for (int i = 0; i < dataGridView2.RowCount + num; i++) { IRow row = sh.CreateRow(i); for (int j = 0; j < dataGridView2.ColumnCount; j++) { row.CreateCell(j); } } using (FileStream @out = new FileStream(text, FileMode.Create, FileAccess.Write)) { wb.Write(@out); } } if (!IsFileLocked(file)) { using (FileStream s = new FileStream(text, FileMode.Open, FileAccess.Read)) { wb = new HSSFWorkbook(s); for (int k = 0; k < wb.Count; k++) { lst_Sheet.Add(wb.GetSheetAt(k).SheetName); } } } if (!IsFileLocked(file)) { sh = (HSSFSheet)wb.GetSheet(lst_Sheet[0]); int l = 0; int num2 = 0; string[] array = new string[9] { "日期:", _strFromDate + "~" + _strToDate, "訂單狀態:", _sales_status, "結帳模式:", _sales_cash_credit, "銷售單總價範圍:", _sales_total_range, "" }; string[] array2 = new string[9] { "時間", "銷售總額(原始)", "現金收款", "賒帳金額", "找零", "退款金額", "總客次", "銷售數量", "" }; num2 = ((array.Length > array2.Length) ? array.Length : array2.Length); for (; l < num; l++) { for (int m = 0; m < num2; m++) { if (sh.GetRow(l).GetCell(m) == null) { sh.GetRow(l).CreateCell(m); } if (l == 0) { sh.GetRow(l).GetCell(m).SetCellValue(array[m]); } if (l == 1) { sh.GetRow(l).GetCell(m).SetCellValue(array2[m]); } } } for (int n = 0; n < dataGridView2.RowCount; n++) { if (sh.GetRow(l) == null) { sh.CreateRow(l); } for (int num3 = 0; num3 < dataGridView2.ColumnCount; num3++) { if (sh.GetRow(l).GetCell(num3) == null) { sh.GetRow(l).CreateCell(num3); } if (dataGridView2[num3, n].Value != null) { sh.GetRow(l).GetCell(num3).SetCellValue(dataGridView2[num3, n].Value.ToString()); } } l++; } using (FileStream out2 = new FileStream(text, FileMode.Open, FileAccess.Write)) { wb.Write(out2); AutoClosingMessageBox.Show("匯出報表於" + text); } } else { AutoClosingMessageBox.Show(text + "檔案使用中,請確認檔案是在未開啟的狀態下"); } }
private void btn_save_Click(object sender, EventArgs e) { string text = ""; if (duplicateAccount) { text += "請確認帳號\n"; } if (string.IsNullOrEmpty(tb_password.Text) || !string.IsNullOrEmpty(l_checkRepassword.Text)) { text += "請確認密碼\n"; } if (string.IsNullOrEmpty(tb_Name.Text)) { text += "請輸入使用者姓名\n"; } if (!"".Equals(text)) { AutoClosingMessageBox.Show(text); return; } string[,] strFieldArray = new string[6, 2] { { "Account", tb_account.Text }, { "Password", tb_password.Text }, { "Name", tb_Name.Text }, { "Email", tb_email.Text }, { "Type", (cb_type.SelectedItem as ComboboxItem).Value.ToString() }, { "Status", (cb_status.SelectedItem as ComboboxItem).Value.ToString() } }; DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Insert, "", "hypos_User", "", "", strFieldArray, null, CommandOperationType.ExecuteNonQuery); TableLayoutPanel tlp_userManage = (base.Owner as frmSystemSetup).tlp_userManage; tlp_userManage.RowCount++; CheckBox checkBox = new CheckBox(); checkBox.Dock = DockStyle.Fill; checkBox.Name = tb_account.Text; Label label = new Label(); label.Dock = DockStyle.Fill; label.Anchor = AnchorStyles.Left; label.Text = tb_account.Text; label.AutoSize = true; label.Click += new EventHandler((base.Owner as frmSystemSetup).editUser); Label label2 = new Label(); label2.Dock = DockStyle.Fill; label2.Anchor = AnchorStyles.Left; label2.Text = tb_Name.Text; label2.AutoSize = true; Label label3 = new Label(); label3.Dock = DockStyle.Fill; label3.Anchor = AnchorStyles.Left; label3.Text = (cb_type.SelectedItem as ComboboxItem).Text; label3.AutoSize = true; Label label4 = new Label(); label4.Dock = DockStyle.Fill; label4.Anchor = AnchorStyles.Left; label4.Text = (cb_status.SelectedItem as ComboboxItem).Text; label4.AutoSize = true; Label label5 = new Label(); label5.Dock = DockStyle.Fill; label5.Anchor = AnchorStyles.Left; label5.Text = ""; label5.AutoSize = true; tlp_userManage.Controls.Add(checkBox, 0, tlp_userManage.RowCount - 1); tlp_userManage.Controls.Add(label, 1, tlp_userManage.RowCount - 1); tlp_userManage.Controls.Add(label2, 2, tlp_userManage.RowCount - 1); tlp_userManage.Controls.Add(label3, 3, tlp_userManage.RowCount - 1); tlp_userManage.Controls.Add(label4, 4, tlp_userManage.RowCount - 1); tlp_userManage.Controls.Add(label5, 5, tlp_userManage.RowCount - 1); tlp_userManage.RowStyles.Add(new RowStyle(SizeType.Absolute, 40f)); AutoClosingMessageBox.Show("已新增"); Close(); }
public void viewMemberInfo(object vipNo, EventArgs s) { int dBVersion = Program.GetDBVersion(); string text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); if (dBVersion == 0) { if (new frmDialogMember(vipNo.ToString()).ShowDialog() == DialogResult.Yes) { if (Program.SystemMode == 1) { switchForm(new frmMainShopSimple(vipNo.ToString())); } else { switchForm(new frmMainShopSimpleWithMoney(vipNo.ToString())); } } } else { if (dBVersion < 1 || !Program.IsFertilizer) { return; } DialogResult dialogResult = new frmDialogMember(vipNo.ToString()).ShowDialog(); string[] strParameterArray = new string[1] { vipNo.ToString() }; DataTable dataTable = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, "SELECT * FROM hypos_CUST_RTL WHERE VipNo = {0} ", strParameterArray, CommandOperationType.ExecuteReaderReturnDataTable); if (dataTable.Rows.Count <= 0) { return; } if (dataTable.Rows[0]["IdNo"].ToString().Length == 10) { if ("Y".Equals(dataTable.Rows[0]["Verification"].ToString())) { if (dialogResult == DialogResult.Yes) { if (Program.SystemMode == 1) { switchForm(new frmMainShopSimple(vipNo.ToString())); } else { switchForm(new frmMainShopSimpleWithMoney(vipNo.ToString())); } AutoClosingMessageBox.Show("會員符合購肥補助資格"); } return; } string text2 = new UploadVerification().farmerInfo(dataTable.Rows[0]["IdNo"].ToString()); string[] strParameterArray2 = new string[4] { dataTable.Rows[0]["Name"].ToString(), dataTable.Rows[0]["IdNo"].ToString(), text, vipNo.ToString() }; DataTable dataTable2 = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, "SELECT * FROM hypos_CUST_RTL ", null, CommandOperationType.ExecuteReaderReturnDataTable); if (text2.Equals("符合補助資格")) { if (dataTable2.Rows.Count > 0) { DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_CUST_RTL SET Verification = 'Y', IdNo = {1}, LastVerificationTime = {2} WHERE VipNo = {3}", strParameterArray2, CommandOperationType.ExecuteNonQuery); } else { DataBaseUtilities.DBOperation(Program.ConnectionString, "INSERT INTO hypos_CUST_RTL ( Name, IdNo, Verification, LastVerificationTime) VALUES( {0}, {1}, 'Y', {2}) ", strParameterArray2, CommandOperationType.ExecuteNonQuery); } AutoClosingMessageBox.Show("驗證成功。"); } else if (text2.Equals("購肥帳號密碼驗證錯誤")) { AutoClosingMessageBox.Show("帳號密碼有誤,請重新確認您的帳號密碼。"); if (dataTable2.Rows.Count > 0) { DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_CUST_RTL SET Verification = 'N', IdNo = {1}, LastVerificationTime = {2} WHERE VipNo = {3} ", strParameterArray2, CommandOperationType.ExecuteNonQuery); } else { DataBaseUtilities.DBOperation(Program.ConnectionString, "INSERT INTO hypos_CUST_RTL ( Name, IdNo, Verification, LastVerificationTime) VALUES( {0}, {1}, 'N', {2}) ", strParameterArray2, CommandOperationType.ExecuteNonQuery); } } else if (text2.Equals("偵測不到網路連線,請確認網路正常後再使用檢查補助") && dataTable.Rows.Count > 0 && "Y".Equals(dataTable.Rows[0]["Verification"].ToString())) { AutoClosingMessageBox.Show("會員符合購肥補助資格"); } if (dialogResult == DialogResult.Yes) { if (Program.SystemMode == 1) { switchForm(new frmMainShopSimple(vipNo.ToString())); } else { switchForm(new frmMainShopSimpleWithMoney(vipNo.ToString())); } } } else if ("".Equals(dataTable.Rows[0]["IdNo"].ToString())) { if (dialogResult == DialogResult.Yes) { if (Program.SystemMode == 1) { switchForm(new frmMainShopSimple(vipNo.ToString())); } else { switchForm(new frmMainShopSimpleWithMoney(vipNo.ToString())); } } } else { AutoClosingMessageBox.Show("身分證字號錯誤"); } } }
private void btn_login_Click(object sender, EventArgs e) { if ("請輸入登入帳號".Equals(tb_account.Text) || "請輸入登入密碼".Equals(tb_password.Text)) { AutoClosingMessageBox.Show("請輸入登入帳號與密碼"); return; } DataTable dataTable = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Select, "*", "hypos_User", "Account = {0}", "", null, new string[1] { tb_account.Text }, CommandOperationType.ExecuteReaderReturnDataTable); if (dataTable.Rows.Count > 0) { if (int.Parse(dataTable.Rows[0]["Status"].ToString()) != 0) { AutoClosingMessageBox.Show("此帳號已被停用,請通知管理員"); } else if (dataTable.Rows[0]["Password"].ToString().Equals(tb_password.Text)) { DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_User set LastLogin = datetime('now') WHERE Account = {0}", new string[1] { tb_account.Text }, CommandOperationType.ExecuteNonQuery); AutoClosingMessageBox.Show("登入成功"); Program.Casher = tb_account.Text; Program.RoleType = int.Parse(dataTable.Rows[0]["Type"].ToString()); if (Program.IsFertilizer) { AutoClosingMessageBox.Show("驗證帳號密碼中"); string text = new UploadVerification().retailData(); if (text.Equals("驗證成功")) { Program.IsSaleOfFertilizer = true; } else if (text.Equals("購肥帳號密碼驗證錯誤")) { Program.IsSaleOfFertilizer = false; if (((DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, "SELECT * FROM hypos_ShopInfoManage", null, CommandOperationType.ExecuteReaderReturnDataTable)).Rows.Count > 0) { try { DataTable dataTable3 = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_ShopInfoManage SET FertilizerPassword = '' ", null, CommandOperationType.ExecuteScalar); } catch (Exception) { AutoClosingMessageBox.Show("購肥帳號密碼驗證錯誤,商家無法販賣介接肥料"); } } } else if (text.Equals("偵測不到網路連線,請確認網路正常後再選入商品")) { DataTable dataTable2 = (DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, "SELECT * FROM hypos_ShopInfoManage", null, CommandOperationType.ExecuteReaderReturnDataTable); if (dataTable2.Rows.Count > 0 && !dataTable2.Rows[0]["FertilizerAccount"].ToString().Equals("") && !dataTable2.Rows[0]["FertilizerPassword"].ToString().Equals("")) { Program.IsSaleOfFertilizer = true; } } } switchForm(new frmNews()); } else { AutoClosingMessageBox.Show("密碼不正確,請重新輸入"); } } else { AutoClosingMessageBox.Show("帳號不存在,請檢查您輸入的帳號"); } }
private void btn_repay_Click(object sender, EventArgs e) { if (_credit == 0) { AutoClosingMessageBox.Show("此會員目前無賒帳金額"); return; } if ("請輸入還款金額".Equals(tb_repay.Text)) { AutoClosingMessageBox.Show("請先輸入賒帳還款數字"); return; } int num = int.Parse(tb_repay.Text); string text = "0"; string text2 = "0"; string sql = ""; if (_credit <= num) { sql = "UPDATE hypos_CUST_RTL SET Credit={1} where VipNo={0} "; text2 = (num - _credit).ToString(); AutoClosingMessageBox.Show("賒帳還款「" + num + "」,還款後賒帳金額為"0",需找零"" + text2 + """); } if (_credit > num) { sql = "UPDATE hypos_CUST_RTL SET Credit=Credit+{1} where VipNo={0} "; text = (-num).ToString(); AutoClosingMessageBox.Show("賒帳還款「" + num + "」,還款後賒帳金額為"" + (_credit - num) + """); } DataBaseUtilities.DBOperation(Program.ConnectionString, sql, new string[2] { _vipNo, text }, CommandOperationType.ExecuteNonQuery); string text3 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string[,] strFieldArray = new string[7, 2] { { "memberId", _vipNo }, { "sellNo", "" }, { "editdate", text3 }, { "sellType", "2" }, { "Cash", text2 }, { "Credit", num.ToString() }, { "status", "0" } }; DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Insert, "", "hypos_user_consumelog", "", "", strFieldArray, null, CommandOperationType.ExecuteNonQuery); DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_CUST_RTL SET RepayDate = {1} WHERE VipNo = {0}", new string[2] { _vipNo, text3 }, CommandOperationType.ExecuteNonQuery); _frmEM.repayChange(); Hide(); _frmEM.Show(); }
private void btnUploadSysSN_Click(object sender, EventArgs e) { string text = ""; if (txtLicenseCode.Text == "請輸入販賣執照證號") { text += "請輸入販賣執照證號 \n"; } if (txtShopName.Text == "請輸入商家商業名稱") { text += "請輸入商家商業名稱"; } if (text != "") { AutoClosingMessageBox.Show(text); return; } string text2 = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff"); RegisterObject registerObject = new RegisterObject(); registerObject.license = txtLicenseCode.Text; registerObject.name = txtShopName.Text; registerObject.hddSerialId = Program.HardDiskSerialNo; registerObject.applyTime = text2; string text3 = Program.Encrypt(JsonConvert.SerializeObject(registerObject, Formatting.Indented)); string[,] strFieldArray = new string[5, 2] { { "RegisterCode", text3 }, { "LicenseCode", registerObject.license }, { "ShopName", registerObject.name }, { "HardDiskSerialNo", registerObject.hddSerialId }, { "CreateDate", text2 } }; DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Insert, "", "hypos_RegisterLicense", "", "", strFieldArray, null, CommandOperationType.ExecuteNonQuery); RegisterResultObject registerResultObject = ws.uploadApplySerial(text3); if (bool.Parse(registerResultObject.isSuccess)) { AutoClosingMessageBox.Show(registerResultObject.message); btnSubmit.Enabled = true; btnUploadSysSN.Enabled = false; btnReset.Enabled = false; txtLicenseCode.Enabled = false; txtShopName.Enabled = false; btnSubmit.BackColor = Color.FromArgb(0, 153, 204); RegisterCode = text3; } else { AutoClosingMessageBox.Show("上傳失敗:\n" + registerResultObject.message); } }
private void btnSubmit_Click(object sender, EventArgs e) { AuthResultObject authResultObject = ws.hasInUseFirst(RegisterCode); string[] strParameterArray = new string[2] { RegisterCode, DateTime.Now.ToString() }; if (bool.Parse(authResultObject.inUse)) { AutoClosingMessageBox.Show(authResultObject.message); Program.LincenseCode = txtLicenseCode.Text; Program.SiteNo = authResultObject.serial.PadLeft(2, '0'); Program.ShopType = authResultObject.shopType; DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_RegisterLicense SET isApproved = 'Y', ApproveDate = {1} where RegisterCode = {0} ", strParameterArray, CommandOperationType.ExecuteNonQuery); DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_SysParam SET SiteNo = {0} ", new string[1] { authResultObject.serial.PadLeft(2, '0') }, CommandOperationType.ExecuteNonQuery); if (!string.IsNullOrEmpty(Program.ShopType)) { string sql = "SELECT ShopIdNo FROM hypos_ShopInfoManage"; if (((DataTable)DataBaseUtilities.DBOperation(Program.ConnectionString, sql, null, CommandOperationType.ExecuteReaderReturnDataTable)).Rows.Count > 0) { if (Program.ShopType.Equals("0")) { DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_ShopInfoManage SET IsRetailer = {0}, IsWholesaler = {1} ", new string[2] { "ON", "ON" }, CommandOperationType.ExecuteNonQuery); } else if (Program.ShopType.Equals("1")) { DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_ShopInfoManage SET IsRetailer = {0}, IsWholesaler = {1} ", new string[2] { "ON", "OFF" }, CommandOperationType.ExecuteNonQuery); } else if (Program.ShopType.Equals("2")) { DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_ShopInfoManage SET IsRetailer = {0}, IsWholesaler = {1} ", new string[2] { "OFF", "ON" }, CommandOperationType.ExecuteNonQuery); } } else if (Program.ShopType.Equals("0")) { DataBaseUtilities.DBOperation(Program.ConnectionString, "INSERT INTO hypos_ShopInfoManage ( IsRetailer, IsWholesaler) VALUES( {0}, {1})", new string[2] { "ON", "ON" }, CommandOperationType.ExecuteNonQuery); } else if (Program.ShopType.Equals("1")) { DataBaseUtilities.DBOperation(Program.ConnectionString, "INSERT INTO hypos_ShopInfoManage ( IsRetailer, IsWholesaler) VALUES( {0}, {1}) ", new string[2] { "ON", "OFF" }, CommandOperationType.ExecuteNonQuery); } else if (Program.ShopType.Equals("2")) { DataBaseUtilities.DBOperation(Program.ConnectionString, "INSERT INTO hypos_ShopInfoManage ( IsRetailer, IsWholesaler) VALUES( {0}, {1}) ", new string[2] { "OFF", "ON" }, CommandOperationType.ExecuteNonQuery); } } new frmDownload(Program.LincenseCode, "").ShowDialog(); if (Program.IsDataTransfer) { string value = DataBaseUtilities.DBOperation(Program.ConnectionString, "SELECT SystemMode FROM hypos_SysParam", null, CommandOperationType.ExecuteScalar).ToString(); string value2 = DataBaseUtilities.DBOperation(Program.ConnectionString, "SELECT IsDataTransfer FROM hypos_SysParam", null, CommandOperationType.ExecuteScalar).ToString(); if (!"Y".Equals(value2) && "".Equals(value)) { frmDataTransfer frmDataTransfer = new frmDataTransfer(); frmDataTransfer.Location = new Point(base.Location.X, base.Location.Y); frmDataTransfer.ShowDialog(); if (File.Exists("C:\\Hypos\\Old_db.db3") && File.Exists("C:\\Hypos\\conn_log.txt")) { try { using (StreamReader streamReader = new StreamReader("C:\\\\Hypos\\\\conn_log.txt", Encoding.Unicode)) { string text = streamReader.ReadToEnd(); if ("1".Equals(text.Substring(0, 1))) { try { AutoBackupDT(); new dbDataTransfer().ShowDialog(); DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_SysParam SET IsDataTransfer = 'Y'", null, CommandOperationType.ExecuteNonQuery); } catch (Exception ex) { MessageBox.Show(string.Format("dbDataTransfer發生例外狀況:「{0}」", ex.ToString())); } } else if ("2".Equals(text.Substring(0, 1))) { DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_SysParam SET IsDataTransfer = 'Y'", null, CommandOperationType.ExecuteNonQuery); MessageBox.Show("舊POS資料移轉程序已取消"); } else { MessageBox.Show("舊POS系統資料匯入SQLite失敗。"); } } } catch (Exception ex2) { MessageBox.Show(string.Format("開啟紀錄檔發生例外狀況:「{0}」", ex2.ToString())); } } else if (File.Exists("C:\\Hypos\\conn_log.txt")) { try { using (StreamReader streamReader2 = new StreamReader("C:\\\\Hypos\\\\conn_log.txt", Encoding.Unicode)) { string text2 = streamReader2.ReadToEnd(); if (!"2".Equals(text2.Substring(0, 1))) { MessageBox.Show("移轉程序失敗並結束。"); return; } } } catch (Exception) { } } } } switchForm(new frmLogin()); } else { AutoClosingMessageBox.Show(authResultObject.message); if ("ERROR_BAN".Equals(authResultObject.errorCode) || "ERROR_UNUSE".Equals(authResultObject.errorCode) || "ERROR_EMPTY".Equals(authResultObject.errorCode)) { DataBaseUtilities.DBOperation(Program.ConnectionString, "UPDATE hypos_RegisterLicense SET isApproved = 'N', ApproveDate = {1} where RegisterCode = {0} ", strParameterArray, CommandOperationType.ExecuteNonQuery); btnSubmit.Enabled = false; btnUploadSysSN.Enabled = true; btnReset.Enabled = true; txtLicenseCode.Enabled = true; txtShopName.Enabled = true; btnSubmit.BackColor = Color.DimGray; } } }