private void PopulateTransaction() { TimeSpan tt = new TimeSpan(); Items itm = new Items(); DateTime dtRec = itm.GetLastReceiveDate(_itemId, _storeId); DateTime dtIss = itm.GetLastIssuedDate(_itemId, _storeId); string noDays = ""; tt = new TimeSpan(_dtCurrent.Ticks - dtRec.Ticks); noDays = (tt.TotalDays < 30000) ? dtRec.ToString("MM dd, yyyy") + " (" + tt.TotalDays.ToString() + " days ago)" : "Never"; lblLastReceive.Text = noDays; lblLastRec.Text = noDays; tt = new TimeSpan(_dtCurrent.Ticks - dtIss.Ticks); noDays = (tt.TotalDays < 30000) ? dtIss.ToString("MM dd, yyyy") + " (" + tt.TotalDays.ToString() + " days ago)" : "Never"; lblLastIssues.Text = noDays; lblLastIssue.Text = noDays; }
private void ItemStockStatus() { GeneralInfo info = new GeneralInfo(); info.LoadAll(); Balance bal = new Balance(); Items itm = new Items(); //dtDate.Value = DateTime.Now; //DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text); // int yr = ()?dtCurrent.Year : dtCurrent.Year -1; DataTable dtItm = itm.GetItemById(_itemId); string dosage = lblBUnit.Text; double amc = Builder.CalculateAverageConsumption(_itemId, _storeId, _dtCurrent.Subtract(TimeSpan.FromDays(180)), _dtCurrent, CalculationOptions.Monthly);//bal.CalculateAMC(_itemId, _storeId, _dtCurrent.Month, _dtCurrent.Year); Int64 soh = bal.GetSOH(_itemId, _storeId, _dtCurrent.Month, _dtCurrent.Year); double sohPrice = bal.GetSOHAmount(_itemId, _storeId, _dtCurrent.Month, _dtCurrent.Year); string sohPriStr = ((sohPrice != 0) ? sohPrice.ToString("C") + " ETB" : "0 ETB"); // this can not be done cuz it works only for current year // Int64 soh = itm.GetSOHQtyAmount(itemId, storeId); double min = (amc * info.Min); //Int64 min = (amc * info.Min); double max = (amc * info.Max); //Int64 max = (amc * info.Max); double eop = amc * (info.EOP + 0.25); double beloweop = amc * (info.EOP - 0.25); double reorder = max - soh; double mos = (amc > 0) ? (Convert.ToDouble(soh) / Convert.ToDouble(amc)) : 0; object[] obj = itm.GetExpiredQtyAmountItemsByID(_itemId, _storeId); Int64 expAmount = Convert.ToInt64(obj[0]); Double expCost = Convert.ToDouble(obj[1]); string expBirr = ((expCost != 0) ? " in ETB " + expCost.ToString("C") : " Price NA"); object[] nearObj = itm.GetNearlyExpiredQtyAmountItemsByID(_itemId, _storeId); Int64 nearExpAmount = Convert.ToInt64(nearObj[0]); double nearExpCost = Convert.ToDouble(nearObj[1]); string nearExpBirr = ((nearExpCost != 0) ? " in ETB " + nearExpCost.ToString("C") : " Price NA"); txtSOH.Text = (soh != 0) ? soh.ToString("#,###") + " - " + dosage + ", " + sohPriStr : "0 - " + dosage; txtAMC.Text = (amc != 0) ? amc.ToString("#,###") + " - " + dosage : "0" + " - " + dosage; txtMin.Text = (min != 0) ? min.ToString("#,###") + " - " + dosage : "0" + " - " + dosage; txtMax.Text = (max != 0) ? max.ToString("#,###") + " - " + dosage : "0" + " - " + dosage; txtMOS.Text = mos.ToString("#,###.0#"); txtReorderAmount.Text = (reorder <= 0) ? "0 - " + dosage : reorder.ToString("#,###") + " - " + dosage; txtExpiredAmount.Text = (expAmount != 0) ? "Qty: " + expAmount.ToString("#,###") + " - " + dosage + expBirr : "0"; txtNearExp.Text = (nearExpAmount != 0) ? nearExpAmount.ToString("#,###") + " - " + dosage + nearExpBirr : "0"; DateTime dtTran = new DateTime(); //dtDate.Value = DateTime.Now; //dtDate.CustomFormat = "MM/dd/yyyy"; TimeSpan tt = new TimeSpan(); if (soh == 0) { lblstat.Text = "Stocked Out"; lblStatus.Text = "Stocked Out"; lblCurStatus.Text = "Stocked Out"; dtTran = itm.GetLastIssuedDate(_itemId, _storeId); tt = new TimeSpan(_dtCurrent.Ticks - dtTran.Ticks); lblTime.Text = " For the past " + tt.TotalDays.ToString() + " Days"; } else if (soh > max && max != 0) { lblstat.Text = "Over Stock"; lblStatus.Text = "Over Stock"; lblCurStatus.Text = "Over Stock"; dtTran = itm.GetLastReceiveDate(_itemId, _storeId); tt = new TimeSpan(_dtCurrent.Ticks - dtTran.Ticks); lblTime.Text = " For the past " + tt.TotalDays.ToString() + " Days"; } else if (soh > beloweop && soh <= eop) { lblstat.Text = "Near EOP"; lblStatus.Text = "Near EOP"; lblCurStatus.Text = "Near EOP"; dtTran = itm.GetLastIssuedDate(_itemId, _storeId); tt = new TimeSpan(_dtCurrent.Ticks - dtTran.Ticks); lblTime.Text = " For the past " + tt.TotalDays.ToString() + " Days"; } else if (soh > 0 && soh <= beloweop) { lblstat.Text = "Below EOP"; lblStatus.Text = "Below EOP"; lblCurStatus.Text = "Below EOP"; dtTran = itm.GetLastIssuedDate(_itemId, _storeId); tt = new TimeSpan(_dtCurrent.Ticks - dtTran.Ticks); lblTime.Text = " For the past " + tt.TotalDays.ToString() + " Days"; } else if (soh > eop && soh <= min) { lblstat.Text = "Below Min"; lblStatus.Text = "Below Min"; lblCurStatus.Text = "Below Min"; dtTran = itm.GetLastIssuedDate(_itemId, _storeId); tt = new TimeSpan(_dtCurrent.Ticks - dtTran.Ticks); lblTime.Text = " For the past " + tt.TotalDays.ToString() + " Days"; } else //if (soh> min && soh <= max) { lblstat.Text = "Normal"; lblStatus.Text = "Normal"; lblCurStatus.Text = "Normal"; } //} //else //{ // lblCurStatus.Text = "Stocked Out"; // lblTime.Text = " Never been received!"; //} }