private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { var view = sender as GridView; if (view == null) return; var iu = new ItemUnit(); if ((view.FocusedColumn.FieldName == "Pack Qty") || (view.FocusedColumn.FieldName == "Qty Per Pack") || (view.FocusedColumn.FieldName == "DU Remaining SOH")) { DataRow dr = issueGridView.GetDataRow(issueGridView.GetSelectedRows()[0]); int qty = Convert.ToInt32(dr["Pack Qty"]); int qtyPerpack = Convert.ToInt32(dr["Qty Per Pack"]); switch (VisibilitySetting.HandleUnits) { case 2: { iu.LoadByPrimaryKey(Convert.ToInt32(dr["UnitID"])); var qtyperunit = iu.QtyPerUnit; dr["Qty Per Pack"] = qtyperunit; dr["Requested Qty"] = qty; } break; case 3: { iu.LoadByPrimaryKey(Convert.ToInt32(dr["UnitID"])); var qtyperunit = iu.QtyPerUnit; dr["Qty Per Pack"] = qtyperunit; dr["Requested Qty"] = qty; } break; case 1: dr["Qty Per Pack"] = qtyPerpack; dr["Requested Qty"] = (qtyPerpack * qty); break; } DateTime xx = dtIssueDate.Value; dtIssueDate.Value = DateTime.Now; dtIssueDate.CustomFormat = "MM/dd/yyyy"; DateTime dtCurrent = ConvertDate.DateConverter(dtIssueDate.Text); dtIssueDate.Value = xx; var bal = new Balance(); var receivingUnit = Convert.ToInt32(cboReceivingUnits.EditValue); Int64 duAmc = 0; int itmId = Convert.ToInt32(dr["ID"]); int lstSOH = ((dr["DU Remaining SOH"] != null && dr["DU Remaining SOH"] != DBNull.Value) ? Convert.ToInt32(dr["DU Remaining SOH"]) : 0); duAmc = bal.CalculateDUAMC(itmId, receivingUnit, dtCurrent.Month, dtCurrent.Year, lstSOH); dr["DU AMC"] = duAmc; //recommend qty to du var DUs = new ReceivingUnits(); DUs.LoadByPrimaryKey(receivingUnit); double dumax = 0.5; try { dumax = DUs.Max; } catch { } double recQty = (Convert.ToInt32(dr["DU AMC"]) * dumax) - lstSOH; dr["Recommended Qty"] = ((recQty > 0) ? Convert.ToInt64(recQty) : 0); } }
private void DetailAmc() { //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(); //lstTrendAmc.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 }; 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.CalculateAMC(_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++; } //lstTrendAmc.Items.Add(lstItm); } //lstTrendAmc.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; if (!(yr == _dtCurrent.Year && mon[i] > _dtCurrent.Month && mon[i] < 11)) { cons[i] = bal.CalculateDUAMC(_itemId, duid, mon[i], yr, 0); } else cons[i] = 0; } 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++; } // lstTrendAmc.Items.Add(lstItm); } }
private void cboReceivingUnits_SelectedValueChanged(object sender, EventArgs e) { DataTable issGrid = (DataTable)issueGrid.DataSource; if (issGrid != null) { if (cboReceivingUnits.EditValue != null && issGrid.Rows.Count > 0) { DateTime xx = dtIssueDate.Value; dtIssueDate.Value = DateTime.Now; dtIssueDate.CustomFormat = "MM/dd/yyyy"; DateTime dtCurrent = ConvertDate.DateConverter(dtIssueDate.Text); dtIssueDate.Value = xx; var iss = new IssueDoc(); var bal = new Balance(); int receivingUnit = Convert.ToInt32(cboReceivingUnits.EditValue); var DUs = new ReceivingUnits(); DUs.LoadByPrimaryKey(receivingUnit); double dumax = 0.5; try { dumax = DUs.Max; } catch(Exception EX) { } for (int i = 0; i < issGrid.Rows.Count; i++) { int itmId = Convert.ToInt32(issGrid.Rows[i]["ID"]); int lastIssueQty = iss.GetDULastIssueQty(itmId, receivingUnit); int lastDUSOH = iss.GetDULastSOH(itmId, receivingUnit); issGrid.Rows[i]["MR Issue Qty"] = lastIssueQty; issGrid.Rows[i]["MR DU SOH"] = lastDUSOH; const int lstSOH = 0; issGrid.Rows[i]["DU Remaining SOH"] = 0; int yer = (dtCurrent.Month < 11) ? dtCurrent.Year : dtCurrent.Year - 1; Int64 duAmc = bal.CalculateDUAMC(itmId, receivingUnit, dtCurrent.Month, dtCurrent.Year, lstSOH); issGrid.Rows[i]["DU AMC"] = duAmc; double recQty = (duAmc * dumax) - Convert.ToInt32(issGrid.Rows[i]["DU Remaining SOH"]); issGrid.Rows[i]["Recommended Qty"] = ((recQty > 0) ? Convert.ToInt64(recQty) : 0); } } } }
/// <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); } }