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; }
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"; } }
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(); }
/// <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 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.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; }
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; }
/* 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 }