Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the processing of balance
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnProcessBalance_Click(object sender, EventArgs e)
        {
            Items   itm  = new Items();
            YearEnd yEnd = new YearEnd();
            Balance bal  = new Balance();

            DataTable dtItm = itm.GetAllItems(1);

            dtDate.Value = DateTime.Now;
            DateTime dtCurent = Convert.ToDateTime(dtDate.Text);

            foreach (DataRow dr in dtItm.Rows)
            {
                yEnd.AddNew();
                yEnd.StoreID           = Convert.ToInt32(cboStore.SelectedValue);
                yEnd.ItemID            = Convert.ToInt32(dr["ID"]);
                yEnd.Year              = Convert.ToInt32(cboYear.SelectedItem);
                yEnd.Month             = (Convert.ToInt32(cboYear.SelectedItem) == dtCurent.Year) ? dtCurent.Month : 10;
                yEnd.BBalance          = 0;
                yEnd.EBalance          = 0;
                yEnd.PhysicalInventory = 0;
                yEnd.Save();
            }
        }
Ejemplo n.º 3
0
        private bool SaveInventory()
        {
            var yEnd = new YearEnd();
            var rec  = new ReceiveDoc();

            if (IsValid())
            {
                dtDate.Value = DateTime.Now;
                DateTime dtCurent = new DateTime();
                dtDate.CustomFormat = "MM/dd/yyyy";
                dtCurent            = ConvertDate.DateConverter(dtDate.Text);

                int year = dtCurent.Year;
                if (XtraMessageBox.Show("Are You Sure, You want to save this Transaction?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    DataTable yearEndTable = (DataTable)grdYearEnd.DataSource;

                    for (int i = 0; i < dtBB.Rows.Count; i++)
                    {
                        int id      = 0;
                        int storeID = Convert.ToInt32(cboStores.EditValue);
                        if (dtBB.Rows[i]["ItemID"] != DBNull.Value)
                        {
                            var itemID = Convert.ToInt32(dtBB.Rows[i]["ItemID"]);
                            var unitID = Convert.ToInt32(dtBB.Rows[i]["UnitID"]);
                            id = yEnd.LoadByItemIDStoreAndYearAndUnit(itemID, storeID, year, false, unitID);
                        }
                        if (id != 0 && !ReferenceEquals(yearEndTable.Rows[i]["Physical Inventory"], string.Empty))//There is already a manual entry in the yearend table.
                        {
                            //yEnd.LoadByPrimaryKey(id);
                            yEnd.BBalance          = Convert.ToInt64(FilterNumbers(yearEndTable.Rows[i]["Beginning Balance"].ToString()));
                            yEnd.EBalance          = Int64.Parse(FilterNumbers(yearEndTable.Rows[i]["Ending Balance(SOH)"].ToString()), NumberStyles.AllowThousands);
                            yEnd.PhysicalInventory = Convert.ToInt64(FilterNumbers(yearEndTable.Rows[i]["Physical Inventory"].ToString()));
                            //yEnd.BatchNo = yearEndTable.Rows[i]["Batch No."].ToString();
                            yEnd.UnitID = Convert.ToInt32(yearEndTable.Rows[i]["UnitID"]);
                            yEnd.Remark = yearEndTable.Rows[i]["Remark"].ToString();
                            yEnd.AutomaticallyEntered = false;
                            yEnd.Save();
                        }
                        else//There is no entry in the yearend table under this item name that has been entered manually.
                        {
                            DataRow cRow = dtBB.Rows[i];
                            if (!ReferenceEquals(cRow["Physical Inventory"], string.Empty) && cRow["ItemID"] != DBNull.Value)
                            {
                                var itemID = Convert.ToInt32(cRow["ItemID"]);
                                var unitID = Convert.ToInt32(cRow["UnitID"]);
                                YearEnd.PurgeAutomaticallyEnteredInventoryForUnit(itemID, storeID, year, unitID);

                                yEnd.AddNew();
                                yEnd.ItemID   = itemID;
                                yEnd.StoreID  = storeID;
                                yEnd.Year     = year;
                                yEnd.BBalance = Convert.ToInt64(cRow["Beginning Balance"]);
                                Int64 endBal = Convert.ToInt64(cRow["Ending Balance(SOH)"]);
                                yEnd.EBalance = endBal;// Convert.ToInt64(yearEndTable.Rows[i].Cells[5].Value);

                                if (cRow["Physical Inventory"] != DBNull.Value)
                                {
                                    yEnd.PhysicalInventory = Convert.ToInt64(cRow["Physical Inventory"]);
                                }

                                yEnd.UnitID = Convert.ToInt32(cRow["UnitID"]);
                                yEnd.Remark = cRow["Remark"].ToString();

                                yEnd.AutomaticallyEntered = cRow["Physical Inventory"] == DBNull.Value;
                                yEnd.Save();

                                //long physicalInventoryTotal = 0;
                                //bool areAllBatchesPhyInventoryNullValue = true;
                                //if (endBal != yEnd.PhysicalInventory)
                                if (true)
                                {
                                    int k = i + 1;

                                    if (k < dtBB.Rows.Count)
                                    {
                                        while (Convert.ToInt32(dtBB.Rows[k]["RecID"]) != -1)
                                        {
                                            if (dtBB.Rows[k]["Physical Inventory"] != DBNull.Value)
                                            {
                                                //areAllBatchesPhyInventoryNullValue = false;
                                                long batchPhysicalInventory =
                                                    Convert.ToInt64(dtBB.Rows[k]["Physical Inventory"]);
                                                //physicalInventoryTotal += batchPhysicalInventory;
                                                rec.LoadByPrimaryKey(Convert.ToInt32(dtBB.Rows[k]["RecID"]));
                                                rec.QuantityLeft = Convert.ToInt64(batchPhysicalInventory);
                                                rec.Remark       = "Physical Inventory";
                                                rec.UnitID       = Convert.ToInt32(dtBB.Rows[k]["UnitID"]);
                                                rec.Out          = rec.QuantityLeft == 0;
                                                rec.Save();
                                            }
                                            k++;
                                            if (k >= yearEndTable.Rows.Count)
                                            {
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    XtraMessageBox.Show("Transaction Successfully Saved!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        private void BtnAddBatchClick(object sender, EventArgs e)
        {
            if (!dxValidationProvider1.Validate())
            {
                return;
            }
            var rec  = new ReceiveDoc();
            var yEnd = new YearEnd();

            switch (VisibilitySetting.HandleUnits)
            {
            case 1:
            {
                rec.AddNew();
                rec.ItemID       = _itemid;
                rec.BatchNo      = txtBatchNo.Text;
                rec.StoreID      = _storeid;
                rec.ExpDate      = (DateTime)dateEditExpiryDate.EditValue;
                rec.Date         = _date;
                rec.UnitID       = 0;
                rec.RefNo        = txtRefNo.Text;
                rec.Out          = false;
                rec.EurDate      = DateTime.Now.Subtract(TimeSpan.FromDays(35));
                rec.NoOfPack     = Convert.ToInt32(txtPackQty.Text);
                rec.QtyPerPack   = Convert.ToInt32(txtQtyPerPack.Text);
                rec.Quantity     = (Convert.ToInt32(txtPackQty.Text)) * (Convert.ToInt32(txtQtyPerPack.Text));
                rec.QuantityLeft = (Convert.ToInt32(txtPackQty.Text)) * (Convert.ToInt32(txtQtyPerPack.Text));
                rec.Cost         = Convert.ToDouble(txtPrice.Text);
                rec.Save();

                yEnd.AddNew();
                yEnd.ItemID  = _itemid;
                yEnd.StoreID = _storeid;
                yEnd.Year    = _date.Year;
                yEnd.AutomaticallyEntered = true;
                yEnd.BBalance             = 0;
                yEnd.EBalance             = 0;
                yEnd.Save();
            }
            break;

            default:
            {
                rec.AddNew();
                rec.ItemID       = _itemid;
                rec.BatchNo      = txtBatchNo.Text;
                rec.StoreID      = _storeid;
                rec.UnitID       = _unitid;
                rec.ExpDate      = (DateTime)dateEditExpiryDate.EditValue;
                rec.NoOfPack     = Convert.ToInt32(txtPackQty.Text);
                rec.Quantity     = Convert.ToInt32(txtPackQty.Text);
                rec.QuantityLeft = Convert.ToInt32(txtPackQty.Text);
                rec.QtyPerPack   = Convert.ToInt32(txtQtyPerPack.Text);
                rec.Date         = _date;
                rec.RefNo        = txtRefNo.Text;
                rec.Out          = false;
                rec.EurDate      = DateTime.Now.Subtract(TimeSpan.FromDays(35));
                rec.Cost         = Convert.ToDouble(txtPrice.Text);
                rec.Save();

                yEnd.AddNew();
                yEnd.ItemID  = _itemid;
                yEnd.StoreID = _storeid;
                yEnd.UnitID  = _unitid;
                yEnd.AutomaticallyEntered = true;
                yEnd.BBalance             = 0;
                yEnd.EBalance             = 0;
                yEnd.Save();
            }
            break;
            }
            XtraMessageBox.Show("New Batch successfully added.", "Success");
            Close();
        }