private void BindFormElements()
 {
     Activity stores = new Activity();
     stores.LoadAll();
     cmbLogicalStore.Properties.DataSource = stores.DefaultView;
     stores.Rewind();
     cmbLogicalStore.EditValue = stores.ID;
     radioLogicalStore_SelectedIndexChanged(new object(), new EventArgs());
 }
Пример #2
0
 /// <summary>
 /// Generates the matrix for A new user.
 /// </summary>
 /// <param name="userID">The user ID.</param>
 public void GenerateMatrixForANewUser(int userID)
 {
     BLL.Activity store = new Activity();
     store.LoadAll();
     while (!store.EOF)
     {
         BLL.UserActivity usrStore = new UserActivity();
         usrStore.AddNew();
         usrStore.UserID     = userID;
         usrStore.ActivityID = store.ID;
         usrStore.CanAccess  = false;
         usrStore.IsDefault  = false;
         usrStore.Save();
         store.MoveNext();
     }
 }
 /// <summary>
 /// Generates the matrix for A new user.
 /// </summary>
 /// <param name="userID">The user ID.</param>
 public void GenerateMatrixForANewUser(int userID)
 {
     BLL.Activity store = new Activity();
     store.LoadAll();
     while (!store.EOF)
     {
         BLL.UserActivity usrStore = new UserActivity();
         usrStore.AddNew();
         usrStore.UserID = userID;
         usrStore.ActivityID = store.ID;
         usrStore.CanAccess = false;
         usrStore.IsDefault = false;
         usrStore.Save();
         store.MoveNext();
     }
 }
