Example #1
0
        private void btnDoEndOfYear_Click(object sender, EventArgs e)
        {
            var result = XtraMessageBox.Show("Are you sure you want to perform the year End activity automatically?",
                                             "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            var confirm =
                XtraMessageBox.Show(
                    "Performing the year end automatically will make HCMIS take the present stock as the beginning balance of the next fiscal year.  You will not be able to use the Inventory page to input inventory data.  Do you want to proceed?",
                    "Confirmation", MessageBoxButtons.YesNo);

            if (confirm == DialogResult.No)
            {
                return;
            }

            btnDoEndOfYear.Enabled = false;
            int      year   = ConvertDate.GetEthiopianYear(DateTimeHelper.ServerDateTime);
            Activity stores = new Activity();

            stores.LoadAll();

            BLL.CommodityType commodityType = new BLL.CommodityType();
            commodityType.LoadAll();

            while (!commodityType.EOF)
            {
                while (!stores.EOF)
                {
                    DataTable dtbl = Balance.GetSohForAllItems(stores.ID, commodityType.ID, year, 10);
                    YearEnd   ye   = new YearEnd();
                    foreach (DataRow dr in dtbl.Rows)
                    {
                        if (dr["ID"] == DBNull.Value || dr["UnitID"] == DBNull.Value)
                        {
                            continue;
                        }

                        ye.AddNew();

                        ye.ItemID  = Convert.ToInt32(dr["ID"]);
                        ye.UnitID  = Convert.ToInt32(dr["UnitID"]);
                        ye.StoreID = stores.ID;
                        ye.Year    = year;

                        ye.PhysicalInventory      = ye.EBalance = Convert.ToInt32(dr["SOH"]);
                        ye.PhysicalInventoryPrice = ye.EndingPrice = Convert.ToDecimal(Convert.ToDouble(dr["Price"]));
                        ye.Save();
                    }
                    stores.MoveNext();
                }
                commodityType.MoveNext();
            }
            XtraMessageBox.Show("Year End has been populated");
            btnDoEndOfYear.Enabled = !BLL.YearEnd.IsPerformedForYear(EthiopianDate.EthiopianDate.Now.Year);
        }
        public static BLL.Models.StockAvailabilityStatistics GetStockAvailabilityStats(int month, int year)
        {
            var commodityType= new CommodityType();
            commodityType.LoadAll();
            var activity = new BLL.Activity();
            activity.LoadByMode(Mode.Constants.HEALTH_PROGRAM);

            var overstocked = 0;
            var nearEOP = 0;
            var belowEOP = 0;
            var stockedOut = 0;
            var normal = 0;

            while(!commodityType.EOF)
            {
                activity.Rewind();
                while(!activity.EOF)
                {
                    DataTable tbl = GetSohForAllItems(activity.ID,
                                                      commodityType.ID, year, month);
                    overstocked += (from y in tbl.AsEnumerable() where y["Status"].ToString() == "Over Stocked" select y).Count();
                    nearEOP += (from y in tbl.AsEnumerable() where y["Status"].ToString() == "Near EOP" select y).Count();
                    belowEOP += (from y in tbl.AsEnumerable() where y["Status"].ToString() == "Below EOP" select y).Count();
                    stockedOut += (from y in tbl.AsEnumerable() where y["Status"].ToString() == "Stock Out" select y).Count();
                    normal += (from y in tbl.AsEnumerable() where y["Status"].ToString() == "Normal" select y).Count();

                    activity.MoveNext();
                }
                commodityType.MoveNext();
            }

            var statistics = new StockAvailabilityStatistics(overstocked, normal, nearEOP, belowEOP, stockedOut);
            return statistics;
        }
        private void btnDoEndOfYear_Click(object sender, EventArgs e)
        {
            var result = XtraMessageBox.Show("Are you sure you want to perform the year End activity automatically?",
                                             "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if(result==System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            var confirm =
                XtraMessageBox.Show(
                    "Performing the year end automatically will make HCMIS take the present stock as the beginning balance of the next fiscal year.  You will not be able to use the Inventory page to input inventory data.  Do you want to proceed?",
                    "Confirmation", MessageBoxButtons.YesNo);
            if(confirm==DialogResult.No)
            {
                return;
            }

            btnDoEndOfYear.Enabled = false;
            int year = ConvertDate.GetEthiopianYear(DateTimeHelper.ServerDateTime);
            Activity stores = new Activity();
            stores.LoadAll();

            BLL.CommodityType commodityType = new BLL.CommodityType();
            commodityType.LoadAll();

            while (!commodityType.EOF)
            {
                while (!stores.EOF)
                {
                    DataTable dtbl = Balance.GetSohForAllItems(stores.ID, commodityType.ID, year, 10);
                    YearEnd ye = new YearEnd();
                    foreach (DataRow dr in dtbl.Rows)
                    {
                        if (dr["ID"] == DBNull.Value || dr["UnitID"] == DBNull.Value)
                            continue;

                        ye.AddNew();

                        ye.ItemID = Convert.ToInt32(dr["ID"]);
                        ye.UnitID = Convert.ToInt32(dr["UnitID"]);
                        ye.StoreID = stores.ID;
                        ye.Year = year;

                        ye.PhysicalInventory = ye.EBalance = Convert.ToInt32(dr["SOH"]);
                        ye.PhysicalInventoryPrice = ye.EndingPrice = Convert.ToDecimal(Convert.ToDouble(dr["Price"]));
                        ye.Save();
                    }
                    stores.MoveNext();
                }
                commodityType.MoveNext();
            }
            XtraMessageBox.Show("Year End has been populated");
            btnDoEndOfYear.Enabled = !BLL.YearEnd.IsPerformedForYear(EthiopianDate.EthiopianDate.Now.Year);
        }
 /// <summary>
 /// Gets all types.
 /// </summary>
 /// <returns></returns>
 public static DataTable GetAllTypes()
 {
     BLL.CommodityType commodityType = new CommodityType();
     commodityType.LoadAll();
     return(commodityType.DataTable);
 }
 /// <summary> 
 /// Gets all types.
 /// </summary>
 /// <returns></returns>
 public static DataTable GetAllTypes()
 {
     BLL.CommodityType commodityType = new CommodityType();
     commodityType.LoadAll();
     return commodityType.DataTable;
 }