private void ItemSearch() { dgvItem.Rows.Clear(); DataGridViewRowCollection rows = dgvItem.Rows; InventoryInfo view = new InventoryInfo(APConfig.Conn); int totalamount = 0; view.Conditions = " 1=1 "; view.Conditions += " AND " + view.getCondition(InventoryInfo.ncConditions.status.ToString(), InventoryStatus.寄庫品.ToString()); if (!string.IsNullOrEmpty(txtName.Text)) { view.Conditions += " AND " + view.getCondition(InventoryInfo.ncConditions.LKname.ToString(), txtName.Text); } if (!string.IsNullOrEmpty(sernolist)) { view.Conditions += " AND " + view.getCondition(InventoryInfo.ncConditions.NINsernolist.ToString(), sernolist); } view.OrderBy = view.getOptionOrderBy(InventoryInfo.ncOrderBy.ODBname.ToString()); view.load(); while (!view.IsEof) { rows.Add(new Object[] { view.INV_SERNO, view.INV_NAME, view.INV_POSTAMT, view.INV_POSTDTTM.ToShortDateString() }); totalamount += view.INV_POSTAMT; view.next(); } lblTotalCount.Text = string.Format("總件數:{0}", view.calculateCount()); lblTotalAmt.Text = string.Format("總金額:{0}", totalamount); }
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 = "出貨日期無法小於進貨日期!"; } //條碼不行重複!!!! InventoryInfo view = new InventoryInfo(APConfig.Conn); view.Conditions = " 1=1 "; view.Conditions += " AND " + view.getCondition(InventoryInfo.ncConditions.status.ToString(), InventoryStatus.已出貨.ToString()); view.Conditions += " AND " + view.getCondition(InventoryInfo.ncConditions.code.ToString(), txtCode.Text); if (view.calculateCount() > 0) { msg = "該條碼已經被使用!"; } foreach (DataGridViewRow row in dgvItem.Rows) { if (txtCode.Text == row.Cells["dgvItem_Code"].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, txtImportAmount.Text, txtExportAmount.Text, ddlDealer.SelectedItem.ToString(), dpkExportDTTM.Value.ToShortDateString(), txtExportComment.Text }); clearTextBox(); loadTotalAmount(); }
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(txtCode.Text)) { msg = "請輸入商品代碼"; } else if (string.IsNullOrEmpty(txtName.Text)) { msg = "請輸入商品名稱"; } //進階判斷 if (string.IsNullOrEmpty(msg)) { //條碼不行重複!!!! InventoryInfo view = new InventoryInfo(APConfig.Conn); view.Conditions = " 1=1 "; view.Conditions += " AND " + view.getCondition(InventoryInfo.ncConditions.code.ToString(), txtCode.Text); if (view.calculateCount() > 0) { msg = "該條碼已經被使用!"; } foreach (DataGridViewRow row in dgvItem.Rows) { if (txtCode.Text == row.Cells["dgvItem_Code"].Value.ToString()) { msg = "該條碼已經被使用!"; break; } else if (!string.IsNullOrEmpty(postSerno) && postSerno == 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[] { postSerno, txtCode.Text, txtName.Text, txtAmount.Text, dpkImportDTTM.Value.ToShortDateString(), txtComment.Text }); postSerno = ""; clearPage(); loadTotalAmount(); loadRowColor(); }