Пример #4
0
 /// <summary>
 /// Renews the matrix for A user.
 /// </summary>
 /// <param name="userID">The user ID.</param>
 public void RenewMatrixForAUser(int userID)
 {
     BLL.Activity store = new Activity();
     store.LoadAll();
     while (!store.EOF)
     {
         BLL.UserActivity usrStore = new UserActivity();
         this.LoadByUserAndStoreID(userID, store.ID);
         if (this.RowCount == 0)
         {
             usrStore.AddNew();
             usrStore.UserID     = userID;
             usrStore.ActivityID = store.ID;
             usrStore.CanAccess  = false;
             usrStore.IsDefault  = false;
             usrStore.Save();
         }
         store.MoveNext();
     }
 }
        private void GeneralReport_Load(object sender, EventArgs e)
        {
            Activity stor = new Activity();
            stor.LoadAll();
            DataTable dtStor = stor.DefaultView.ToTable();
            object[] obj = {0,1,"All"};
            //if(stor.RowCount > 1)
                //dtStor.Rows.Add(obj);
            cboStores.DataSource = dtStor;
            //if (stor.RowCount > 1)
            //    cboStores.SelectedValue = 0;

            dtDate.Value = DateTimeHelper.ServerDateTime;
            dtDate.CustomFormat = "MM/dd/yyyy";
            dtCurrent = ConvertDate.DateConverter(dtDate.Text);
            curMont = dtCurrent.Month;
            curYear = dtCurrent.Year;

            Item itm = new Item();
            DataTable dtyears = itm.AllYears();

            foreach (DataRow drYears in dtyears.Rows)
            {
                int yr = Convert.ToInt32(drYears["year"]);
                cboYear.Items.Add(yr);
            }
            cboYear.SelectedItem = dtCurrent.Year;
        }
        private void RrfFormLoad(object sender, EventArgs e)
        {
            PopulateTheMonthCombos(cboFromMonth);
            PopulateTheMonthCombos(cboToMonth);
            PopulateTheYearCombo(cboFromYear);
            PopulateTheYearCombo(cboToYear);
            var stor = new Activity();
            stor.LoadAll();
            cboStores.Properties.DataSource = stor.DefaultView;
            PopulateRrFs();
            WindowVisibility(false);
            EnableDisableStatusCheck();

            btnAutoPushToPFSA.Enabled = BLL.Settings.AllowOnlineOrders;
        }
 /// <summary>
 /// Renews the matrix for A user.
 /// </summary>
 /// <param name="userID">The user ID.</param>
 public void RenewMatrixForAUser(int userID)
 {
     BLL.Activity store = new Activity();
     store.LoadAll();
     while (!store.EOF)
     {
         BLL.UserActivity usrStore = new UserActivity();
         this.LoadByUserAndStoreID(userID,store.ID);
         if (this.RowCount == 0)
         {
             usrStore.AddNew();
             usrStore.UserID = userID;
             usrStore.ActivityID = store.ID;
             usrStore.CanAccess = false;
             usrStore.IsDefault = false;
             usrStore.Save();
         }
         store.MoveNext();
     }
 }
        private void DatabaseInteractivityUtility_Load(object sender, EventArgs e)
        {
            SetPermission();
            PreparePrintLog();
            var activity = new Activity();
            activity.LoadAll();
            lkStoreLocation.Properties.DataSource = activity.DefaultView;

            txtEditVersion.Text = Program.HCMISVersionStringShort;

            try
            {
                txtItemID.Text = _itemID == 0 ? "" : _itemID.ToString();
                if (txtItemID.Text != "")
                    btnGo_Click(null, null);
            }
            catch
            {
            }
        }
        private void ManageItems_Load(object sender, EventArgs e)
        {
            lkCategories.Properties.DataSource = BLL.CommodityType.GetAllTypes();
            lkCategories.ItemIndex = 0;

            dtFrom.Value = DateTime.Today;
            dtTo.Value = DateTime.Today;

            Activity stor = new Activity();
            stor.LoadAll();
            DataView dv = stor.DefaultView;
            cboStores.Properties.DataSource = stor.DefaultView;
            cboStores.ItemIndex = 0;
            Route route = new Route();
            route.LoadAll();
            lkRoutes.Properties.DataSource = route.DefaultView;
            lkRoutes.EditValue = route.RouteID;
            _IsReady = true;
               //     PopulateItemList();
        }
        private void GeneralReport_Load(object sender, EventArgs e)
        {
            Activity stor = new Activity();
            stor.LoadAll();
            DataTable dtStor = stor.DefaultView.ToTable();
            cboStores.DataSource = dtStor;

            dtDate.Value = DateTimeHelper.ServerDateTime;
            dtDate.CustomFormat = "MM/dd/yyyy";
            ConvertDate.DateConverter(dtDate.Text);
        }
        private void startbgWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            MyGeneration.dOOdads.TransactionMgr transactionMgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();

            try
            {
                // Add the inventory details.
                // For each Activity, populate the inventory.
                //ToDO: this grid reading in a non ui thread is dangerous
                //please don't do it this way.
                transactionMgr.BeginTransaction();
                int physicalStoreID = Convert.ToInt32(gridManageInvetoryView.GetFocusedDataRow()["ID"]);
                PhysicalStore physicalStore = new PhysicalStore();
                physicalStore.LoadByPrimaryKey(physicalStoreID);

                DateTime startDate = dtStartInventory.Value;
                if (!physicalStore.IsColumnNull("CurrentInventoryPeriodID"))
                {
                // create the inventory period
                InventoryPeriod oldPeriod = new InventoryPeriod();
                oldPeriod.LoadByPrimaryKey(physicalStore.CurrentInventoryPeriodID);
                oldPeriod.EndDate = dtStartInventory.Value;
                oldPeriod.Save();
                }
                InventoryPeriod period = new InventoryPeriod();
                period.AddNew();
                period.InventoryStatusID = InventoryPeriod.Constants.BEGIN_INVENTORY;
                period.PhysicalStoreID = physicalStoreID;
                period.StartDate = dtStartInventory.Value;
                period.EndDate = FiscalYear.Current.EndDate;
                period.StartedBy = CurrentContext.UserId;
                period.FiscalYearID = FiscalYear.Current.ID;
                if (memoEdit1.EditValue != null)
                {
                    period.Remark = memoEdit1.EditValue.ToString();
                }

                period.Save();
                //ChangePhysicalStoreToCurrentPeriod

                physicalStore = new PhysicalStore();
                physicalStore.LoadByPrimaryKey(physicalStoreID);
                physicalStore.CurrentInventoryPeriodID = period.ID;
                physicalStore.CurrentPeriodStartDate = period.StartDate;
                physicalStore.Save();

                Activity activity = new Activity();
                activity.LoadAll();
                int activityIndex = 1;
                while (!activity.EOF)
                {
                    // report that this activity is being processed.
                    startbgWorker.ReportProgress(activityIndex++, "Activity: " + activity.FullActivityName);

                    DataTable dtbl = Balance.GetBalanceByPhysicalStore(physicalStoreID, activity.ID, false);
                    decimal total = dtbl.Rows.Count;
                    decimal i = 0;
                    foreach (DataRow dr in dtbl.Rows)
                    {

                        Inventory inv = new Inventory();
                        inv.AddNew();

                        inv.IsDraft = true;
                        inv.PhysicalStoreID = physicalStoreID;
                        inv.RecordedBy = CurrentContext.UserId;
                        inv.RecordedDate = BLL.DateTimeHelper.ServerDateTime;

                        inv.InventoryPeriodID = period.ID;
                        inv.ItemID = Convert.ToInt32(dr["ID"]);
                        inv.UnitID = Convert.ToInt32(dr["UnitID"]);
                        inv.ActivityID = activity.ID;
                        inv.ManufacturerID = Convert.ToInt32(dr["ManufacturerID"]);
                        inv.SetColumn("BatchNo", dr["BatchNo"]);
                        inv.SetColumn("ExpiryDate", dr["ExpDate"]);
                        if (!inv.IsColumnNull("ExpiryDate") && inv.ExpiryDate < BLL.DateTimeHelper.ServerDateTime)
                        {
                            inv.SystemExpiredQuantity = Convert.ToDecimal(dr["SoundSOH"]);
                        }
                        else
                        {
                            inv.SystemSoundQuantity = Convert.ToDecimal(dr["SoundSOH"]);
                        }

                        inv.SystemDamagedQuantity = Convert.ToDecimal(dr["DamagedSOH"]);
                        inv.SetColumn("Cost", dr["Cost"]);
                        inv.Margin = dr["Margin"] == DBNull.Value ? 0 : Convert.ToDecimal(dr["Margin"]);
                        inv.SetColumn("PalletLocationID", dr["PalletLocationID"]);
                        inv.Save();

                        startbgWorker.ReportProgress(Convert.ToInt32((i / total) * 100), "Detail");
                        //inventory
                        i++;
                    }

                    activity.MoveNext();
                }
                transactionMgr.CommitTransaction();
                XtraMessageBox.Show("The new Inventory Period has been defined.");
            }
            catch (Exception exception)
            {
                transactionMgr.RollbackTransaction();
                XtraMessageBox.Show(exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnStartInventory_Click(object sender, EventArgs e)
        {
            //Show a dialog box to confirm if they are sure to do this.

            if (XtraMessageBox.Show("Are you sure you would like to start inventory on this physical store?", "Confrim",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                int physicalStoreID = Convert.ToInt32(gridManageInvetoryView.GetFocusedDataRow()["ID"]);

                if (!BLL.Inventory.CanInventoryBeStarted(physicalStoreID))
                {
                    XtraMessageBox.Show(
                        "Inventory cannot be started in the chosen warehouse because there are outstanding transactions.",
                        "Inventory Cannot Be Started");
                    return;
                }

                //Set The PhsyicalStore to The CurrentInventoryPeriod
                PhysicalStore physicalStore = new PhysicalStore();
                physicalStore.LoadByPrimaryKey(physicalStoreID);
                if (physicalStore.IsActive)
                {
                    XtraMessageBox.Show(
                       "Transaction on this warehouse should be blocked before starting inventory.The selected warehouse is still Active",
                       "Inventory Cannot Be Started");
                    return;
                }
                InitializeProgressBar();

                lblDescription.Text =
                    string.Format(
                        "HCMIS is starting inventory on <b>{1} - {0}</b>. Please do not close this window until this operation is complete.",
                        physicalStore.Name, physicalStore.WarehouseName);

                //TODO: this needs to be optimized.
                // there is no need that this has to be loaded here.
                // or if it is loaded, dont load it in the background thread.
                Activity activity = new Activity();
                activity.LoadAll();

                labelTotalActivity.Text =
                    string.Format("HCMIS is searching this physical store for stock under all <b>{0}</b> activities.",
                                  activity.RowCount);
                progressBarActivities.Properties.Maximum = activity.RowCount;

                startbgWorker.RunWorkerAsync();

                // post start inventory transaction
                // todo:
                // lock all items from issue from this phsical store.
            }
        }
 private void RefreshUserStoreGrid(int userID)
 {
     BLL.Activity stores=new Activity();
     stores.LoadAll();
     BLL.UserActivity userStore = new UserActivity();
     userStore.LoadByUserID(userID);
     if (userStore.RowCount == 0)
     {
         BLL.UserActivity usrStore = new UserActivity();
         usrStore.GenerateMatrixForANewUser(userID);
         RefreshUserStoreGrid(userID);
     }
     else if (userStore.RowCount == stores.RowCount)
     {
         grdUserStoreMatrix.DataSource = userStore.DefaultView;
         lcUserStoreMatrix.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
     }
     else
     {
         BLL.UserActivity usrStore = new UserActivity();
         usrStore.RenewMatrixForAUser(userID);
         RefreshUserStoreGrid(userID);
     }
 }
        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);
        }
 private void PopulateStores()
 {
     Activity str = new Activity();
     str.LoadAll();
     gridStores.DataSource = str.DefaultView;
 }
        private void PopulateShelves(DataView dtSlf)
        {
            gridBinLocation.DataSource = dtSlf;

            Activity str = new Activity();
            str.LoadAll();
            cboStore.DataSource = str.DefaultView;
        }