private void FinanceReport_Load(object sender, EventArgs e) { Supplier supplier = new Supplier(); supplier.LoadAll(); lkSupplier.Properties.DataSource = supplier.DefaultView; lkAccount.SetupActivityEditor().SetDefaultActivity(); LoadStatusGrid(); }
private void PopulateFields() { // Bind the lookups first ABC abc = new ABC(); abc.LoadAll(); radioGroupABC.Properties.Items.Clear(); while(!abc.EOF){ radioGroupABC.Properties.Items.Add(new RadioGroupItem(abc.ID, abc.Description)); abc.MoveNext(); } radioGroupVEN.Properties.Items.Clear(); VEN ven = new VEN(); ven.LoadAll(); while (!ven.EOF) { radioGroupVEN.Properties.Items.Add(new RadioGroupItem(ven.ID, ven.Description)); ven.MoveNext(); } if(itemId != 0) { Item itm = new Item(); //itm.LoadByPrimaryKey(itemId); DataTable dtItem = itm.GetItemById(itemId); txtItemName.Text = itm.FullItemName;//String.Format("{0} - {1} - {2}", dtItem.Rows[0]["ItemName"], dtItem.Rows[0]["DosageForm"], dtItem.Rows[0]["Strength"]); ckExculed.Checked = (!itm.IsColumnNull("IsInHospitalList"))?itm.IsInHospitalList:false; chkProcessDecimal.Checked = (!itm.IsColumnNull("ProcessInDecimal")) ? itm.ProcessInDecimal : false; if (!itm.IsColumnNull("ABCID")) { radioGroupABC.EditValue = itm.GetColumn("ABCID"); } if (!itm.IsColumnNull("VENID")) { radioGroupVEN.EditValue = itm.GetColumn("VENID"); } Supplier sup = new Supplier(); sup.LoadAll(); ItemSupplier itmSup = new ItemSupplier(); itmSup.GetSuppliersAndMarkThoseUsed(itemId); while(!itmSup.EOF) { lstSuppliers.Items.Add(itmSup.GetColumn("CompanyName"),Convert.ToBoolean(itmSup.GetColumn("IsUsed"))); itmSup.MoveNext(); } BLL.Program prog = new BLL.Program(); prog.GetSubPrograms(); ItemProgram progItem = new ItemProgram(); lstPrograms.Items.Clear(); foreach (DataRowView dv in prog.DefaultView) { bool check = false; check = progItem.CheckIfExists(itemId,Convert.ToInt32(dv["ID"])); lstPrograms.Items.Add(dv["Name"],check); } } }
private object GetForPrint(DataView dv) { DataTable dtbl = dv.Table.Clone(); dtbl.Columns.Add("Supplier"); dtbl.Clear(); foreach (DataRowView drv in dv) { if (dtbl.Rows.Count == 0) { dtbl.ImportRow(drv.Row); } else { //check if items with same expiry esists in the table DataRow[] ar = dtbl.Select(string.Format("ItemID={0} and BatchNumber='{1}' and UnitPrice = {2}", drv["ItemID"], drv["BatchNumber"], drv["UnitPrice"])); if (ar.Length > 0) { ar[0]["SKUPICKED"] = Convert.ToInt32(ar[0]["SKUPICKED"]) + Convert.ToInt32(drv["SKUPICKED"]); ar[0]["Cost"] = Convert.ToInt32(ar[0]["Cost"]) + Convert.ToInt32(drv["Cost"]); ar[0].EndEdit(); } else { dtbl.ImportRow(drv.Row); } } } Supplier supplier = new Supplier(); ReceiveDoc rd = new ReceiveDoc(); foreach (DataRow drw in dtbl.Rows) { rd.LoadByPrimaryKey(Convert.ToInt32(drw["ReceiveDocID"])); if (rd.RowCount > 0) { supplier.LoadByPrimaryKey(rd.SupplierID); drw["Supplier"] = supplier.CompanyName; drw.EndEdit(); } } return dtbl; }
/// <summary> /// Load the lookups and Prepare the form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditReceive_Load(object sender, EventArgs e) { lkItemUnit.Enabled = VisibilitySetting.HandleUnits != 1; var str = new Stores(); str.LoadAll(); cboStores.DataSource = str.DefaultView; var sup = new Supplier(); sup.GetActiveSuppliers(); cboSupplier.DataSource = sup.DefaultView; if(_tranId != 0) { var rec = new ReceiveDoc(); var itm = new Items(); rec.LoadByPrimaryKey(_tranId); var dtItm = itm.GetItemById(rec.ItemID); var units = new ItemUnit(); var unit = units.LoadFromSQl(rec.ItemID); lkItemUnit.Properties.DataSource = unit; lkItemUnit.Properties.DisplayMember = "Text"; lkItemUnit.Properties.ValueMember = "ID"; var programs = new Programs(); var allprograms = programs.GetSubPrograms(); lkPrograms.Properties.DataSource = allprograms; lkPrograms.Properties.ValueMember = "ID"; lkPrograms.Properties.DisplayMember = "Name"; string itemName = dtItm.Rows[0]["ItemName"].ToString() + " - " + dtItm.Rows[0]["DosageForm"].ToString() + " - " + dtItm.Rows[0]["Strength"].ToString(); txtRefNo.Text = rec.RefNo; txtBatchNo.Text = rec.BatchNo; try { txtPack.Text = rec.NoOfPack.ToString(); txtQtyPack.Text =rec.QtyPerPack.ToString(); txtPrice.Text = (rec.Cost * rec.QtyPerPack).ToString(); //txtQuantityLeft.Text = rec.QuantityLeft.ToString(); } catch { txtPack.Text = "0"; txtQtyPack.Text = "0"; txtPrice.Text = (rec.Cost * 1).ToString(); } txtQuantity.Text = rec.Quantity.ToString(); lkPrograms.EditValue = rec.SubProgramID; DateTime dtDate = Convert.ToDateTime(rec.Date.ToString("MM/dd/yyyy")); txtDate.Text = dtDate.ToShortDateString(); dtRecDate.Value = DateTime.Now; dtRecDate.CustomFormat = "MM/dd/yyyy"; if (!rec.IsColumnNull("ExpDate")) dtExpiryDate.Value = rec.ExpDate; cboStores.SelectedValue = rec.StoreID; cboSupplier.SelectedValue = rec.SupplierID; if (!rec.IsColumnNull("UnitID")) lkItemUnit.EditValue = rec.UnitID; txtItemName.Text = itemName; txtReceivedBy.Text = rec.ReceivedBy; txtRemark.Text = rec.Remark; } }
/// <summary> /// Load the drop downs and tables /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void HospitalSettings_Load(object sender, EventArgs e) { Supplier sup = new Supplier(); sup.LoadAll(); PopulateSupplier(sup); Stores str = new Stores(); str.LoadAll(); PopulateStores(str); Shelf slf = new Shelf(); DataTable dtSlf = slf.GetShelves(); PopulateShelves(dtSlf.DefaultView); ReceivingUnits recUnit = new ReceivingUnits(); recUnit.LoadAll(); PopulateReceivingUnit(recUnit); DataTable dtdumin = new DataTable(); dtdumin.Columns.Add("Value"); dtdumin.Columns.Add("Month"); object[] objdumin01 = { 0.25, "1 Weeks" }; dtdumin.Rows.Add(objdumin01); object[] objdumin0 = { 0.5, "2 Weeks" }; dtdumin.Rows.Add(objdumin0); object[] objdumin1 = { 0.75, ("3 Weeks") }; dtdumin.Rows.Add(objdumin1); object[] objdumin2 = { 1, (1 + " Month") }; dtdumin.Rows.Add(objdumin2); object[] objdumin3 = { 2, (2 + " Month") }; dtdumin.Rows.Add(objdumin3); cboDUMin.DataSource = dtdumin; DataTable dtdumax = new DataTable(); dtdumax.Columns.Add("Value"); dtdumax.Columns.Add("Month"); object[] objdumax01 = { 0.25, "1 Weeks" }; dtdumax.Rows.Add(objdumax01); object[] objdumax010 = { 0.5, "2 Weeks" }; dtdumax.Rows.Add(objdumax010); object[] objdumax011 = { 0.75, ("3 Weeks") }; dtdumax.Rows.Add(objdumax011); object[] objdumax012 = { 1, (1 + " Month") }; dtdumax.Rows.Add(objdumax012); object[] objdumax013 = { 2, (2 + " Month") }; dtdumax.Rows.Add(objdumax013); cboDUMax.DataSource = dtdumax; }
private void viewSupplies_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { DataRow dr = viewSupplies.GetFocusedDataRow(); if (dr != null) { int selected = Convert.ToInt32(dr["ID"]); Supplier sup = new Supplier(); sup.LoadByPrimaryKey(selected); txtCompanyName.Text = sup.CompanyName; txtAddress.Text = sup.Address; txtContactPerson.Text = sup.ContactPerson; txtMobile.Text = sup.Mobile; txtTelephone.Text = sup.Telephone; txtEmail.Text = sup.Email; ckIsActive.Checked = sup.IsColumnNull("IsActive")?false: sup.IsActive; _supplierId = sup.ID; cboCompanyInfo.SelectedItem = sup.CompanyInfo; btnSupplierSave.Text = "Update"; } }
/// <summary> /// Populates the fields based on the supplied itemID or categoryID /// </summary> private void PopulateFields() { if (_itemId == 0) return; Items itm = new Items(); DataTable dtItem = itm.GetItemById(_itemId); txtItemName.Text = dtItem.Rows[0]["ItemName"].ToString() + " - " + dtItem.Rows[0]["DosageForm"].ToString() + " - " + dtItem.Rows[0]["Strength"].ToString(); ckExculed.Checked =itm.IsInHospitalList; chkNeedExpiryBatch.Checked = itm.NeedExpiryBatch; txtText.Text = itm.StockCodeDACA ?? string.Empty; txtQuantityPerPack.Text = itm.Cost ?? string.Empty; try { if (dtItem.Rows[0]["ABC"].ToString() == "A") rdA.Checked = true; else if (dtItem.Rows[0]["ABC"].ToString() == "B") rdB.Checked = true; else if (dtItem.Rows[0]["ABC"].ToString() == "C") rdC.Checked = true; } catch { } try { if (dtItem.Rows[0]["VEN"].ToString() == "V") rdV.Checked = true; else if (dtItem.Rows[0]["VEN"].ToString() == "E") rdE.Checked = true; else if (dtItem.Rows[0]["VEN"].ToString() == "N") rdN.Checked = true; } catch { } //ItemShelf itmShelf = new ItemShelf(); //DataTable dtSlf = itmShelf.GetLocationByItem(itm.ID); //lstBinLocation.DataSource = dtSlf; var unit = new ItemUnit(); var itemunits= unit.LoadFromSQl(_itemId); itemunitbindingSource.DataSource = itemunits; if (VisibilitySetting.HandleUnits == 2) { listBox1.Visible = true; } else if(VisibilitySetting.HandleUnits == 3) { listBox1.Visible = true; } else if(VisibilitySetting.HandleUnits == 1) { listBox1.Hide(); } Supplier sup = new Supplier(); sup.GetActiveSuppliers(); ItemSupplier itmSup = new ItemSupplier(); itm.GetItemsBySupplier(_itemId); foreach (DataRowView dv in sup.DefaultView) { bool check = false; check = itmSup.CheckIfExist(_itemId, Convert.ToInt32(dv["ID"])); object obj = dv["CompanyName"]; lstSuppliers.Items.Add(obj, check); } Programs prog = new Programs(); prog.GetSubPrograms(); ProgramProduct progItem = new ProgramProduct(); lstPrograms.Items.Clear(); foreach (DataRowView dv in prog.DefaultView) { bool check = false; check = progItem.CheckIfExists(_itemId, Convert.ToInt32(dv["ID"])); lstPrograms.Items.Add(dv["Name"], check); } ReceivingUnits dus = new ReceivingUnits(); dus.GetActiveDispensaries(); lstDUs.Items.Clear(); DUsItemList duItem = new DUsItemList(); foreach (DataRowView drDus in dus.DefaultView) { bool check = false; check = duItem.CheckIfExsits(_itemId, Convert.ToInt32(drDus["ID"])); lstDUs.Items.Add(drDus["Name"], check); } }
private int SaveRelevantReceiptHeaders(int receiptTypeID, int warehouseID) { int receiptID; var receipt = new BLL.Receipt(); var sup = new BLL.Supplier(); if (lkReceiptInvoice.EditValue != null && Convert.ToInt32(lkReceiptInvoice.EditValue) != -1) { receiptID = receipt.AddNewReceipt(receiptTypeID, warehouseID, CurrentContext.UserId, Convert.ToInt32(lkReceiptInvoice.EditValue), txtEditTransferNo.Text, ReceiptConfirmationStatus.Constants.RECEIVE_ENTERED); // , txtTransitNo.Text, txtInsuranceNo.Text, txtWayBillNo.Text); } else { //PO and ReceiptInvoice created automatically. //Needs to be fixed. BLL.PO po = new PO(); BLL.ReceiptInvoice rctInvoice = new ReceiptInvoice(); po.AddNew(); var serverDateTime = DateTimeHelper.ServerDateTime; po.PODate = serverDateTime; po.DateOfEntry = serverDateTime; po.PurchaseType = POType.INVENTORY; po.IsElectronic = false; po.POFinalized = false; po.Rowguid = Guid.NewGuid(); po.Identifier = "00000"; po.PaymentTypeID = BLL.PaymentType.Constants.STV; po.TermOfPayement = BLL.PaymentTerm.Internal; po.PurchaseOrderStatusID = PurchaseOrderStatus.Processed; rctInvoice.AddNew(); po.StoreID = Convert.ToInt32(lkAccounts.EditValue); Activity acc = new Activity(); acc.LoadByPrimaryKey(po.StoreID); po.ModeID = acc.ModeID; //po.PONumber = srm ? lkSTVInvoiceNo.EditValue.ToString() : (deliveryNote ? txtRefNo.Text : (beginningBalance ? "BeginningBalance" : String.Empty)); if (lcSTVNo.Visibility == DevExpress.XtraLayout.Utils.LayoutVisibility.Always) { po.PONumber = srm && !chkSRMForOldSystemIssues.Checked ? txtSTVNo.Text : ((deliveryNoteType != DeliveryNoteType.NotSet) ? txtSTVNo.Text : (beginningBalance ? "BeginningBalance" : (srm && chkSRMForOldSystemIssues.Checked ? txtSTVInvoiceNoOldSystem.Text : txtRefNo.Text))); } else { po.PONumber = srm && !chkSRMForOldSystemIssues.Checked ? lkSTVInvoiceNo.Text : ((deliveryNoteType != DeliveryNoteType.NotSet) ? txtRefNo.Text : (beginningBalance ? "BeginningBalance" : (srm && chkSRMForOldSystemIssues.Checked ? txtSTVInvoiceNoOldSystem.Text : txtRefNo.Text))); } //TODO: Ugly hack, supplier. To be fixed. if (srm) { po.SupplierID = BLL.Supplier.CONSTANTS.RETURNED_FROM_FACILITY; //Let's put Finance Required stuff here. po.Insurance = 0; po.ExhangeRate = 1; rctInvoice.ExchangeRate = 1; rctInvoice.Insurance = 0; rctInvoice.InvoiceTypeID = ReceiptInvoiceType.InvoiceType.LOCAL_PURCHASE; if (chkSRMForOldSystemIssues.Checked) { if (lkForFacility.EditValue == null) throw new Exception("Facility not chosen!"); po.RefNo = lkForFacility.EditValue.ToString(); } } po.SavedbyUserID = CurrentContext.LoggedInUser.ID; po.Save(); rctInvoice.POID = po.ID; if (lcSTVNo.Visibility == DevExpress.XtraLayout.Utils.LayoutVisibility.Always) { rctInvoice.STVOrInvoiceNo = srm && !chkSRMForOldSystemIssues.Checked ? txtSTVNo.Text : ((deliveryNoteType != DeliveryNoteType.NotSet) ? txtSTVNo.Text : (beginningBalance ? "BeginningBalance" : (srm && chkSRMForOldSystemIssues.Checked ? txtSTVInvoiceNoOldSystem.Text : txtSTVNo.Text))); } else { rctInvoice.STVOrInvoiceNo = srm && !chkSRMForOldSystemIssues.Checked ? lkSTVInvoiceNo.Text : ((deliveryNoteType != DeliveryNoteType.NotSet) ? txtRefNo.Text : (beginningBalance ? "BeginningBalance" : (srm && chkSRMForOldSystemIssues.Checked ? txtSTVInvoiceNoOldSystem.Text : txtRefNo.Text))); } rctInvoice.DateOfEntry = DateTimeHelper.ServerDateTime; rctInvoice.ActivityID = po.StoreID; rctInvoice.SavedByUserID = CurrentContext.LoggedInUser.ID; rctInvoice.IsDeliveryNote = false; rctInvoice.Rowguid = Guid.NewGuid(); rctInvoice.PrintedDate = po.DateOfEntry; rctInvoice.IsVoided = false; rctInvoice.ShippingSite = " "; rctInvoice.IsConvertedFromDeliveryNote = false; rctInvoice.IsDeliveryNote = false; rctInvoice.DocumentTypeID = DocumentType.CONSTANTS.SRM; rctInvoice.Save(); receiptID = receipt.AddNewReceipt(receiptTypeID, warehouseID, CurrentContext.UserId, rctInvoice.ID, txtTransitTransferVoucherNo.Text, ReceiptConfirmationStatus.Constants.RECEIVE_ENTERED); //receiptID = receipt.AddNewReceipt(receiptTypeID, NewMainWindow.UserId); } return receiptID; }
/* private void GenerateBinCard() { ReceiveDoc rec = new ReceiveDoc(); IssueDoc iss = new IssueDoc(); Disposal dis = new Disposal(); DisposalReasons res = new DisposalReasons(); Balance bal = new Balance(); GeneralInfo info = new GeneralInfo(); YearEnd yEnd = new YearEnd(); Items itm = new Items(); info.LoadAll(); year = Convert.ToInt32(cboYear.SelectedItem); DataTable dtRec = rec.GetAllTransaction(itemId,storeId,dtCurrent.Month,year); DataTable dtIss = iss.GetTransactionByItemId(storeId, itemId, year); DataTable dtDis = dis.GetTransactionByItemId(storeId, itemId, year); Int64[] cStockout = { 0, 0, 0 }; Int64[] cOverStock = { 0, 0, 0 }; Int64[] cNearStockOut = { 0, 0, 0 }; Int64[] cBelowMin = { 0, 0, 0 }; //DateTime dtThree = dtCurrent.AddMonths(3); DataTable dtbin = new DataTable(); string[] col = { "Date", "Ref. No", "Receive", "Issue", "Unit Price", "Balance", "Batch No", "Expiry Date","To / From"}; foreach (string str in col) { dtbin.Columns.Add(str); } int i = 0; Int64 bBalance = 0; dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; dtCurrent = ConvertDate.DateConverter(dtDate.Text); bBalance = yEnd.GetBBalance(year, storeId, itemId,dtCurrent.Month); Int64 balanceAmount = bBalance; Int64 mincon = 0; Int64 maxcon = 0; double eopcon = 0; DateTime dtT = new DateTime(); string balanceAm = ""; txtBBalance.Text = bBalance.ToString(); string ddDate = ""; string batNo = ""; foreach (DataRow dvRec in dtRec.Rows) { i++; if (Convert.ToInt32(dvRec["Transact"]) == 1) { rec.LoadByPrimaryKey(Convert.ToInt32(dvRec["ID"])); balanceAmount = balanceAmount + Convert.ToInt64(dvRec["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; itm.LoadByPrimaryKey(rec.ItemID); if (itm.NeedExpiryBatch) { ddDate = rec.ExpDate.ToString("MMM dd,yyyy"); batNo = rec.BatchNo; } Supplier sup = new Supplier(); sup.LoadByPrimaryKey(rec.SupplierID); object[] obj = { Convert.ToDateTime(dvRec["Date"]).ToString("MM dd,yyyy"), dvRec["RefNo"], Convert.ToInt64(dvRec["Quantity"]).ToString("#,###"), "", Convert.ToDouble(dvRec["Cost"]).ToString("C"), balanceAm, batNo, ddDate, sup.CompanyName}; dtbin.Rows.Add(obj); //For stock Out dtT = Convert.ToDateTime(dvRec["Date"]); //int monb = (dtT.Month < 11) ? dtT.Month + 2 : ((dtT.Month == 11) ? 1 : 2); //int yer = (dtT.Month < 11) ? dtT.Year : dtT.Year - 1; Int64 bBal = bal.GetSOH(itemId, storeId, dtT.Month, dtT.Year); Int64 bAmc = bal.CalculateAMC(itemId, storeId, dtT.Month, dtT.Year); mincon = bAmc * info.Min; maxcon = bAmc * info.Max; eopcon = bAmc * info.EOP; if (balanceAmount == 0) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cStockout[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cStockout[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cStockout[2]++; } } else if (balanceAmount > maxcon) { //For Over stock if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cOverStock[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cOverStock[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cOverStock[2]++; } }//For Below min else if (balanceAmount > eopcon && balanceAmount <= mincon) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cBelowMin[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cBelowMin[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cBelowMin[2]++; } } else if (balanceAmount > 0 && balanceAmount < eopcon) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cNearStockOut[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cNearStockOut[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cNearStockOut[2]++; } } }else if(Convert.ToInt32(dvRec["Transact"]) == 0) { //DateTime dteIss = Convert.ToDateTime(drIss["Date"]); //DateTime dteRec = Convert.ToDateTime(dvRec["Date"]); //DateTime dTomorow = new DateTime(dtCurrent.Year, dtCurrent.Month, dtCurrent.Day + 1); //DateTime dteNextRec = (i <= dtRec.Rows.Count - 1) ? Convert.ToDateTime(dtRec.Rows[i]["Date"]) : dTomorow; iss.LoadByPrimaryKey(Convert.ToInt32(dvRec["ID"])); try { rec.LoadByPrimaryKey(iss.RecievDocID); } catch { rec.GetTransactionByBatch(itemId, dvRec["BatchNo"].ToString(), storeId); } ReceivingUnits recUnit = new ReceivingUnits(); recUnit.LoadByPrimaryKey(iss.ReceivingUnitID); string issuedTo = recUnit.Name; balanceAmount = balanceAmount - Convert.ToInt64(dvRec["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; itm.LoadByPrimaryKey(iss.ItemID); if (itm.NeedExpiryBatch) { ddDate = ((rec.RowCount > 0) ? rec.ExpDate.ToString("MMM dd,yyyy") : ""); ; batNo = dvRec["BatchNo"].ToString(); //rec.BatchNo; } else { ddDate = ""; batNo = ""; } object[] obj = { Convert.ToDateTime(dvRec["Date"]).ToString("MM dd,yyyy"), dvRec["RefNo"], "", Convert.ToInt64(dvRec["Quantity"]).ToString("#,###"), Convert.ToDouble(dvRec["Cost"]).ToString("C"), balanceAm,batNo, ddDate,issuedTo}; dtbin.Rows.Add(obj); //For stock Out dtT = Convert.ToDateTime(dvRec["Date"]); //int monb1 = (dtT.Month < 11) ? dtT.Month + 2 : ((dtT.Month == 11) ? 1 : 2); //int yer1 = (dtT.Month < 11) ? dtT.Year : dtT.Year - 1; Int64 bBal = bal.GetSOH(itemId, storeId, dtT.Month, dtT.Year); Int64 bAmc = bal.CalculateAMC(itemId, storeId, dtT.Month, dtT.Year); mincon = bAmc * info.Min; maxcon = bAmc * info.Max; eopcon = bAmc * info.EOP; if (balanceAmount == 0) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cStockout[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cStockout[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cStockout[2]++; } } else if (balanceAmount > maxcon) { //For Over stock if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cOverStock[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cOverStock[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cOverStock[2]++; } }//For Below min else if (balanceAmount > eopcon && balanceAmount <= mincon) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cBelowMin[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cBelowMin[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cBelowMin[2]++; } } else if (balanceAmount > 0 && balanceAmount < eopcon) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cNearStockOut[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cNearStockOut[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cNearStockOut[2]++; } } } foreach (DataRow drDis in dtDis.Rows) { DateTime dteDis = Convert.ToDateTime(drDis["Date"]); DateTime dteRec = Convert.ToDateTime(dvRec["Date"]); res.LoadByPrimaryKey(Convert.ToInt32(drDis["ReasonId"])); rec.GetTransactionByBatch(itemId,drDis["BatchNo"].ToString(),storeId); DateTime dteNextRec = (i <= dtRec.Rows.Count - 1) ? Convert.ToDateTime(dtRec.Rows[i]["Date"]) : dtCurrent; if ((dteRec <= dteDis) && (dteDis < dteNextRec)) { if (Convert.ToBoolean(drDis["Losses"])) { balanceAmount = balanceAmount - Convert.ToInt64(drDis["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; object[] objIss = { Convert.ToDateTime(drDis["Date"]).ToString("MM dd,yyyy"), drDis["RefNo"], "", Convert.ToInt64(drDis["Quantity"]).ToString("#,###"), Convert.ToDouble(drDis["Cost"]).ToString("C"), balanceAm, drDis["BatchNo"], rec.ExpDate.ToString("MMM dd,yyyy"), res.Reason}; dtbin.Rows.Add(objIss); } else { balanceAmount = balanceAmount + Convert.ToInt64(drDis["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; object[] objIss2 = { Convert.ToDateTime(drDis["Date"]).ToString("MM dd,yyyy"), drDis["RefNo"], Convert.ToInt64(drDis["Quantity"]).ToString("#,###"), "", Convert.ToDouble(drDis["Cost"]).ToString("C"), balanceAm, drDis["BatchNo"], rec.ExpDate.ToString("MMM dd,yyyy"), res.Reason}; dtbin.Rows.Add(objIss2); } dtT = Convert.ToDateTime(dvRec["Date"]); Int64 bAmc = bal.CalculateAMC(itemId, storeId, dtT.Month, dtT.Year); mincon = bAmc * info.Min; maxcon = bAmc * info.Max; eopcon = bAmc * info.EOP; if (balanceAmount == 0) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cStockout[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cStockout[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cStockout[2]++; } } else if (balanceAmount > maxcon) { //For Over stock if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cOverStock[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cOverStock[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cOverStock[2]++; } }//For Below min else if (balanceAmount > eopcon && balanceAmount <= mincon) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cBelowMin[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cBelowMin[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cBelowMin[2]++; } } else if (balanceAmount > 0 && balanceAmount < eopcon) { if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(90))) { cNearStockOut[0]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(180))) { cNearStockOut[1]++; } else if (Convert.ToDateTime(dvRec["Date"]) <= dtCurrent && Convert.ToDateTime(dvRec["Date"]) >= dtCurrent.Subtract(TimeSpan.FromDays(360))) { cNearStockOut[2]++; } } } } } transactionGrid.DataSource = dtbin; //Stock Out lblThreeStockout.Text = cStockout[0].ToString(); lblSixStockOut.Text = (cStockout[0] + cStockout[1]).ToString(); lblTwelveStockOut.Text = (cStockout[0] + cStockout[1] + cStockout[2]).ToString(); //Over Stock lblThreeOverStock.Text = cOverStock[0].ToString(); lblSixOverStock.Text = (cOverStock[0] + cOverStock[1]).ToString(); lblTwelveOverStock.Text = (cOverStock[0] + cOverStock[1] + cOverStock[2]).ToString(); //Near eop lblThreeNearStock.Text = cNearStockOut[0].ToString(); lblSixNearStock.Text = (cNearStockOut[0] + cNearStockOut[1]).ToString(); lblTwelveNear.Text = (cNearStockOut[0] + cNearStockOut[1] + cNearStockOut[2]).ToString(); //Below Min lblThreeBelowMin.Text = cBelowMin[0].ToString(); lblSixBelowMin.Text = (cBelowMin[0] + cBelowMin[1]).ToString(); lblTwelveBelowMin.Text = (cBelowMin[0] + cBelowMin[1] + cBelowMin[2]).ToString(); } */ /// <summary> /// Generates the bin card transaction /// </summary> private void GenerateBinCard() { #region NewCode ////Get the beginning balance. //Int64 begBalance = 0; //YearEnd yearEnd = new YearEnd(); //begBalance = yearEnd.GetBeginningBalance(_storeId, _itemId); //txtBBalance.Text = begBalance.ToString(); ////Get the bin card. //Balance balance = new Balance(); //gridItemsList.DataSource = balance.GetBinCard(_storeId, _itemId); //return; #endregion #region Old Code ReceiveDoc rec = new ReceiveDoc(); IssueDoc iss = new IssueDoc(); Disposal dis = new Disposal(); DisposalReasons res = new DisposalReasons(); Balance bal = new Balance(); GeneralInfo info = new GeneralInfo(); YearEnd yEnd = new YearEnd(); Items itm = new Items(); info.LoadAll(); if (cboFiscalYear.SelectedItem == null) PopulateBinCardYearCombo(); //_year = Convert.ToInt32(cboFiscalYear.SelectedItem); _year = Convert.ToInt32(cboYear.SelectedItem); int yer = _year; //int mth = (_year > _dtCurrent.Year) ? _dtCurrent.Month : 10; int mth = _dtCurrent.Month; EthiopianDate.EthiopianDate ethioDate = new EthiopianDate.EthiopianDate(_year, 1, 1); //if (_dtCurrent.Month < 11) //{ // yer = _year; //} //else //{ // yer = _year - 1; //} //DataTable dtRec = rec.GetAllTransaction(_itemId, _storeId, ethioDate.Month,ethioDate.Year); DataTable dtRec = rec.GetAllTransaction(_itemId, _storeId, ethioDate.FiscalYear); DataTable dtIss = iss.GetTransactionByItemId(_storeId, _itemId, ethioDate.FiscalYear); DataTable dtDis = dis.GetTransactionByItemId(_storeId, _itemId, ethioDate.FiscalYear); Int64[] cStockout = { 0, 0, 0 }; Int64[] cOverStock = { 0, 0, 0 }; Int64[] cNearStockOut = { 0, 0, 0 }; Int64[] cBelowMin = { 0, 0, 0 }; //DateTime dtThree = dtCurrent.AddMonths(3); DataTable dtbin = new DataTable(); string[] col = { "Date", "RefNo", "Receive", "Issue", "Unit Price", "Balance", "Batch No", "Expiry Date", "ToFrom" }; foreach (string str in col) { dtbin.Columns.Add(str); } int i = 0; Int64 bBalance = 0; dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; _dtCurrent = ConvertDate.DateConverter(dtDate.Text); //bBalance = yEnd.GetBBalance(_year, _storeId, _itemId, _dtCurrent.Month); bBalance = yEnd.GetBBalance(_year, _storeId, _itemId); Int64 balanceAmount = bBalance; DateTime dtT = new DateTime(); string balanceAm = ""; string ddDate = ""; string batNo = ""; foreach (DataRow dvRec in dtRec.Rows) { i++; if (Convert.ToInt32(dvRec["Transact"]) == 1) { rec.LoadByPrimaryKey(Convert.ToInt32(dvRec["ID"])); if (dvRec["Quantity"] == DBNull.Value) { dvRec["Quantity"] = 0; } balanceAmount = balanceAmount + Convert.ToInt64(dvRec["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; itm.LoadByPrimaryKey(rec.ItemID); if (itm.NeedExpiryBatch) { if (!rec.IsColumnNull("ExpDate")) { ddDate = rec.ExpDate.ToString("MMM dd,yyyy"); batNo = rec.BatchNo; } } Supplier sup = new Supplier(); sup.LoadByPrimaryKey(rec.SupplierID); object[] obj = { Convert.ToDateTime(dvRec["Date"]).ToString("MM dd,yyyy"), dvRec["RefNo"], Convert.ToInt64(dvRec["Quantity"]).ToString("#,###"), "", Convert.ToDouble(dvRec["Cost"]).ToString("C"), balanceAm, batNo, ddDate, sup.CompanyName }; dtbin.Rows.Add(obj); //For stock Out dtT = Convert.ToDateTime(dvRec["Date"]); } else if (Convert.ToInt32(dvRec["Transact"]) == 0) { iss.LoadByPrimaryKey(Convert.ToInt32(dvRec["ID"])); try { rec.LoadByPrimaryKey(iss.RecievDocID); } catch { rec.GetTransactionByBatch(_itemId, dvRec["BatchNo"].ToString(), _storeId); } ReceivingUnits recUnit = new ReceivingUnits(); recUnit.LoadByPrimaryKey(iss.ReceivingUnitID); string issuedTo = recUnit.Name; balanceAmount = balanceAmount - Convert.ToInt64(dvRec["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; itm.LoadByPrimaryKey(iss.ItemID); if (itm.NeedExpiryBatch) { ddDate = ((rec.RowCount > 0) ? rec.ExpDate.ToString("MMM dd,yyyy") : ""); ; batNo = dvRec["BatchNo"].ToString(); //rec.BatchNo; } else { ddDate = ""; batNo = ""; } object[] obj = { Convert.ToDateTime(dvRec["Date"]).ToString("MM dd,yyyy"), dvRec["RefNo"], "", Convert.ToInt64(dvRec["Quantity"]).ToString("#,###"), Convert.ToDouble(dvRec["Cost"]).ToString("C"), balanceAm, batNo, ddDate, issuedTo }; dtbin.Rows.Add(obj); //For stock Out dtT = Convert.ToDateTime(dvRec["Date"]); } foreach (DataRow drDis in dtDis.Rows) { DateTime dteDis = Convert.ToDateTime(drDis["Date"]); DateTime dteRec = Convert.ToDateTime(dvRec["Date"]); res.LoadByPrimaryKey(Convert.ToInt32(drDis["ReasonId"])); rec.GetTransactionByBatch(_itemId, drDis["BatchNo"].ToString(), _storeId); DateTime dteNextRec = (i <= dtRec.Rows.Count - 1) ? Convert.ToDateTime(dtRec.Rows[i]["Date"]) : _dtCurrent; if ((dteRec <= dteDis) && (dteDis < dteNextRec)) { if (Convert.ToBoolean(drDis["Losses"])) { balanceAmount = balanceAmount - Convert.ToInt64(drDis["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; if (rec.RowCount > 0) { object[] objIss = { Convert.ToDateTime(drDis["Date"]).ToString("MM dd,yyyy"), drDis["RefNo"], "", Convert.ToInt64(drDis["Quantity"]).ToString("#,###"), Convert.ToDouble(drDis["Cost"]).ToString("C"), balanceAm, drDis["BatchNo"], rec.ExpDate.ToString("MMM dd,yyyy"), res.Reason }; dtbin.Rows.Add(objIss); } } else { balanceAmount = balanceAmount + Convert.ToInt64(drDis["Quantity"]); balanceAm = (balanceAmount > 0) ? balanceAmount.ToString("#,###") : "0"; object[] objIss2 = { Convert.ToDateTime(drDis["Date"]).ToString("MM dd,yyyy"), drDis["RefNo"], Convert.ToInt64(drDis["Quantity"]).ToString("#,###"), "", Convert.ToDouble(drDis["Cost"]).ToString("C"), balanceAm, drDis["BatchNo"], rec.ExpDate.ToString("MMM dd,yyyy"), res.Reason }; dtbin.Rows.Add(objIss2); } dtT = Convert.ToDateTime(dvRec["Date"]); } } } gridItemsList.DataSource = dtbin; #endregion }
private void ManageItems_Load(object sender, EventArgs e) { var stor = new Stores(); stor.GetActiveStores(); cboStores.Properties.DataSource = stor.DefaultView; cboStores.ItemIndex = 0; var sup = new Supplier(); var dtSup = sup.GetSuppliersWithTransaction(); cboSupplier.Properties.DataSource = dtSup; cboSupplier.ItemIndex = -1; cboSupplier.Text = "Select Supplier"; var itemunit = new ItemUnit(); var units = itemunit.GetAllUnits(); unitsbindingSource.DataSource = units.DefaultView; // bind the supplier lookup for the grid. lkEditSupplier.DataSource = dtSup; var unitcolumn = ((GridView)gridReceives.MainView).Columns[14]; switch (VisibilitySetting.HandleUnits) { case 1: unitcolumn.Visible = false; break; case 2: unitcolumn.Visible = true; break; default: unitcolumn.Visible = true; break; } // bind the current dates try { var dr = (DataRowView) lstTree.GetDataRecordByNode(lstTree.Nodes[0].FirstNode); if (dr == null) return; var rec = new ReceiveDoc(); if (dr["ParentID"] == DBNull.Value) { // int yr = ((dtCurrent.Month > 10) ? dtCurrent.Year : dtCurrent.Year - 1); var dt1 = new DateTime(Convert.ToInt32(dr["ID"]) - 1, 11, 1); var dt2 = new DateTime(Convert.ToInt32(dr["ID"]), 11, 1); dtRec = rec.GetTransactionByDateRange(Convert.ToInt32(cboStores.EditValue), dt1, dt2); lblRecDate.Text = dr["RefNo"].ToString(); } else { dtRec = rec.GetTransactionByRefNo(dr["RefNo"].ToString(), Convert.ToInt32(cboStores.EditValue),dr["Date"].ToString()); lblRecDate.Text = Convert.ToDateTime(dr["Date"]).ToString("MM dd,yyyy"); } gridReceives.DataSource = dtRec; } catch (Exception ex) { } }
/// <summary> /// 根据编号修改信息 /// </summary> /// <param name="supplier">模型载体</param> /// <returns>受影响行数</returns> public int UpdateSupplier(Supplier supplier) { return(ss.UpdateSupplier(supplier)); }
/// <summary> /// 新增信息 /// </summary> /// <param name="supplier">模型</param> /// <returns>受影响行数</returns> public int InsSupplier(Supplier supplier) { return(ss.InsSupplier(supplier)); }
private void ManageItems_Load(object sender, EventArgs e) { SetPermission(); // Bind the supplier combo Supplier sup = new Supplier(); DataTable dtSup = sup.GetSuppliersWithTransaction(); cboSuppliers.Properties.DataSource = dtSup; cboSuppliers.ItemIndex = -1; cboSuppliers.Text = @"Select Supplier"; cboStores.SetupActivityEditor().SetDefaultActivity(); // Set the default dates on the filter as the current date // TODO: the from date should be fixed. dtFrom.Value = DateTimeHelper.ServerDateTime; dtTo.Value = DateTimeHelper.ServerDateTime; _isReady = true; }
/// <summary> /// Populate the lookups and item lists. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ReceiveingForm_Load(object sender, EventArgs e) { //gridRecieveView.Columns[4].Visible = VisibilitySetting.HandleUnits; var UnitColumn = ((GridView)receivingGrid.MainView).Columns[12]; var UnitColumn1 = ((GridView)receivingGrid.MainView).Columns[5]; var UnitColumn2 = ((GridView)gridItemsChoice.MainView).Columns[4]; var qtyperpack = ((GridView)receivingGrid.MainView).Columns[3]; var buqty = ((GridView)receivingGrid.MainView).Columns[4]; switch (VisibilitySetting.HandleUnits) { case 3: UnitColumn.Visible = true; UnitColumn1.Visible = false; UnitColumn2.Visible = false; qtyperpack.Visible = false; buqty.Visible = false; break; case 2: UnitColumn.Visible = true; UnitColumn1.Visible = false; UnitColumn2.Visible = false; qtyperpack.Visible = false; buqty.Visible = false; break; case 1: UnitColumn.Visible = false; UnitColumn1.Visible = true; qtyperpack.Visible = true; UnitColumn2.Visible = true; buqty.Visible = true; break; } var stor = new Stores(); stor.GetActiveStores(); cboStores.Properties.DataSource = stor.DefaultView; cboStores.ItemIndex = 0; Programs prog = new Programs(); DataTable dtProg = prog.GetSubPrograms(); cboProgram.Properties.DataSource = dtProg; cboProgram.Properties.DisplayMember = "Name"; cboProgram.Properties.ValueMember = "ID"; var unit = new ItemUnit(); var units = unit.GetAllUnits(); UnitsbindingSource.DataSource = units.DefaultView; Supplier sup = new Supplier(); DataTable dtSup = new DataTable(); sup.GetActiveSuppliers(); dtSup = sup.DefaultView.ToTable(); cboSuppliers.DataSource = dtSup; cboSupplier.Properties.DataSource = sup.DefaultView; cboSuppliers.Text = "Select Supplier"; cboSuppliers.ValueMember = "ID"; cboSuppliers.DisplayMember = "CompanyName"; // Bind the grid with only active items Items itm = new Items(); //DataTable dtItem = itm.GetAllItems(1); DataTable dtItem = BLL.Items.GetActiveItemsByCommodityType(0); lkCategories.Properties.DataSource = BLL.Type.GetAllTypes(); lkCategories.ItemIndex = 0; PopulateItemList(dtItem); selectedType = radioGroup1.EditValue.ToString(); PopulateCatTree(selectedType); int userID = MainWindow.LoggedinId; User us = new User(); us.LoadByPrimaryKey(userID); txtReceivedBy.Text = us.FullName; // bind the current date as the datetime field dtRecDate.Value = DateTime.Now; }
/// <summary> /// Saves the item policy /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { var itm = new Items(); var itmSup = new ItemSupplier(); if (_itemId != 0) itm.LoadByPrimaryKey(_itemId); else { itm.AddNew(); var prodCate = new ProductsCategory(); prodCate.AddNew(); prodCate.ItemId = itm.ID; prodCate.SubCategoryID = Convert.ToInt32(_categoryId); prodCate.Save(); } //if (rdA.Checked || rdB.Checked || rdC.Checked) // itm.ABC = ((rdA.Checked) ? 1 : (rdB.Checked) ? 2 : 3); //if (rdV.Checked || rdE.Checked || rdN.Checked) // itm.VEN = ((rdV.Checked) ? 1 : (rdE.Checked) ? 2 : 3); itm.IsInHospitalList = ckExculed.Checked; //itm.NeedExpiryBatch = chkNeedExpiryBatch.Checked; string valid = ValidateFields(); if (valid == "true") { itm.NeedExpiryBatch = chkNeedExpiryBatch.Checked; itm.StockCodeDACA = txtText.Text; itm.Cost = txtQuantityPerPack.Text; itm.Save(); } else { XtraMessageBox.Show(valid, "Validation", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } //TODO: To add categories //Needs some modification on edit // this will only add the suppliers //do some thing on edit itmSup.DeleteAllSupForItem(itm.ID); Supplier sup = new Supplier(); foreach (object t in lstSuppliers.CheckedItems) { sup.GetSupplierByName(t.ToString()); itmSup.AddNew(); itmSup.ItemID = itm.ID; itmSup.SupplierID = sup.ID; itmSup.Save(); } var progItm = new ProgramProduct(); progItm.DeleteAllProgramsForItem(_itemId); var prog = new Programs(); //prog.AddNew(); //prog.Name = cboPrograms.Text; //prog.Save(); foreach (object t in lstPrograms.CheckedItems) { prog.GetProgramByName(t.ToString()); progItm.AddNew(); progItm.ItemID = itm.ID; progItm.ProgramID = prog.ID; progItm.Save(); } var duItem = new DUsItemList(); var dus = new ReceivingUnits(); foreach (object t in lstDUs.CheckedItems) { dus.GetDUByName(t.ToString()); duItem.AddNew(); duItem.DUID = dus.ID; duItem.ItemID = _itemId; try { duItem.Save(); } catch { } } XtraMessageBox.Show("Item Detail is Saved Successfully!", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); }
private void lkReceiptInvoice_EditValueChanged(object sender, EventArgs e) { ResetFields(); if (lkReceiptInvoice.EditValue != null) { if ((standardRecType == StandardReceiptType.iGRVOnline || deliveryNoteType == DeliveryNoteType.Automatic) && lkReceiptInvoice.EditValue.Equals(-1)) { HandleReceiptTypeChange(true); return; } if (standardRecType == StandardReceiptType.iGRV && !lkReceiptInvoice.EditValue.Equals(-1)) { //This means, the hub has chosen an invoice other than "Not Found" from the list of invoices. Therefore, we want to change the receipt type to be iGRV-Online. HandleReceiptTypeChange(); } BLL.ReceiptInvoice rctInvoice = new ReceiptInvoice(); rctInvoice.LoadByPrimaryKey(Convert.ToInt32(lkReceiptInvoice.EditValue)); var po = new PO(); po.LoadByPrimaryKey(rctInvoice.POID); if (po.IsElectronic == true) { rdIsElectronic.Checked = true; lblSyncDate.Text = rctInvoice.DateOfEntry.ToShortDateString(); txtPassCode.Enabled = true; lcPassCode.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; } else { rdIsElectronic.Checked = false; lblSyncDate.Text = "-"; txtPassCode.Enabled = false; lcPassCode.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; } lblOrderNo.Text = po.PONumber; lblOrderNum.Text = po.PONumber; if (!rctInvoice.IsColumnNull("DocumentTypeID")) { var doctype = new BLL.DocumentType(); doctype.LoadByPrimaryKey(rctInvoice.DocumentTypeID); lblDeliveryNote.Text = doctype.Name; lblHeaderDoc.Text = doctype.Name; } else { lblDeliveryNote.Text = "-"; lblHeaderDoc.Text = "-"; } var mode = new Mode(); mode.LoadByPrimaryKey(po.ModeID); lblMode.Text = mode.TypeName; lblAccount.Text = "-"; lblSubAccount.Text = "-"; lblActivity.Text = "-"; lblReferenceNo.Text = po.RefNo; var payment = new PaymentType(); payment.LoadByPrimaryKey(po.PaymentTypeID); lblPaymentType.Text = payment.Name; lblHeaderPayment.Text = payment.Name; //if (po.IsColumnNull("NBE")) //{ // lblNebService.Text = Convert.ToString(po.NBE); //} //else //{ // lblNebService.Text = "-"; //} if (po.Remaining != -1) lblRemainingValue.Text = po.Remaining.ToString(); else lblRemainingValue.Text = "-"; if (po.TotalValue != -1) lblTotalValue.Text = po.Remaining.ToString(); else lblTotalValue.Text = "-"; if (po.Insurance != -1) lblChargeInsurance.Text = po.Insurance.ToString(); else lblChargeInsurance.Text = "-"; if (po.NBE != -1) lblNebService.Text = po.NBE.ToString(); else lblNebService.Text = "-"; lblOrderDate.Text = po.PODate.ToShortDateString(); lblReceiptDate.Text = rctInvoice.DateOfEntry.ToShortDateString(); var user = new User(); user.LoadByPrimaryKey(po.SavedbyUserID); lblOrderBy.Text = user.FullName; var sup = new Supplier(); lkAccounts.EditValue = rctInvoice.ActivityID; var act = new Activity(); act.LoadByPrimaryKey(rctInvoice.ActivityID); _supplierID = rctInvoice.GetSupplier(); sup.LoadByPrimaryKey(_supplierID); lblSupplier.Text = sup.CompanyName; lblOrdSup.Text = sup.CompanyName; lblInvoiceNo.Text = rctInvoice.STVOrInvoiceNo; lblInvAccount.Text = act.AccountName ?? "-"; lblInvActivity.Text = act.Name ?? "-"; lblAct.Text = act.FullActivityName ?? "-"; lblInvSubAccount.Text = act.SubAccountName ?? "-"; lblInvMode.Text = act.ModeName ?? "-"; lblInvTotalValue.Text = rctInvoice.TotalFOBValue.ToString("N"); lblInsurancePolicy.Text = rctInvoice.InsurancePolicyNo == " "? rctInvoice.InsurancePolicyNo : "-"; var poType = new POType(); poType.LoadByPrimaryKey(po.PurchaseType); lblOrderType.Text = poType.Name ?? "-"; lblPOType.Text = poType.Name ?? "-"; var poStatus = new PurchaseOrderStatus(); poStatus.LoadByPrimaryKey(po.PurchaseOrderStatusID); lblOrderStatus.Text = poStatus.Name ?? "-"; var it = new InvoiceType(); it.LoadByPrimaryKey(rctInvoice.InvoiceTypeID); lblInvType.Text = it.Name; lblInvDate.Text = rctInvoice.DateOfEntry.ToShortDateString(); mode.LoadByPrimaryKey(rctInvoice.ActivityID); lblWayBillNo.Text = rctInvoice.WayBillNo; txtTransitTransferVoucherNo.Text = rctInvoice.TransitTransferNo; txtEditTransferNo.Text = rctInvoice.TransitTransferNo; lblInsurancePolicyNo.Text = rctInvoice.InsurancePolicyNo; BLL.PO order = new PO(); order.LoadByPrimaryKey(rctInvoice.POID); lblRefNo.Text = order.RefNo; lblPoNo.Text = order.PONumber; DataTable relatedReceives = rctInvoice.GetRelatedReceives(); hasPreviousReceive = false; if (relatedReceives.Rows.Count > 0) { XtraMessageBox.Show( "The Invoice you have selected has previous associated receives", "Invoice Detail", MessageBoxButtons.OK, MessageBoxIcon.Warning); colSelectedManufactuerer.Visible = true; colSelectedUnit.Visible = true; colSelectionLineNo.Visible = true; colSelectedReceiveQty.Visible = true; colSelectedInvoiceQty.Visible = true; hasPreviousReceive = true; gridItemsChoice.Enabled = false; colRemainingQty.VisibleIndex = 9; lcItemChoiceGrid.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; _dtSelectedTable = relatedReceives.Clone(); gridSelected.DataSource = _dtSelectedTable; foreach (DataRow dr in relatedReceives.Rows) { SelectAnItem(dr); } } else { hasPreviousReceive = false; colSelectedManufactuerer.Visible = false; colSelectedUnit.Visible = false; colSelectionLineNo.Visible = false; colSelectedReceiveQty.Visible = false; colSelectedInvoiceQty.Visible = false; colRemainingQty.Visible = false; gridItemsChoice.Enabled = true; lcItemChoiceGrid.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; } if (lkAccounts.EditValue != null) { // lcInvoiceDetail.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; } if (standardRecType == StandardReceiptType.iGRVOnline || standardRecType == StandardReceiptType.GRV || deliveryNoteType == DeliveryNoteType.Automatic) { if (!hasPreviousReceive) LoadItemsFromTransferredReceiptInvoiceDetail(rctInvoice.ID); txtRefNo.Text = lkReceiptInvoice.Text; colSelectedReceiveQty.Visible = true; lcItemChoiceGrid.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; lkAccounts.Enabled = false; } else { lkAccounts.Enabled = !BLL.Settings.IsCenter; } if(!BLL.Settings.IsCenter) { //Passcode Textbox var dataRowView = lkReceiptInvoice.GetSelectedDataRow() as DataRowView; if (dataRowView != null) _isElectronic = Convert.ToBoolean(dataRowView["IsElectronic"]); lcPassCode.Visibility = (!_isNonElectronicReceiveOnly) && (_isElectronic) && (standardRecType == StandardReceiptType.iGRVOnline || deliveryNoteType == DeliveryNoteType.Automatic) ? LayoutVisibility.Always : LayoutVisibility.Never; txtPassCode.Text = "HHMM"; } } }
private HCMIS.Desktop.Reports.ReceiptConfirmationPrintout PrintReceiptConfirmation(int ReceiptID, int? reprintOfReceiptConfirmationPrintoutID) { ReceiptConfirmationPrintout rc = new ReceiptConfirmationPrintout(); HCMIS.Desktop.Reports.ReceiptConfirmationPrintout printout = new HCMIS.Desktop.Reports.ReceiptConfirmationPrintout(CurrentContext.LoggedInUserName); BLL.ReceiveDoc receiveDoc = new ReceiveDoc(); // receiveDoc.LoadByReferenceNo(reference); receiveDoc.LoadByReceiptID(ReceiptID); var activity = new Activity(); activity.LoadByPrimaryKey(receiveDoc.StoreID); BLL.Supplier supplier = new Supplier(); supplier.LoadByPrimaryKey(receiveDoc.SupplierID); BLL.Receipt receipt=new BLL.Receipt(); receipt.LoadByPrimaryKey(receiveDoc.ReceiptID); BLL.ReceiptInvoice receiptInvoice= new ReceiptInvoice(); receiptInvoice.LoadByPrimaryKey(receipt.ReceiptInvoiceID); BLL.PO po = new PO(); po.LoadByPrimaryKey(receiptInvoice.POID); BLL.POType poType = new POType(); poType.LoadByPrimaryKey(po.PurchaseType); int printedID = 0; string GRNFNo = FiscalYear.Current.GetCode(BLL.ReceiptConfirmationPrintout.GetGRNFNo(ReceiptID)); if (currentMode == Modes.GRVPrinting) //The GRVConfirmation is for reprinting { printout.BranchName.Text = GeneralInfo.Current.HospitalName; PrepareGRVPrintout(printout); // String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString(); if (poType.PurchaseOrderTypeCode == "LP") printout.xrGRVLabel.Text = "GRV No."; else printout.xrGRVLabel.Text = "iGRV No."; if (supplier.SupplierTypeID == SupplierType.CONSTANTS.HOME_OFFICE || supplier.SupplierTypeID == SupplierType.CONSTANTS.HUBS || supplier.SupplierTypeID == SupplierType.CONSTANTS.ACCOUNTS || supplier.SupplierTypeID == SupplierType.CONSTANTS.STORES) { //printout.xrGRVLabel.Text = "iGRV No."; printout.xrAir.Visible = false; printout.xrAirValue.Visible = false; printout.xrTransit.Visible = false; printout.xrTransitValue.Visible = false; printout.xrInsurance.Visible = false; printout.xrInsuranceValue.Visible = false; printout.xrNumberOfCases.Visible = false; printout.xrNumberOfCasesValue.Visible = false; printout.xrInvoiceNo.Text = "STV No."; printout.xrPurchaseOrderNo.Visible = false; printout.xrPurchaseOrderNoValue.Visible = false; printout.xrLabelGRNF.Text = GRNFNo; printout.xrSTV.Visible = false; printout.xrSTVNoValue.Visible = false; printedID = rc.PrepareDataForPrintout(ReceiptID, CurrentContext.UserId, false, 4, null,reprintOfReceiptConfirmationPrintoutID,FiscalYear.Current); printout.DataSource = rc.DefaultView.ToTable(); CalendarLib.DateTimePickerEx dtDate = new CalendarLib.DateTimePickerEx(); //dtDate.CustomFormat = "dd/MM/yyyy"; dtDate.Value = receiveDoc.EurDate; printout.Date.Text = dtDate.Text; } else { // printout.xrGRVLabel.Text = "GRV No."; printout.xrSTV.Visible = false; printout.xrSTVNoValue.Visible = false; printedID = rc.PrepareDataForPrintout(ReceiptID, CurrentContext.UserId, false, 2, null, reprintOfReceiptConfirmationPrintoutID,FiscalYear.Current); printout.xrLabelGRNF.Text = GRNFNo; printout.DataSource = rc.DefaultView.ToTable(); CalendarLib.DateTimePickerEx dtDate = new CalendarLib.DateTimePickerEx(); //dtDate.CustomFormat = "dd/MM/yyyy"; dtDate.Value = receiveDoc.EurDate; printout.Date.Text = dtDate.Text; } } printout.xrLabelStoreName.Text = activity.FullActivityName; if (ReceiveDoc.IsThereShortageOrDamage(ReceiptID)) { HCMIS.Desktop.Reports.ReceiptConfirmationShortagePrintout printoutShortage = PrintReceiptConfirmationForShortage(ReceiptID, printedID); if (currentMode == Modes.GRVPrinting) PrepareGRVPrintout(printoutShortage); printout.xrShortageReport.ReportSource = printoutShortage; printout.PrintingSystem.ContinuousPageNumbering = true; } else { printout.ReportFooter.Visible = false; } //Release Product CostCalculator GRV = new CostCalculator(); GRV.LoadGRV(ReceiptID); String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString(); BLL.ReceiveDoc recDoc = new ReceiveDoc(); recDoc.LoadByReceiptID(ReceiptID); recDoc.ConfirmGRVPrinted(CurrentContext.UserId); BLL.Receipt receiptStatus = new BLL.Receipt(); receiptStatus.LoadByPrimaryKey(ReceiptID); receiptStatus.ChangeStatus(ReceiptConfirmationStatus.Constants.GRV_PRINTED, null, this.GetFormIdentifier(), CurrentContext.UserId, "GRV Printed"); BindFormContents(); // LOG Cost Analysis printout in PDF Log MemoryStream stream = new MemoryStream(); printout.ExportToPdf(stream); HCMIS.Core.Distribution.Services.PrintLogService.SavePrintLogNoWait(stream, "GRV/IGRV", true, ReceiptID, CurrentContext.UserId, BLL.DateTimeHelper.ServerDateTime); return printout; }
/// <summary> /// Saves supplier information /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSupplierSave_Click(object sender, EventArgs e) { if (txtCompanyName.Text != "" && cboCompanyInfo.SelectedItem != null) { Supplier sup = new Supplier(); if (_supplierId != 0) sup.LoadByPrimaryKey(_supplierId); else sup.AddNew(); sup.CompanyInfo = cboCompanyInfo.SelectedItem.ToString(); sup.CompanyName = txtCompanyName.Text; sup.Address = txtAddress.Text; sup.ContactPerson = txtContactPerson.Text; sup.Telephone = txtTelephone.Text; sup.IsActive = ckIsActive.Checked; sup.Mobile = txtMobile.Text; sup.Email = txtEmail.Text; sup.Save(); sup.LoadAll(); PopulateSupplier(sup); ResetSupplier(); XtraMessageBox.Show("Supplier Record Updated.", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { txtCompanyName.BackColor = Color.FromArgb(251, 214, 214); } }
private HCMIS.Desktop.Reports.ReceiptConfirmationShortagePrintout PrintReceiptConfirmationForShortage(int ReceiptID, int printedID) { HCMIS.Desktop.Reports.ReceiptConfirmationShortagePrintout printout = new HCMIS.Desktop.Reports.ReceiptConfirmationShortagePrintout(); ReceiptConfirmationPrintout rc = new ReceiptConfirmationPrintout(); BLL.ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.LoadAllByReceiptID(ReceiptID); if (currentMode == Modes.GRVPrinting ) { BLL.Supplier supplier = new Supplier(); supplier.LoadByPrimaryKey(receiveDoc.SupplierID); } rc.PrepareDataForPrintout(ReceiptID, CurrentContext.UserId, true, 2, printedID,null,FiscalYear.Current); printout.DataSource = rc.DefaultView.ToTable(); return printout; }
/// <summary> /// Populates the lstSuppliers with the supplied Suppliers /// </summary> /// <param name="sup"></param> private void PopulateSupplier(Supplier sup) { lstSuppliers.DataSource = sup.DefaultView; }
private void EditReceived_Load(object sender, EventArgs e) { BLL.ItemManufacturer im = new BLL.ItemManufacturer(); im.LoadManufacturersFor(rDoc.ItemID); lkManufacturer.Properties.DataSource = im.DefaultView; if (BLL.Settings.UseNewUserManagement && this.HasPermission("Edit-Quantity") && (rDoc.IsColumnNull("Confirmed") || (!rDoc.IsColumnNull("Confirmed") && !rDoc.Confirmed))) { txtQuanitity.Enabled = true; } else if ( (!rDoc.IsColumnNull("Confirmed") && !rDoc.Confirmed)) { txtQuanitity.Enabled = true; } else { txtQuanitity.Enabled = false; } Supplier supplier = new Supplier(); supplier.LoadAll(); lkSupplier.Properties.DataSource = supplier.DefaultView; lkAccount.SetupActivityEditor().SetDefaultActivity(); BLL.ItemUnit iu = new ItemUnit(); iu.LoadAllForItem(rDoc.ItemID); lkUnit.Properties.DataSource = iu.DefaultView; // Bind the variables) if (rDoc.RowCount > 0) { this.txtRefNo.Text = rDoc.RefNo; this.txtQuanitity.Text = Convert.ToInt32(Convert.ToDouble(rDoc.Quantity)/rDoc.QtyPerPack).ToString("#,##0"); this.txtManufacturer.Text = Manufacturer.GetName(rDoc.ManufacturerId); this.txtItemName.Text = Item.GetName(rDoc.ItemID); this.txtGrvNo.Text = rDoc.RefNo; this.lkManufacturer.EditValue = rDoc.ManufacturerId; this.lkAccount.EditValue = rDoc.StoreID; this.lkUnit.EditValue = rDoc.UnitID; if (!rDoc.IsColumnNull("SupplierID")) lkSupplier.EditValue = rDoc.SupplierID; // Editable controls txtPrice.Text = rDoc.IsColumnNull("Cost") ? "0" : rDoc.Cost.ToString(); if (!rDoc.IsColumnNull("ExpDate")) { dtExpiry.EditValue = rDoc.ExpDate; } if (!rDoc.IsColumnNull("BatchNo")) { txtBatchNo.Text = rDoc.BatchNo; } BLL.Item itm = new Item(); itm.LoadByPrimaryKey(rDoc.ItemID); if (BLL.Settings.UseNewUserManagement && this.HasPermission("Edit-Batch-Expiry")) { } else if (!itm.NeedExpiryBatch && (CurrentContext.LoggedInUser.UserType == UserType.Constants.ADMIN || CurrentContext.LoggedInUser.UserType == UserType.Constants.SUPER_ADMINISTRATOR)) { btnRemoveExpiry.Enabled = true; txtBatchNo.Enabled = true; } } }
private void PrintReceiptConfirmation(string referenceNumber, int? reprintOfReceiptConfirmationPrintoutID) { ReceiptConfirmationPrintout rc = new ReceiptConfirmationPrintout(); HCMIS.Desktop.Reports.ReceiptConfirmationPrintout printout = new HCMIS.Desktop.Reports.ReceiptConfirmationPrintout(CurrentContext.LoggedInUserName); HCMIS.Desktop.Reports.SRMPrintout srmPrintout = new HCMIS.Desktop.Reports.SRMPrintout(CurrentContext.LoggedInUserName); int ReceiptID = Convert.ToInt32(gridReceiveView.GetFocusedDataRow()["ReceiptID"]); BLL.ReceiveDoc receiveDoc = new ReceiveDoc(); // receiveDoc.LoadByReferenceNo(reference); receiveDoc.LoadByReceiptID(ReceiptID); BLL.Supplier supplier = new Supplier(); supplier.LoadByPrimaryKey(receiveDoc.SupplierID); int printedID = 0; int GRNFNo = BLL.ReceiptConfirmationPrintout.GetGRNFNo(ReceiptID); if (currentMode == Modes.DeliveryNotePrinting) { printout.BranchName.Text = GeneralInfo.Current.HospitalName; printout.xrGRVLabel.Text = "Delivery Note."; printout.xrAir.Visible = false; printout.xrAirValue.Visible = false; printout.xrTransit.Visible = false; printout.xrTransitValue.Visible = false; printout.xrInsurance.Visible = false; printout.xrInsuranceValue.Visible = false; printout.xrNumberOfCases.Visible = false; printout.xrNumberOfCasesValue.Visible = false; printout.xrInvoiceNo.Visible = false; printout.xrInvoiceNoValue.Visible = false; printout.xrPurchaseOrderNo.Visible = false; printout.xrPurchaseOrderNoValue.Visible = false; printout.xrSTV.Visible = false; printout.xrSTVNoValue.Visible = false; printout.DataSource = rc.PrepareDataForPrintout(ReceiptID, CurrentContext.UserId, false, 5, null, reprintOfReceiptConfirmationPrintoutID,FiscalYear.Current); CalendarLib.DateTimePickerEx dtDate = new CalendarLib.DateTimePickerEx(); //dtDate.CustomFormat = "dd/MM/yyyy"; dtDate.Value = receiveDoc.EurDate; printout.Date.Text = dtDate.Text; } var activity = new Activity(); activity.LoadByPrimaryKey(receiveDoc.StoreID); printout.xrLabelStoreName.Text = activity.FullActivityName; if (ReceiveDoc.IsThereShortageOrDamage(ReceiptID)) { HCMIS.Desktop.Reports.ReceiptConfirmationShortagePrintout printoutShortage = PrintReceiptConfirmationForShortage(referenceNumber, printedID); printout.xrShortageReport.ReportSource = printoutShortage; printout.PrintingSystem.ContinuousPageNumbering = true; } else { printout.ReportFooter.Visible = false; } //Successfully printed //Release Product CostCalculator GRV = new CostCalculator(); GRV.LoadGRV(ReceiptID); GRV.ReleaseForIssue(); String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString(); BLL.ReceiveDoc recDoc = new ReceiveDoc(); recDoc.LoadByReferenceNo(reference); recDoc.ConfirmGRVPrinted(CurrentContext.UserId); BindFormContents(); }
private void btnSave_Click(object sender, EventArgs e) { if (!AccountTypeSelectionValid()) { XtraMessageBox.Show("Please choose to which account types this item applies to.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); gridViewStoreItemMatrix.SetColumnError(gridColAcctType, "At least one account type needs to be selected"); return; } Item itm = new Item(); ItemSupplier itmSup = new ItemSupplier(); if (itemId != 0) itm.LoadByPrimaryKey(itemId); else { itm.AddNew(); ItemCategory prodCate = new ItemCategory(); prodCate.AddNew(); prodCate.ItemId = itm.ID; prodCate.SubCategoryID = Convert.ToInt32(categoryId); prodCate.Save(); } if(radioGroupABC.EditValue != null){ itm.ABC = Convert.ToInt32(radioGroupABC.EditValue); } if (radioGroupVEN.EditValue != null) { itm.VEN = Convert.ToInt32(radioGroupVEN.EditValue); } itm.IsInHospitalList = ckExculed.Checked; itm.ProcessInDecimal = chkProcessDecimal.Checked; itm.Save(); if (itm.IsInHospitalList) { SaveHubDetails(); } else { // clear out the prefered locations // clear out the pick face locations // make sure that this item could be made not in the list } itmSup.DeleteAllSupForItem(itm.ID); Supplier sup = new Supplier(); for (int i = 0; i < lstSuppliers.CheckedItems.Count;i++ ) { sup.GetSupplierByName(lstSuppliers.CheckedItems[i].ToString()); itmSup.AddNew(); itmSup.ItemID = itm.ID; itmSup.SupplierID = sup.ID; itmSup.Save(); } ItemProgram progItm = new ItemProgram(); progItm.DeleteAllProgramsForItem(itemId); BLL.Program prog = new BLL.Program(); for (int i = 0; i < lstPrograms.CheckedItems.Count; i++) { prog.GetProgramByName(lstPrograms.CheckedItems[i].ToString()); progItm.AddNew(); progItm.ItemID = itm.ID; progItm.ProgramID = prog.ID; progItm.Save(); } XtraMessageBox.Show("Item Detail is Saved Successfully!", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); }
private void btnSave_Click(object sender, EventArgs e) { int warehouseID = Convert.ToInt32(lkWarehouse.EditValue); receiveDoc.Rewind(); var po = new BLL.PO(); var receiptInvoice = new BLL.ReceiptInvoice(); while (!receiveDoc.EOF) { //Handle the PO. //int receiptID; if (po.RowCount == 0 || po.StoreID != receiveDoc.StoreID) { Supplier supplier = new Supplier(); po = BLL.PO.CreatePOforStandard(OrderType.CONSTANTS.STANDARD_ORDER, receiveDoc.StoreID, supplier.GetHubHomeOfficeSupplierID(), "",CurrentContext.LoggedInUser.ID); //Should we receive it as hub to hub transfer? We're now using Standard order. receipt = BLL.ReceiptInvoice.CreateAutomaticReceiptInvoiceForSTVTransfer(po.ID, warehouseID, STVNo, CurrentContext.UserId); } receiveDoc.Quantity = receiveDoc.QtyPerPack * receiveDoc.NoOfPack; receiveDoc.ReceiptID = receipt.ID; receiveDoc.MoveNext(); } receiveDoc.Save(); //Save the location receiveDoc.Rewind(); BLL.ReceivePallet receivePallet = new ReceivePallet(); while (!receiveDoc.EOF) { //Save Location Information BLL.PalletLocation palletLocation = new PalletLocation(); receivePallet.AddNew(); int palletLocationID = Convert.ToInt32(receiveDoc.GetColumn("PalletLocationID")); receivePallet.PalletLocationID = palletLocationID; palletLocation.LoadByPrimaryKey(palletLocationID); receivePallet.PalletID = palletLocation.PalletID; receivePallet.ReceivedQuantity = receiveDoc.Quantity; receivePallet.Balance = receiveDoc.Quantity; receivePallet.ReceiveID = receiveDoc.ID; receivePallet.ReservedStock = 0; //Save Discrepancy information if there is any receiveDocShortage.Rewind(); while (receiveDocShortage.FindNextByGUID(receiveDoc.GetColumn("GUID").ToString())) { receiveDocShortage.ReceiveDocID = receiveDoc.ID; if (receiveDocShortage.ShortageReasonID == ShortageReasons.Constants.DAMAGED) { receiveDoc.NoOfPack += receiveDocShortage.NoOfPacks; receiveDoc.Quantity += receiveDocShortage.NoOfPacks*receiveDoc.QtyPerPack; palletLocationID = Convert.ToInt32(receiveDocShortage.GetColumn("PalletLocationID")); receivePallet.AddNew(); receivePallet.PalletLocationID = palletLocationID; palletLocation.LoadByPrimaryKey(palletLocationID); receivePallet.PalletID = palletLocation.PalletID; receivePallet.ReceivedQuantity = receiveDocShortage.NoOfPacks*receiveDoc.QtyPerPack; receivePallet.Balance = receiveDocShortage.NoOfPacks*receiveDoc.QtyPerPack; receivePallet.ReceiveID = receiveDoc.ID; receivePallet.ReservedStock = 0; } } receiveDoc.MoveNext(); } receivePallet.IsOriginalReceive = true; receivePallet.Save(); }
public bool EditSupplier(Supplier sl) { return(supplierDAL.EditSupplier(sl)); }