public void PopulateItemListByDU(DataTable dtItem) { progressBar1.Visible = true; progressBar1.Minimum = 1; progressBar1.Value = 1; progressBar1.Maximum = dtItem.Rows.Count; GeneralInfo pipline = new GeneralInfo(); pipline.LoadAll(); int min = pipline.Min; int max = pipline.Max; int storeId = (cboStores.SelectedValue != null) ? Convert.ToInt32(cboStores.SelectedValue) : 1; int duId = Convert.ToInt32(cboIssuedTo.SelectedValue); lstItem.Items.Clear(); int col = 0; int count = 1; Balance bal = new Balance(); IssueDoc itmIssues = new IssueDoc(); foreach (DataRow dr in dtItem.Rows) { int itemId = Convert.ToInt32(dr["ID"]); string itemName = dr["ItemName"].ToString() + " - " + dr["DosageForm"].ToString() + " - " + dr["Strength"].ToString(); int year = Convert.ToInt32(cboYear.SelectedItem); Int64 SOH = bal.GetDUSOH(Convert.ToInt32(dr["ID"]), duId, dtCurrent.Month, year); int[] mon = { 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; long[] cons = new long[12]; for (int i = 0; i < mon.Length; i++) { int yr = (mon[i] > 10) ? year - 1 : year; cons[i] = itmIssues.GetDUConsumptionByMonth(itemId,duId,mon[i], yr); } string[] str = { count.ToString(), itemName, ((SOH != 0) ? SOH.ToString("#,###") : "0"), ((cons[0] != 0) ? cons[0].ToString("#,###") : "0"), ((cons[1] != 0) ? cons[1].ToString("#,###") : "0"), ((cons[2] != 0) ? cons[2].ToString("#,###") : "0"), ((cons[3] != 0) ? cons[3].ToString("#,###") : "0"), ((cons[4] != 0) ? cons[4].ToString("#,###") : "0"), ((cons[5] != 0) ? cons[5].ToString("#,###") : "0"), ((cons[6] != 0) ? cons[6].ToString("#,###") : "0"), ((cons[7] != 0) ? cons[7].ToString("#,###") : "0"), ((cons[8] != 0) ? cons[8].ToString("#,###") : "0"), ((cons[9] != 0) ? cons[9].ToString("#,###") : "0"), ((cons[10] != 0) ? cons[10].ToString("#,###") : "0"), ((cons[11] != 0) ? cons[11].ToString("#,###") : "0") }; ListViewItem listItem = new ListViewItem(str); listItem.ToolTipText = itemName; listItem.Tag = dr["ID"]; if (col != 0) { listItem.BackColor = Color.FromArgb(233, 247, 248); col = 0; } else { col++; } lstItem.Items.Add(listItem); count++; progressBar1.PerformStep(); } progressBar1.Visible = false; }
public void PopulateItemListDU(DataTable dtItem) { lstItem.Items.Clear(); GeneralInfo pipline = new GeneralInfo(); pipline.LoadAll(); int min = pipline.Min; int max = pipline.Max; double eop = pipline.EOP; int duId = Convert.ToInt32(cboIssuedTo.SelectedValue); int count = 1; Balance bal = new Balance(); DataTable dtList = new DataTable(); // string[] co = {"No","Item Name", "Ham","HamAmc","Neh","NehAmc","Mes","MesAmc","Tek","TekAmc","Hed","HedAmc","Tah","TahAmc","Tir","TirAmc","Yek","YekAmc","Meg","MegAmc","Miz","MizAmc","Gen","GenAmc","Sen","SenAmc","ItemID" }; dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text); int year = Convert.ToInt32(cboYear.SelectedItem); int col = 0; progressBar1.Visible = true; progressBar1.Minimum = 1; progressBar1.Maximum = dtItem.Rows.Count; foreach (DataRow dr in dtItem.Rows) { int itemId = Convert.ToInt32(dr["ID"]); string itemName = dr["ItemName"].ToString() + " - " + dr["DosageForm"].ToString() + " - " + dr["Strength"].ToString(); int[] mon = { 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; long[] cons = new long[12]; long[] amc = new long[12]; DataTable dtBal = new DataTable(); for (int i = 0; i < mon.Length; i++) { if (!(year == dtCurrent.Year && mon[i] > dtCurrent.Month && mon[i] < 11)) { cons[i] = bal.GetDUSOH(itemId, duId, mon[i], year); } } //string[] str = { count.ToString(), itemName, ((cons[0] != 0) ? cons[0].ToString("") : "0"), amc[0].ToString(), ((cons[1] != 0) ? cons[1].ToString() : "0"), amc[1].ToString(), ((cons[2] != 0) ? cons[2].ToString() : "0"), amc[2].ToString(), ((cons[3] != 0) ? cons[3].ToString() : "0"), amc[3].ToString(), ((cons[4] != 0) ? cons[4].ToString() : "0"), amc[4].ToString(), ((cons[5] != 0) ? cons[5].ToString() : "0"), amc[5].ToString(), ((cons[6] != 0) ? cons[6].ToString() : "0"), amc[6].ToString(), ((cons[7] != 0) ? cons[7].ToString() : "0"), amc[7].ToString(), ((cons[8] != 0) ? cons[8].ToString() : "0"), amc[8].ToString(), ((cons[9] != 0) ? cons[9].ToString() : "0"), amc[9].ToString(), ((cons[10] != 0) ? cons[10].ToString() : "0"), amc[10].ToString(), ((cons[11] != 0) ? cons[11].ToString() : "0"), amc[11].ToString(), dr["ID"].ToString() }; string[] str = { count.ToString(), itemName, ((cons[0] != 0) ? cons[0].ToString("#,###") : "0"), ((cons[1] != 0) ? cons[1].ToString("#,###") : "0"), ((cons[2] != 0) ? cons[2].ToString("#,###") : "0"), ((cons[3] != 0) ? cons[3].ToString("#,###") : "0"), ((cons[4] != 0) ? cons[4].ToString("#,###") : "0"), ((cons[5] != 0) ? cons[5].ToString("#,###") : "0"), ((cons[6] != 0) ? cons[6].ToString("#,###") : "0"), ((cons[7] != 0) ? cons[7].ToString("#,###") : "0"), ((cons[8] != 0) ? cons[8].ToString("#,###") : "0"), ((cons[9] != 0) ? cons[9].ToString("#,###") : "0"), ((cons[10] != 0) ? cons[10].ToString("#,###") : "0"), ((cons[11] != 0) ? cons[11].ToString("#,###") : "0") }; // dtList.Rows.Add(str); ListViewItem listItem = new ListViewItem(str); listItem.ToolTipText = itemName; listItem.Tag = dr["ID"]; if (col != 0) { listItem.BackColor = Color.FromArgb(233, 247, 248); col = 0; } else { col++; } lstItem.Items.Add(listItem); count++; progressBar1.PerformStep(); //SOHGrid.Rows.Add(dRow); } progressBar1.Visible = false; }
private void DetailSoh() { //CALENDAR: dtDate.Value = DateTime.Now; dtDate.CustomFormat = "MM/dd/yyyy"; DateTime dtCurrent = new DateTime();// Convert.ToDateTime(dtDate.Text); try { dtCurrent = Convert.ToDateTime(dtDate.Text); } catch { string dtValid = ""; string yer = ""; if (Convert.ToInt32(dtDate.Text.Substring(0, 2)) == 13) { dtValid = dtDate.Text; yer = dtValid.Substring(dtValid.Length - 4, 4); dtCurrent = Convert.ToDateTime("12/30/" + yer); } else if (Convert.ToInt32(dtDate.Text.Substring(0, 2)) == 2) { dtValid = dtDate.Text; yer = dtValid.Substring(dtValid.Length - 4, 4); dtCurrent = Convert.ToDateTime("2/28/" + yer); } } ReceivingUnits du = new ReceivingUnits(); DataTable dtDus = du.GetApplicableDUsAll(_itemId); int col = 0; Balance bal = new Balance(); IssueDoc iss = new IssueDoc(); Stores stor = new Stores(); stor.GetActiveStores(); DataTable dtStores = stor.DefaultView.ToTable(); foreach (DataRow drStr in dtStores.Rows) { int storeId = Convert.ToInt32(drStr["ID"]); //Int64 soh = bal.GetSOH(itemId, storeId, dtCurrent.Month, dtCurrent.Year); //Int64 amc = bal.CalculateAMC(itemId, storeId, dtCurrent.Month, dtCurrent.Year); //Int64 issue = iss.GetIssuedQuantityByMonth(itemId, storeId, dtCurrent.Month, dtCurrent.Year); //decimal mos = ((amc > 0) ? Convert.ToDecimal(soh) / Convert.ToDecimal(amc) : 0); //mos = Decimal.Round(mos, 1); int[] mon = { 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; long[] cons = new long[12]; for (int i = 0; i < mon.Length; i++) { int yr = (mon[i] > 10) ? dtCurrent.Year - 1 : dtCurrent.Year; if (!(yr == dtCurrent.Year && mon[i] > dtCurrent.Month && mon[i] < 11)) { cons[i] = bal.GetSOH(_itemId, storeId, mon[i], yr); } else cons[i] = 0; } string[] str = { drStr["StoreName"].ToString(), ((cons[0] != 0) ? cons[0].ToString("#,###") : "0"), ((cons[1] != 0) ? cons[1].ToString("#,###") : "0"), ((cons[2] != 0) ? cons[2].ToString("#,###") : "0"), ((cons[3] != 0) ? cons[3].ToString("#,###") : "0"), ((cons[4] != 0) ? cons[4].ToString("#,###") : "0"), ((cons[5] != 0) ? cons[5].ToString("#,###") : "0"), ((cons[6] != 0) ? cons[6].ToString("#,###") : "0"), ((cons[7] != 0) ? cons[7].ToString("#,###") : "0"), ((cons[8] != 0) ? cons[8].ToString("#,###") : "0"), ((cons[9] != 0) ? cons[9].ToString("#,###") : "0"), ((cons[10] != 0) ? cons[10].ToString("#,###") : "0"), ((cons[11] != 0) ? cons[11].ToString("#,###") : "0") }; ListViewItem lstItm = new ListViewItem(str); if (col != 0) { lstItm.BackColor = Color.FromArgb(233, 247, 248); col = 0; } else { col++; } //lstTrendSoh.Items.Add(lstItm); } //lstTrendSoh.Items.Add(new ListViewItem()); foreach (DataRow drDus in dtDus.Rows) { int duid = Convert.ToInt32(drDus["ID"]); //Int64 soh = bal.GetDUSOH(itemId, duid, dtCurrent.Month, dtCurrent.Year); //Int64 amc = bal.CalculateDUAMC(itemId, duid, dtCurrent.Month, dtCurrent.Year, 0); //Int64 issue = iss.GetDUIssueByMonth(itemId, duid, dtCurrent.Month, dtCurrent.Year); //decimal mos = ((amc > 0) ? Convert.ToDecimal(soh) / Convert.ToDecimal(amc) : 0); //mos = Decimal.Round(mos, 1); int[] mon = { 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; long[] cons = new long[12]; for (int i = 0; i < mon.Length; i++) { int yr = (mon[i] > 10) ? dtCurrent.Year - 1 : dtCurrent.Year; cons[i] = bal.GetDUSOH(_itemId, duid, mon[i], yr); } string[] str = { drDus["Name"].ToString(), ((cons[0] != 0) ? cons[0].ToString("#,###") : "0"), ((cons[1] != 0) ? cons[1].ToString("#,###") : "0"), ((cons[2] != 0) ? cons[2].ToString("#,###") : "0"), ((cons[3] != 0) ? cons[3].ToString("#,###") : "0"), ((cons[4] != 0) ? cons[4].ToString("#,###") : "0"), ((cons[5] != 0) ? cons[5].ToString("#,###") : "0"), ((cons[6] != 0) ? cons[6].ToString("#,###") : "0"), ((cons[7] != 0) ? cons[7].ToString("#,###") : "0"), ((cons[8] != 0) ? cons[8].ToString("#,###") : "0"), ((cons[9] != 0) ? cons[9].ToString("#,###") : "0"), ((cons[10] != 0) ? cons[10].ToString("#,###") : "0"), ((cons[11] != 0) ? cons[11].ToString("#,###") : "0") }; ListViewItem lstItm = new ListViewItem(str); if (col != 0) { lstItm.BackColor = Color.FromArgb(233, 247, 248); col = 0; } else { col++; } // lstTrendSoh.Items.Add(lstItm); } }
private void DetailMos() { //dtDate.Value = DateTime.Now; //dtDate.CustomFormat = "MM/dd/yyyy"; // DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text); ReceivingUnits du = new ReceivingUnits(); DataTable dtDus = du.GetApplicableDUsAll(_itemId); int col = 0; Balance bal = new Balance(); IssueDoc iss = new IssueDoc(); Stores stor = new Stores(); stor.GetActiveStores(); DataTable dtStores = stor.DefaultView.ToTable(); // lstTrendMos.Items.Clear(); foreach (DataRow drStr in dtStores.Rows) { int storeId = Convert.ToInt32(drStr["ID"]); //Int64 soh = bal.GetSOH(itemId, storeId, dtCurrent.Month, dtCurrent.Year); //Int64 amc = bal.CalculateAMC(itemId, storeId, dtCurrent.Month, dtCurrent.Year); //Int64 issue = iss.GetIssuedQuantityByMonth(itemId, storeId, dtCurrent.Month, dtCurrent.Year); //decimal mos = ((amc > 0) ? Convert.ToDecimal(soh) / Convert.ToDecimal(amc) : 0); //mos = Decimal.Round(mos, 1); int[] mon = { 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; decimal[] cons = new decimal[12]; for (int i = 0; i < mon.Length; i++) { int yr = (mon[i] > 10) ? _dtCurrent.Year - 1 : _dtCurrent.Year; if (!(yr == _dtCurrent.Year && mon[i] > _dtCurrent.Month && mon[i] < 11)) { Int64 soh = bal.GetSOH(_itemId, storeId, mon[i], yr); double amc = Builder.CalculateAverageConsumption(_itemId, _storeId, _dtCurrent.Subtract(TimeSpan.FromDays(180)), _dtCurrent, CalculationOptions.Monthly); decimal mos = ((amc != 0) ? Convert.ToDecimal(soh) / Convert.ToDecimal(amc) : 0); cons[i] = Decimal.Round(mos, 1); } else cons[i] = 0; } string[] str = { drStr["StoreName"].ToString(), ((cons[0] != 0) ? cons[0].ToString() : "0"), ((cons[1] != 0) ? cons[1].ToString() : "0"), ((cons[2] != 0) ? cons[2].ToString() : "0"), ((cons[3] != 0) ? cons[3].ToString() : "0"), ((cons[4] != 0) ? cons[4].ToString() : "0"), ((cons[5] != 0) ? cons[5].ToString() : "0"), ((cons[6] != 0) ? cons[6].ToString() : "0"), ((cons[7] != 0) ? cons[7].ToString() : "0"), ((cons[8] != 0) ? cons[8].ToString() : "0"), ((cons[9] != 0) ? cons[9].ToString() : "0"), ((cons[10] != 0) ? cons[10].ToString() : "0"), ((cons[11] != 0) ? cons[11].ToString() : "0") }; ListViewItem lstItm = new ListViewItem(str); if (col != 0) { lstItm.BackColor = Color.FromArgb(233, 247, 248); col = 0; } else { col++; } // lstTrendMos.Items.Add(lstItm); } // lstTrendMos.Items.Add(new ListViewItem()); foreach (DataRow drDus in dtDus.Rows) { int duid = Convert.ToInt32(drDus["ID"]); //Int64 soh = bal.GetDUSOH(itemId, duid, dtCurrent.Month, dtCurrent.Year); //Int64 amc = bal.CalculateDUAMC(itemId, duid, dtCurrent.Month, dtCurrent.Year, 0); //Int64 issue = iss.GetDUIssueByMonth(itemId, duid, dtCurrent.Month, dtCurrent.Year); //decimal mos = ((amc > 0) ? Convert.ToDecimal(soh) / Convert.ToDecimal(amc) : 0); //mos = Decimal.Round(mos, 1); int[] mon = { 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; decimal[] cons = new decimal[12]; for (int i = 0; i < mon.Length; i++) { int yr = (mon[i] > 10) ? _dtCurrent.Year - 1 : _dtCurrent.Year; Int64 soh = bal.GetDUSOH(_itemId, duid, mon[i], yr); double amc = Builder.CalculateAverageConsumption(_itemId, duid, _dtCurrent.Subtract(TimeSpan.FromDays(180)), _dtCurrent, CalculationOptions.Monthly);//bal.CalculateDUAMC(_itemId, duid, mon[i], yr, 0); decimal mos = ((amc != 0) ? Convert.ToDecimal(soh) / Convert.ToDecimal(amc) : 0); cons[i] = Decimal.Round(mos, 1); } string[] str = { drDus["Name"].ToString(), ((cons[0] != 0) ? cons[0].ToString() : "0"), ((cons[1] != 0) ? cons[1].ToString() : "0"), ((cons[2] != 0) ? cons[2].ToString() : "0"), ((cons[3] != 0) ? cons[3].ToString() : "0"), ((cons[4] != 0) ? cons[4].ToString() : "0"), ((cons[5] != 0) ? cons[5].ToString() : "0"), ((cons[6] != 0) ? cons[6].ToString() : "0"), ((cons[7] != 0) ? cons[7].ToString() : "0"), ((cons[8] != 0) ? cons[8].ToString() : "0"), ((cons[9] != 0) ? cons[9].ToString() : "0"), ((cons[10] != 0) ? cons[10].ToString() : "0"), ((cons[11] != 0) ? cons[11].ToString() : "0") }; ListViewItem lstItm = new ListViewItem(str); if (col != 0) { lstItm.BackColor = Color.FromArgb(233, 247, 248); col = 0; } else { col++; } // lstTrendMos.Items.Add(lstItm); } }
private void PopulateLogisticSummary() { //dtDate.Value = DateTime.Now; // dtDate.CustomFormat = "MM/dd/yyyy"; //DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text); ReceivingUnits du = new ReceivingUnits(); DataTable dtDus = du.GetApplicableDUsAll(_itemId); Balance bal = new Balance(); IssueDoc iss = new IssueDoc(); Stores stor = new Stores(); stor.GetActiveStores(); DataTable dtStores = stor.DefaultView.ToTable(); DataTable dtbl = new DataTable(); dtbl.Columns.Add("StoreName"); dtbl.Columns.Add("SOH"); dtbl.Columns.Add("AMC"); dtbl.Columns.Add("Issue"); dtbl.Columns.Add("MOS"); foreach (DataRow drStr in dtStores.Rows) { int storeId = Convert.ToInt32(drStr["ID"]); Int64 soh = bal.GetSOH(_itemId, storeId, _dtCurrent.Month, _dtCurrent.Year); double amc = Builder.CalculateAverageConsumption(_itemId, storeId, _dtCurrent.Subtract(TimeSpan.FromDays(180)), _dtCurrent, CalculationOptions.Monthly); //bal.CalculateAMC(_itemId, storeId, _dtCurrent.Month, _dtCurrent.Year); //Builder.CalculateAverageConsumption(_itemId, storeId,dtCurrent.Subtract(TimeSpan.FromDays(180)),dtCurrent,CalculationOptions.Monthly); //bal.CalculateAMC(_itemId, storeId, _dtCurrent.Month, _dtCurrent.Year); Int64 issue = iss.GetIssuedQuantityByMonth(_itemId, storeId, _dtCurrent.Month, _dtCurrent.Year); decimal mos = ((amc > 0) ? Convert.ToDecimal(soh) / Convert.ToDecimal(amc) : 0); mos = Decimal.Round(mos, 1); string[] str = { drStr["StoreName"].ToString(), ((soh != 0) ? soh.ToString("#,###") : "0"), ((amc != 0) ? amc.ToString("#,###") : "0"), ((issue != 0) ? issue.ToString("#,###") : "0"), mos.ToString() }; dtbl.Rows.Add(str); } foreach (DataRow drDus in dtDus.Rows) { int duid = Convert.ToInt32(drDus["ID"]); Int64 soh = bal.GetDUSOH(_itemId, duid, _dtCurrent.Month, _dtCurrent.Year); double amc = Builder.CalculateAverageConsumption(_itemId, duid, _dtCurrent.Subtract(TimeSpan.FromDays(180)), _dtCurrent, CalculationOptions.Monthly);//bal.CalculateDUAMC(_itemId, duid, _dtCurrent.Month, _dtCurrent.Year, 0); Int64 issue = iss.GetDUIssueByMonth(_itemId, duid, _dtCurrent.Month, _dtCurrent.Year); decimal mos = ((amc > 0) ? Convert.ToDecimal(soh) / Convert.ToDecimal(amc) : 0); mos = Decimal.Round(mos, 1); string[] str = { drDus["Name"].ToString(), ((soh != 0) ? soh.ToString("#,###") : "0"), ((amc != 0) ? amc.ToString("#,###") : "0"), ((issue != 0) ? issue.ToString("#,###") : "0"), mos.ToString() }; dtbl.Rows.Add(str); } gridDispensaryView.DataSource = dtbl; }
/// <summary> /// Generates the charts one by one. /// </summary> /// <param name="du"></param> private void GenerateCharts(int du) { Balance bal = new Balance(); GeneralInfo info = new GeneralInfo(); info.LoadAll(); DataTable dtList = new DataTable(); DataTable dtAmc = new DataTable(); DataTable dtMOS = new DataTable(); DataTable dtIss = new DataTable(); DataTable dtRec = new DataTable(); DataTable dtBB = new DataTable(); //CALENDAR: // DataTable dtCons = new DataTable(); string[] co = { "Ham", "Neh", "Mes", "Tek", "Hed", "Tah", "Tir", "Yek", "Meg", "Miz", "Gen", "Sen" }; //foreach(string s in co) //{ dtList.Columns.Add("Month"); dtList.Columns.Add("Value"); dtList.Columns[1].DataType = typeof(Int64); dtMOS.Columns.Add("Month"); dtMOS.Columns.Add("Value"); dtMOS.Columns[1].DataType = typeof(decimal); dtAmc.Columns.Add("Month"); dtAmc.Columns.Add("Value"); dtAmc.Columns[1].DataType = typeof(Int64); dtIss.Columns.Add("Month"); dtIss.Columns.Add("Value"); dtIss.Columns[1].DataType = typeof(Int64); dtRec.Columns.Add("Month"); dtRec.Columns.Add("Value"); dtRec.Columns[1].DataType = typeof(Int64); dtBB.Columns.Add("Month"); dtBB.Columns.Add("Value"); dtBB.Columns[1].DataType = typeof(Int64); int[] mon = { 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; long[] cons = new long[12]; double[] amc = new double[12]; long[] con = new long[12]; long[] issval = new long[12]; DataTable dtBal = new DataTable(); IssueDoc issd = new IssueDoc(); Items recd = new Items(); YearEnd yEnd = new YearEnd(); Int64 bb = yEnd.GetBBalance(_year, _storeId, _itemId, 10); object[] objBB = { "Ham", bb }; dtBB.Rows.Add(objBB); //dtDate.Value = DateTime.Now; //dtDate.CustomFormat = "MM/dd/yyyy"; //DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text); for (int i = 0; i < mon.Length; i++) { int cMonth = _dtCurrent.Month; //if (!(year == dtCurrent.Year && mon[i] > dtCurrent.Month && mon[i] < 11)) if (((mon[i] == 11 || mon[i] == 12) && (mon[i] <= cMonth || _year == _dtCurrent.Year)) || (mon[i] < 11 && mon[i] <= cMonth && _year == _dtCurrent.Year)) { int yr = (mon[i] < 11) ? _year : _year - 1; // dtBal = bal.GetSOH(itemId,storeId,mon[i],yr); con[i] = ((du == 0) ? bal.GetSOH(_itemId, _storeId, mon[i], yr) : bal.GetDUSOH(_itemId, du, mon[i], yr)); object xSOH = null; if (con[i] == 0) { for (int li = i; li >= 0; li--) { if (con[li] != 0) { xSOH = 0; break; } } } else xSOH = con[i]; object[] str = { co[i], xSOH }; amc[i] = ((du == 0) ? Builder.CalculateAverageConsumption(_itemId, _storeId, _dtCurrent.Subtract(TimeSpan.FromDays(180)), _dtCurrent, CalculationOptions.Monthly) : bal.CalculateDUAMC(_itemId, du, mon[i], yr, 0));//bal.CalculateAMC(_itemId, _storeId, mon[i], yr) object xAmc = null; if (amc[i] == 0) { for (int li = i; li >= 0; li--) { if (amc[li] != 0) { xAmc = 0; break; } } } else xAmc = amc[i]; object[] objAmc = { co[i], xAmc }; // for mos check the diff b/n null and zero // And also mos = soh/amc right??? decimal mos = (amc[i] > 0) ? (Convert.ToDecimal(con[i]) / Convert.ToDecimal(amc[i])) : 0; object[] objMos = { co[i], mos }; int fYear = (mon[i] < 11) ? yr : yr - 1; issval[i] = ((du == 0) ? issd.GetIssuedQuantityByMonth(_itemId, _storeId, mon[i], yr) : issd.GetDUConsumptionByMonth(_itemId, du, mon[i], yr)); object xIss = null; if (issval[i] == 0) { for (int li = i; li >= 0; li--) { if (issval[li] != 0) { xIss = 0; break; } } } else xIss = issval[i]; object[] objIss = { co[i], xIss }; Int64 recVal = ((du == 0) ? recd.GetQuantityReceiveByItemPerMonth(mon[i], _itemId, _storeId, yr) : issd.GetDUReceiveByMonth(_itemId, du, mon[i], yr)); object[] objrec = { co[i], recVal }; dtList.Rows.Add(str); dtAmc.Rows.Add(objAmc); dtMOS.Rows.Add(objMos); dtIss.Rows.Add(objIss); dtRec.Rows.Add(objrec); } } // string[] str = { ((cons[0] != 0) ? cons[0].ToString("") : "0"), ((cons[1] != 0) ? cons[1].ToString() : "0"), ((cons[2] != 0) ? cons[2].ToString() : "0"), ((cons[3] != 0) ? cons[3].ToString() : "0"), ((cons[4] != 0) ? cons[4].ToString() : "0"), ((cons[5] != 0) ? cons[5].ToString() : "0"), ((cons[6] != 0) ? cons[6].ToString() : "0"), ((cons[7] != 0) ? cons[7].ToString() : "0"), ((cons[8] != 0) ? cons[8].ToString() : "0"), ((cons[9] != 0) ? cons[9].ToString() : "0"), ((cons[10] != 0) ? cons[10].ToString() : "0"), ((cons[11] != 0) ? cons[11].ToString() : "0")}; chartAmc.Series.Clear(); //AMC chartComp.Series.Clear();//Activity chartBar.Series.Clear(); //SOH chartMOS.Series.Clear(); // MOS consuTrend.Series.Clear(); Series ser = new Series("Stock On Hand", ViewType.Line); ser.DataSource = dtList; ser.ArgumentScaleType = ScaleType.Qualitative; ser.ArgumentDataMember = "Month"; ser.ValueScaleType = ScaleType.Numerical; ser.PointOptions.ValueNumericOptions.Format = NumericFormat.Number; ser.PointOptions.ValueNumericOptions.Precision = 0; ser.ValueDataMembers.AddRange(new string[] { "Value" }); chartBar.Series.Add(ser); ((XYDiagram)chartBar.Diagram).AxisY.NumericOptions.Format = NumericFormat.Number; ((XYDiagram)chartBar.Diagram).AxisY.NumericOptions.Precision = 0; Series serB = new Series("Begining Balance", ViewType.Bar); serB.DataSource = dtBB; serB.ArgumentScaleType = ScaleType.Qualitative; serB.ArgumentDataMember = "Month"; serB.ValueScaleType = ScaleType.Numerical; serB.PointOptions.ValueNumericOptions.Format = NumericFormat.Number; serB.PointOptions.ValueNumericOptions.Precision = 0; serB.ValueDataMembers.AddRange(new string[] { "Value" }); chartComp.Series.Add(serB); Series serRec = new Series("Received Qty", ViewType.Bar); serRec.DataSource = dtRec; serRec.ArgumentScaleType = ScaleType.Qualitative; serRec.ArgumentDataMember = "Month"; serRec.ValueScaleType = ScaleType.Numerical; serRec.PointOptions.ValueNumericOptions.Format = NumericFormat.Number; serRec.PointOptions.ValueNumericOptions.Precision = 0; serRec.ValueDataMembers.AddRange(new string[] { "Value" }); chartComp.Series.Add(serRec); Series serAmc = new Series("AMC", ViewType.Line); serAmc.DataSource = dtAmc; serAmc.ArgumentScaleType = ScaleType.Qualitative; serAmc.ArgumentDataMember = "Month"; serAmc.ValueScaleType = ScaleType.Numerical; serAmc.PointOptions.ValueNumericOptions.Format = NumericFormat.Number; serAmc.PointOptions.ValueNumericOptions.Precision = 0; serAmc.ValueDataMembers.AddRange(new string[] { "Value" }); chartAmc.Series.Add(serAmc); ((XYDiagram)chartAmc.Diagram).AxisY.NumericOptions.Format = NumericFormat.Number; ((XYDiagram)chartAmc.Diagram).AxisY.NumericOptions.Precision = 0; Series serIss = new Series("Issue Qty", ViewType.Bar); serIss.DataSource = dtIss; serIss.ArgumentScaleType = ScaleType.Qualitative; serIss.ArgumentDataMember = "Month"; serIss.ValueScaleType = ScaleType.Numerical; serIss.PointOptions.ValueNumericOptions.Format = NumericFormat.Number; serIss.PointOptions.ValueNumericOptions.Precision = 0; serIss.ValueDataMembers.AddRange(new string[] { "Value" }); chartComp.Series.Add(serIss); //Int64 amcCurent = bal.CalculateAMC(_itemId, _storeId, _dtCurrent.Month, _dtCurrent.Year); double amcCurent = Builder.CalculateAverageConsumption(_itemId, _storeId, _dtCurrent.Subtract(TimeSpan.FromDays(180)), _dtCurrent, CalculationOptions.Monthly); double min = info.Min * amcCurent; double max = info.Max * amcCurent; Int64 nearEOP = Convert.ToInt64(amcCurent * (info.EOP + 0.25)); ConstantLine target = new ConstantLine(); ConstantLine targetEOP = new ConstantLine(); target.AxisValue = min; //which min and max to show month ((XYDiagram)chartComp.Diagram).AxisY.ConstantLines.Clear(); target.Visible = true; target.Title.Text = "Current Min value is " + Convert.ToInt64(target.AxisValue).ToString("#,###") + " " + lblBUnit.Text; target.Color = Color.Red; target.LineStyle.Thickness = 2; target.LegendText = "Min"; ((XYDiagram)chartComp.Diagram).AxisY.ConstantLines.Add(target); targetEOP = new ConstantLine(); targetEOP.AxisValue = nearEOP; //which min and max to show month //((XYDiagram)chartBar.Diagram).AxisY.ConstantLines.Clear(); targetEOP.Visible = true; targetEOP.Title.Text = "Current EOP value is " + Convert.ToInt64(targetEOP.AxisValue).ToString("#,###") + " " + lblBUnit.Text; targetEOP.Color = Color.Yellow; targetEOP.LineStyle.Thickness = 2; targetEOP.LegendText = "EOP"; ((XYDiagram)chartComp.Diagram).AxisY.ConstantLines.Add(targetEOP); ConstantLine targetMax = new ConstantLine(); targetMax.AxisValue = max; //which min and max to show month targetMax.Visible = true; targetMax.Title.Text = "Current Max value is " + Convert.ToInt64(targetMax.AxisValue).ToString("#,###") + " " + lblBUnit.Text; targetMax.Color = Color.Blue; targetMax.LineStyle.Thickness = 2; targetMax.LegendText = "Max"; ((XYDiagram)chartComp.Diagram).AxisY.ConstantLines.Add(targetMax); Series sercons = new Series("Consumption", ViewType.Line); sercons.DataSource = dtIss; sercons.ArgumentScaleType = ScaleType.Qualitative; sercons.ArgumentDataMember = "Month"; sercons.ValueScaleType = ScaleType.Numerical; sercons.PointOptions.ValueNumericOptions.Format = NumericFormat.Number; sercons.PointOptions.ValueNumericOptions.Precision = 0; sercons.ValueDataMembers.AddRange(new string[] { "Value" }); consuTrend.Series.Add(sercons); ((XYDiagram)consuTrend.Diagram).AxisY.NumericOptions.Format = NumericFormat.Number; ((XYDiagram)consuTrend.Diagram).AxisY.NumericOptions.Precision = 0; Series serSOH = new Series("SOH", ViewType.Bar); serSOH.DataSource = dtList; serSOH.ArgumentScaleType = ScaleType.Qualitative; serSOH.ArgumentDataMember = "Month"; serSOH.ValueScaleType = ScaleType.Numerical; serSOH.PointOptions.ValueNumericOptions.Format = NumericFormat.Number; ((XYDiagram)chartComp.Diagram).AxisY.NumericOptions.Format = NumericFormat.Number; ((XYDiagram)chartComp.Diagram).AxisY.NumericOptions.Precision = 0; serSOH.PointOptions.ValueNumericOptions.Precision = 0; serSOH.ValueDataMembers.AddRange(new string[] { "Value" }); chartComp.Series.Add(serSOH); Series serMos = new Series("Month Of Stock", ViewType.Line); serMos.DataSource = dtMOS; serMos.ArgumentScaleType = ScaleType.Qualitative; serMos.ArgumentDataMember = "Month"; serMos.ValueScaleType = ScaleType.Numerical; serMos.PointOptions.ValueNumericOptions.Format = NumericFormat.FixedPoint; serMos.PointOptions.ValueNumericOptions.Precision = 1; serMos.ValueDataMembers.AddRange(new string[] { "Value" }); chartMOS.Series.Add(serMos); if (Convert.ToInt32(((XYDiagram)chartMOS.Diagram).AxisY.Range.MaxValue) <= 12) { ((XYDiagram)chartMOS.Diagram).AxisY.Range.MaxValue = 12; } //Int64 soh = bal.GetSOH(itemId,storeId,dtCurrent.Month,year); //if (bal.RowCount > 0) //{ //Int64 amcCurent = bal.CalculateAMC(_itemId, _storeId, _dtCurrent.Month, _year); amcCurent = Builder.CalculateAverageConsumption(_itemId, _storeId, _dtCurrent.Subtract(TimeSpan.FromDays(180)), _dtCurrent, CalculationOptions.Monthly); min = info.Min * amcCurent; max = info.Max * amcCurent; nearEOP = Convert.ToInt64(amcCurent * (info.EOP + 0.25)); target = new ConstantLine(); target.AxisValue = min; //which min and max to show month ((XYDiagram)chartBar.Diagram).AxisY.ConstantLines.Clear(); target.Visible = true; target.Title.Text = "Current Min value is " + Convert.ToInt64(target.AxisValue).ToString("#,###") + " " + lblBUnit.Text; target.Color = Color.Red; target.LineStyle.Thickness = 2; target.LegendText = "Min"; ((XYDiagram)chartBar.Diagram).AxisY.ConstantLines.Add(target); targetEOP = new ConstantLine(); targetEOP.AxisValue = nearEOP; //which min and max to show month //((XYDiagram)chartBar.Diagram).AxisY.ConstantLines.Clear(); targetEOP.Visible = true; targetEOP.Title.Text = "Current EOP value is " + Convert.ToInt64(targetEOP.AxisValue).ToString("#,###") + " " + lblBUnit.Text; targetEOP.Color = Color.Yellow; targetEOP.LineStyle.Thickness = 2; targetEOP.LegendText = "EOP"; ((XYDiagram)chartBar.Diagram).AxisY.ConstantLines.Add(targetEOP); targetMax = new ConstantLine(); targetMax.AxisValue = max; //which min and max to show month targetMax.Visible = true; targetMax.Title.Text = "Current Max value is " + Convert.ToInt64(targetMax.AxisValue).ToString("#,###") + " " + lblBUnit.Text; targetMax.Color = Color.Blue; targetMax.LineStyle.Thickness = 2; targetMax.LegendText = "Max"; ((XYDiagram)chartBar.Diagram).AxisY.ConstantLines.Add(targetMax); ConstantLine targetMos = new ConstantLine(); ConstantLine targetMosMin = new ConstantLine(); ((XYDiagram)chartMOS.Diagram).AxisY.ConstantLines.Clear(); targetMos = new ConstantLine(); targetMos.AxisValue = info.Max; //which min and max to show month targetMos.Visible = true; targetMos.Title.Text = "Current Max is " + info.Max.ToString() + " months"; targetMos.Color = Color.Blue; targetMos.LineStyle.Thickness = 2; targetMos.LegendText = "Max"; ((XYDiagram)chartMOS.Diagram).AxisY.ConstantLines.Add(targetMos); targetMosMin = new ConstantLine(); targetMosMin.AxisValue = info.Min; //which min and max to show month targetMosMin.Visible = true; targetMosMin.Title.Text = "Current Min is " + info.Min.ToString() + " months"; targetMosMin.Color = Color.Red; targetMosMin.LineStyle.Thickness = 2; targetMosMin.LegendText = "Max"; ((XYDiagram)chartMOS.Diagram).AxisY.ConstantLines.Add(targetMosMin); //} // Generate the pie Chart for the Current SOH and EXpired Drugs ReceiveDoc rec = new ReceiveDoc(); chartPie.Series.Clear(); Items itm = new Items(); object[] objExp = itm.GetExpiredQtyAmountItemsByID(_itemId, _storeId); Int64 expAmount = Convert.ToInt64(objExp[0]); Double expCost = Convert.ToDouble(objExp[1]); object[] nearObj = itm.GetNearlyExpiredQtyAmountItemsByID(_itemId, _storeId); Int64 nearExpAmount = Convert.ToInt64(nearObj[0]); double nearExpCost = Convert.ToDouble(nearObj[1]); Int64 soh = bal.GetSOH(_itemId, _storeId, _dtCurrent.Month, _dtCurrent.Year); double sohPrice = bal.GetSOHAmount(_itemId, _storeId, _dtCurrent.Month, _dtCurrent.Year); Int64 normal = (soh - nearExpAmount - expAmount); Int64 nearExpiry = nearExpAmount; Int64 expired = expAmount; object[] obj = { normal, nearExpiry, expired }; DataTable dtSOHList = new DataTable(); dtSOHList.Columns.Add("Type"); dtSOHList.Columns.Add("Value"); dtSOHList.Columns[1].DataType = typeof(Int64); double normalPrice = (sohPrice - nearExpCost - expAmount); object[] oo = { "Normal : " + normalPrice.ToString("C"), obj[0] }; dtSOHList.Rows.Add(oo); object[] oo3 = { "Expired : " + expCost.ToString("C"), obj[2] }; dtSOHList.Rows.Add(oo3); object[] oo2 = { "Near Expiry : " + nearExpCost.ToString("C"), obj[1] }; dtSOHList.Rows.Add(oo2); Series serExpired = new Series("pie", ViewType.Pie3D); if (!(Convert.ToInt32(obj[0]) == 0 && Convert.ToInt32(obj[1]) == 0 && Convert.ToInt32(obj[2]) == 0)) { serExpired.DataSource = dtSOHList; serExpired.ArgumentScaleType = ScaleType.Qualitative; serExpired.ArgumentDataMember = "Type"; serExpired.ValueScaleType = ScaleType.Numerical; serExpired.ValueDataMembers.AddRange(new string[] { "Value" }); serExpired.PointOptions.PointView = PointView.ArgumentAndValues; serExpired.LegendText = "Key"; serExpired.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent; serExpired.PointOptions.ValueNumericOptions.Precision = 0; ((PieSeriesLabel)serExpired.Label).Position = PieSeriesLabelPosition.TwoColumns; // ((PieSeriesLabel)serExpired.Label).ColumnIndent = 2; ((PiePointOptions)serExpired.PointOptions).PointView = PointView.ArgumentAndValues; // ((PiePointOptions)serExpired.PointOptions).Separator = " , "; chartPie.Series.Add(serExpired); chartPie.Size = new System.Drawing.Size(1000, 500); } }