private void memberLoadData(int pageNum) { 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(dpkMemberInsertSDTTM.Value.ToString()) && ckbMemberInsertDTTM.Checked) { vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.createSDTTM.ToString(), dpkMemberInsertSDTTM.Value.ToString("yyyy/MM/dd")); } if (!string.IsNullOrEmpty(dpkMemberInsertEDTTM.Value.ToString()) && ckbMemberInsertDTTM.Checked) { vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.createEDTTM.ToString(), dpkMemberInsertEDTTM.Value.ToString("yyyy/MM/dd")); } if (!string.IsNullOrEmpty(dpkMemberModifySDTTM.Value.ToString()) && ckbMemberModifyDTTM.Checked) { vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.modifySDTTM.ToString(), dpkMemberModifySDTTM.Value.ToString("yyyy/MM/dd")); } if (!string.IsNullOrEmpty(dpkMemberModifyEDTTM.Value.ToString()) && ckbMemberModifyDTTM.Checked) { vRoster.Conditions += " AND " + vRoster.getCondition(RosterInfo.ncConditions.modifyEDTTM.ToString(), dpkMemberModifyEDTTM.Value.ToString("yyyy/MM/dd")); } //組排序指令 if (dgvMember.SortedColumn is 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[6], dr.ItemArray[4], dr.ItemArray[5], dr.ItemArray[8], dr.ItemArray[10], dr.ItemArray[13] }); } }
private void inventoryLoadData(int pageNum) { int importTotal = 0, exportTotal = 0, itemTotal = 0, postTotal = 0, returnTotal = 0; dgvInventory.Rows.Clear(); DataGridViewRowCollection rows = dgvInventory.Rows; InventroyRPTInfo view = new InventroyRPTInfo(APConfig.Conn); view.Conditions = " 1=1 "; if (!string.IsNullOrEmpty(txtInventoryName.Text)) { view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.name.ToString(), txtInventoryName.Text); } if (!string.IsNullOrEmpty(txtInventoryCode.Text)) { view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.code.ToString(), txtInventoryCode.Text); } if (!string.IsNullOrEmpty(dpkInventoryINSDTTM.Value.ToString()) && ckbInventoryINDTTM.Checked) { view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.importSDTTM.ToString(), dpkInventoryINSDTTM.Value.ToString("yyyy/MM/dd")); } if (!string.IsNullOrEmpty(dpkInventoryINEDTTM.Value.ToString()) && ckbInventoryINDTTM.Checked) { view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.importEDTTM.ToString(), dpkInventoryINEDTTM.Value.ToString("yyyy/MM/dd")); } if (!string.IsNullOrEmpty(dpkInventoryOUTSDTTM.Value.ToString()) && ckbInventoryOUTDTTM.Checked) { view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.exportSDTTM.ToString(), dpkInventoryOUTSDTTM.Value.ToString("yyyy/MM/dd")); } if (!string.IsNullOrEmpty(dpkInventoryOUTEDTTM.Value.ToString()) && ckbInventoryOUTDTTM.Checked) { view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.exportEDTTM.ToString(), dpkInventoryOUTEDTTM.Value.ToString("yyyy/MM/dd")); } if (!string.IsNullOrEmpty(dpkInventoryPOSTSDTTM.Value.ToString()) && ckbInventoryPOSTDTTM.Checked) { view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.postSDTTM.ToString(), dpkInventoryPOSTSDTTM.Value.ToString("yyyy/MM/dd")); } if (!string.IsNullOrEmpty(dpkInventoryPOSTEDTTM.Value.ToString()) && ckbInventoryPOSTDTTM.Checked) { view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.postEDTTM.ToString(), dpkInventoryPOSTEDTTM.Value.ToString("yyyy/MM/dd")); } if (!string.IsNullOrEmpty(dpkInventoryRETURNSDTTM.Value.ToString()) && ckbInventoryRETURNDTTM.Checked) { view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.returnSDTTM.ToString(), dpkInventoryRETURNSDTTM.Value.ToString("yyyy/MM/dd")); } if (!string.IsNullOrEmpty(dpkInventoryRETURNEDTTM.Value.ToString()) && ckbInventoryRETURNDTTM.Checked) { view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.returnEDTTM.ToString(), dpkInventoryRETURNEDTTM.Value.ToString("yyyy/MM/dd")); } if (ddlInventoryDealer.SelectedIndex != 0) { view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.dealer.ToString(), ddlInventoryDealer.SelectedItem.ToString()); } if (ddlInventoryStatus.SelectedIndex != 0) { view.Conditions += " AND " + view.getCondition(InventroyRPTInfo.ncConditions.status.ToString(), ddlInventoryStatus.SelectedItem.ToString()); } view.condFormat(string.Format(" AND {0} ", view.Conditions)); //組排序指令 if (dgvInventory.SortedColumn is null) { view.OrderBy = view.getOptionOrderBy(RosterDial_RInfo.ncSort.Default.ToString()); } else { string sortname = dgvInventory.SortedColumn.Name; string sortmode = APConfig.GetValueFromDescription <SortMode>(dgvInventory.SortOrder.ToString()).ToString(); view.OrderBy = string.Format("{0} {1}", view.getOptionOrderBy(sortname), sortmode); } //查詢頁數初始化且自動跳轉至第一頁 if (pageNum == 0) { APConfig.loadPage(ddlInventoryPage, view.calculatePage(APConfig.PageCount)); return; } //塞入資料 DataSet ds = APConfig.GoPage(view.SQLStatement, pageNum); foreach (DataRow dr in ds.Tables[0].Rows) { rows.Add(new Object[] { dr.ItemArray[1], dr.ItemArray[0], dr.ItemArray[2], dr.ItemArray[3], dr.ItemArray[4], dr.ItemArray[5], dr.ItemArray[6] }); } //計算總合 if (view.load()) { while (!view.IsEof) { importTotal += view.INAMT; exportTotal += view.OUTAMT; postTotal += view.POSTAMT; returnTotal += view.RETURNAMT; itemTotal += Convert.ToInt32(view.ITEMTOTAL); view.next(); } } lblInventoryTotal.Text = string.Format("{0}", itemTotal.ToString()); lblInventoryINAMT.Text = string.Format("{0:n0} 元", importTotal); lblInventoryOUTAMT.Text = string.Format("{0:n0} 元", exportTotal); lblInventoryPOSTAMT.Text = string.Format("{0:n0} 元", postTotal); lblInventoryRETURNAMT.Text = string.Format("{0:n0} 元", returnTotal); }
private void saleLoadData(int pageNum) { int total = 0; dgvSale.Rows.Clear(); DataGridViewRowCollection rows = dgvSale.Rows; RosterDial_RInfo view = new RosterDial_RInfo(APConfig.Conn); view.Conditions = " 1=1 "; if (!string.IsNullOrEmpty(txtSaleItem.Text)) { view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.item.ToString(), txtSaleItem.Text); } if (!string.IsNullOrEmpty(txtSaleMain.Text)) { view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.main.ToString(), txtSaleMain.Text); } if (!string.IsNullOrEmpty(txtSaleName.Text)) { view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.name.ToString(), txtSaleName.Text); } if (!string.IsNullOrEmpty(txtSaleComment.Text)) { view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.comment.ToString(), txtSaleComment.Text); } //if (!string.IsNullOrEmpty(dpkSaleInsertSDTTM.Value.ToString()) && ckbSaleInsertDTTM.Checked) // view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.createSDTTM.ToString(), dpkSaleInsertSDTTM.Value.ToString("yyyy/MM/dd")); //if (!string.IsNullOrEmpty(dpkSaleInsertSDTTM.Value.ToString()) && ckbSaleInsertDTTM.Checked) // view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.createEDTTM.ToString(), dpkSaleInsertSDTTM.Value.ToString("yyyy/MM/dd")); if (!string.IsNullOrEmpty(dpkSaleModifySDTTM.Value.ToString()) && ckbSaleModifyDTTM.Checked) { view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.modifySDTTM.ToString(), dpkSaleModifySDTTM.Value.ToString("yyyy/MM/dd")); } if (!string.IsNullOrEmpty(dpkSaleModifyEDTTM.Value.ToString()) && ckbSaleModifyDTTM.Checked) { view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.modifyEDTTM.ToString(), dpkSaleModifyEDTTM.Value.ToString("yyyy/MM/dd")); } if (!string.IsNullOrEmpty(dpkSaleDealSDTTM.Value.ToString()) && ckbSaleDealDTTM.Checked) { view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.dealSDTTM.ToString(), dpkSaleDealSDTTM.Value.ToString("yyyy/MM/dd")); } if (!string.IsNullOrEmpty(dpkSaleDealEDTTM.Value.ToString()) && ckbSaleDealDTTM.Checked) { view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.dealEDTTM.ToString(), dpkSaleDealEDTTM.Value.ToString("yyyy/MM/dd")); } if (ddlSaleDealer.SelectedIndex != 0) { view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.dealer.ToString(), ddlSaleDealer.SelectedItem.ToString()); } if (ddlSaleStatus.SelectedIndex != 0) { view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.status.ToString(), ddlSaleStatus.SelectedItem.ToString()); } if (ddlSaleType.SelectedIndex != 0) { if (ddlSaleType.SelectedItem.ToString() == "銷貨淨值") //Harsh Code { view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.typelist.ToString(), " '銷貨收入','銷貨折扣'"); } else { view.Conditions += " AND " + view.getCondition(RosterDial_RInfo.ncConditions.type.ToString(), ddlSaleType.SelectedItem.ToString()); } } //組排序指令 if (dgvSale.SortedColumn is null) { view.OrderBy = view.getOptionOrderBy(RosterDial_RInfo.ncSort.Default.ToString()); } else { string sortname = dgvSale.SortedColumn.Name; string sortmode = APConfig.GetValueFromDescription <SortMode>(dgvSale.SortOrder.ToString()).ToString(); view.OrderBy = string.Format("{0} {1}", view.getOptionOrderBy(sortname), sortmode); } //查詢頁數初始化且自動跳轉至第一頁 if (pageNum == 0) { APConfig.loadPage(ddlSalePage, view.calculatePage(APConfig.PageCount)); return; } //計算總合 if (view.load()) { while (!view.IsEof) { total += int.Parse(view.RSD_AMOUNT); view.next(); } } //塞入資料 DataSet ds = APConfig.GoPage(view.SQLStatement, pageNum); foreach (DataRow dr in ds.Tables[0].Rows) { rows.Add(new Object[] { dr.ItemArray[0], dr.ItemArray[14], dr.ItemArray[13], dr.ItemArray[1], dr.ItemArray[2], dr.ItemArray[3], dr.ItemArray[6], dr.ItemArray[4], dr.ItemArray[5], dr.ItemArray[7], dr.ItemArray[10] }); } lblSaleTotal.Text = view.calculateCount().ToString(); lblSaleTotalAmount.Text = string.Format("{0:n0} 元", total); }