Ejemplo n.º 1
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (Utils.ConvertToDouble(txtAmountTendered.Text) <= 0)
                {
                    LocalUtils.ShowErrorMessage(this, "Amount tendered is not valid!");
                    return;
                }
                var member = Factories.CreateMember().Get(txtMember.Text);
                if (member == null)
                {
                    LocalUtils.ShowErrorMessage(this, "Member not found!");
                    return;
                }
                //Complete then transactions
                Factories.CreatePosTransaction().CompletePosTransaction(_postTransactionID, member.ID, txtAmountTendered.DoubleValue, txtTotal.DoubleValue);

                //Print Reciept
                DialogResult d = MetroMessageBox.Show(this, "Do you want to print reciept?", "Print Reciept", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (d == DialogResult.Yes)
                {
                    //Proceed to print reciept
                    PrintReciept();
                    //Create new transaction after print
                    this.SetDefaultFieldValue();
                    NewTransaction();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        private void Edit()
        {
            try
            {
                var grid = gridProducts;

                if (grid.SelectedRows.Count > 0)
                {
                    _productID = int.Parse(grid.SelectedRows[0].Cells[0].Value.ToString());
                    if (_productID != 0)
                    {
                        page.SetPage(pageProductDetail);
                        SetData();
                    }
                }
                else
                {
                    LocalUtils.ShowNoRecordSelectedMessage(this);
                }
            }
            catch (Exception ex)
            {
                LocalUtils.ShowErrorMessage(this, ex.ToString());
            }
        }
Ejemplo n.º 3
0
        async void LoadProducts()
        {
            try
            {
                await Task.Delay(1000);

                var products = await Task.Run(() => Factories.CreateProducts().GetProductList(txtSearch.Text));

                int count = 0;

                gridProducts.Rows.Clear();
                foreach (var item in products)
                {
                    count++;
                    gridProducts.Rows.Add(new string[] {
                        item.ProductID.ToString(),
                        count.ToString(),
                        item.Description,
                        item.Quantity.ToString()
                    });
                }
            }
            catch (Exception ex)
            {
                LocalUtils.ShowErrorMessage(this, ex.ToString());
            }
        }
Ejemplo n.º 4
0
        public void SetData()
        {
            try
            {
                // populate data
                var model = Factories.CreateDailySale().Get(dailySaleID);
                dtDate.Value           = model.Date;
                txtOutletSale1.Text    = model.OutletSale1.ToString();
                txtOutletSale2.Text    = model.OutletSale2.ToString();
                txtProcessingSale.Text = model.ProcessingSale.ToString();
                // Total Cash Sale Dairy Product
                txtTotalCashSale.Text          = model.TotalCashSales.ToString();
                txtRawMilkSales.Text           = model.RawMilkSales.ToString();
                txtSalesOnAccount.Text         = model.SaleOnAccount.ToString();
                txtTotalSaleDairyProducts.Text = model.TotalSaleForDairyProduct.ToString();
                // Total Sale Over All Sale
                txtTotalSale.Text = model.TotalSales.ToString();

                txtDebtor.Text = model.Debtor.ToString();
            }
            catch (Exception ex)
            {
                LocalUtils.ShowErrorMessage(this, ex.ToString());
            }
        }
Ejemplo n.º 5
0
        private void Edit()
        {
            try
            {
                var grid = gridChat;

                if (grid.SelectedRows.Count > 0)
                {
                    _userID = int.Parse(grid.SelectedRows[0].Cells[0].Value.ToString());
                    if (_userID != 0)
                    {
                        var user = Factories.CreateUser().GetUser(_userID);
                        if (user.UserName == CurrentUser.Name)
                        {
                            LocalUtils.ShowErrorMessage(this, "You cannot message your self!");
                        }
                        else
                        {
                            CheckUnreadMessage();
                            var frmChatMessage = new frmChatMessage(user.UserName);
                            frmChatMessage.Show();
                        }
                    }
                }
                else
                {
                    LocalUtils.ShowNoRecordSelectedMessage(this);
                }
            }
            catch (Exception ex)
            {
                LocalUtils.ShowErrorMessage(this, ex.ToString());
            }
        }
        private void ViewDetail()
        {
            try
            {
                var grid = gridList;

                if (grid.SelectedRows.Count > 0)
                {
                    posTransactionID = int.Parse(grid.SelectedRows[0].Cells[0].Value.ToString());
                    if (posTransactionID != 0)
                    {
                        page.SetPage(pageTransactionDetails);
                        SetData();
                        LoadPosTransactionProducts();
                    }
                }
                else
                {
                    LocalUtils.ShowNoRecordSelectedMessage(this);
                }
            }
            catch (Exception ex)
            {
                LocalUtils.ShowErrorMessage(this, ex.ToString());
            }
        }
Ejemplo n.º 7
0
        private void Delete()
        {
            try
            {
                var grid = gridMembers;

                if (grid.SelectedRows.Count > 0)
                {
                    memberID = int.Parse(grid.SelectedRows[0].Cells[0].Value.ToString());
                    if (memberID != 0)
                    {
                        DialogResult result = MetroMessageBox.Show(this, "Are you sure you want to delete this record?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        if (result == DialogResult.Yes)
                        {
                            Factories.CreateMember().Delete(memberID);
                            LoadList();
                        }
                    }
                    else
                    {
                        LocalUtils.ShowNoRecordFoundMessage(this);
                    }
                }
                else
                {
                    LocalUtils.ShowNoRecordSelectedMessage(this);
                }
            }
            catch (Exception ex)
            {
                LocalUtils.ShowErrorMessage(this, ex.Message);
            }
        }
Ejemplo n.º 8
0
 private void Save()
 {
     try
     {
         var model = new MemberModel();
         model.Address       = txtAddress.Text;
         model.ContactNumber = txtContactNumber.Text;
         model.FullName      = txtFullName.Text;
         ValidatedFields(model);
         if (memberID > 0)
         {
             Factories.CreateMember().Edit(memberID, model);
         }
         else
         {
             Factories.CreateMember().Add(model);
         }
         LocalUtils.ShowSaveMessage(this);
         LoadList();
         page.SetPage(pageList);
     }
     catch (Exception ex)
     {
         LocalUtils.ShowErrorMessage(this, ex.Message);
     }
 }
Ejemplo n.º 9
0
        async void Login()
        {
            try
            {
                if (txtUserName.Text == string.Empty && txtPassword.Text == string.Empty)
                {
                    LocalUtils.ShowErrorMessage(this, "User Name or Password is empty");
                }
                else
                {
                    lblLoggingIn.Visible = true;
                    await Task.Run(() => Factories.CreateUser().LoginUser(txtUserName.Text, txtPassword.Text));

                    //if login success set isLogin to true
                    isLogin = true;
                    LoginSuccess();
                }
            }
            catch (Exception ex)
            {
                LocalUtils.ShowErrorMessage(this, ex.Message);
            }

            lblLoggingIn.Visible = false;
        }
Ejemplo n.º 10
0
 private void Edit()
 {
     try
     {
         if (gridList.SelectedRows.Count > 0)
         {
             // get id
             userID = int.Parse(gridList.SelectedRows[0].Cells[0].Value.ToString());
             if (userID != 0)
             {
                 //show and hide controls
                 mainPage.SetPage(pageDetail);
                 bunifuTransition1.HideSync(pnlSide, false, BunifuAnimatorNS.Animation.Transparent);
                 ResetInputs(pnlAddEdit);
                 SetData();
             }
             else
             {
                 LocalUtils.ShowNoRecordFoundMessage(this);
                 mainPage.SetPage(pageGridMain);
                 bunifuTransition1.ShowSync(pnlSide, false, BunifuAnimatorNS.Animation.Transparent);
             }
         }
         else
         {
             LocalUtils.ShowNoRecordSelectedMessage(this);
         }
     }
     catch (Exception ex)
     {
         LocalUtils.ShowErrorMessage(this, ex.ToString());
     }
 }
Ejemplo n.º 11
0
        private async void Save()
        {
            try
            {
                if (!ValidatedFields())
                {
                    return;
                }
                var model = new AddEditUserModel();
                model.UserName   = txtUserName.Text;
                model.FirstName  = txtFirstName.Text;
                model.MiddleName = txtMiddleName.Text;
                model.LastName   = txtLastName.Text;
                model.Password   = txtPassword.Text;
                model.RoleID     = int.Parse(((ItemX)cboRoles.SelectedItem).Value);
                if (_userID == 0)
                {
                    await Task.Run(() => Factories.CreateUser().Add(model));

                    page.SetPage(tabUserList);
                    LoadUsers();
                }
                else
                {
                    await Task.Run(() => Factories.CreateUser().Edit(_userID, model));

                    page.SetPage(tabUserList);
                    LoadUsers();
                }
            }
            catch (Exception ex)
            {
                LocalUtils.ShowErrorMessage(this, ex.Message);
            }
        }
Ejemplo n.º 12
0
        private void Save()
        {
            try
            {
                if (!ValidateFields())
                {
                    LocalUtils.ShowValidationFailedMessage(this);
                    return;
                }

                var model = new UserModel();
                model.Password       = txtPassword.Text;
                model.ReTypePassword = txtRetypePassword.Text;
                model.UserName       = txtUserName.Text;
                if (userID > 0)
                {
                    Factories.CreateUser().Edit(userID, model);
                }
                else
                {
                    Factories.CreateUser().Add(model);
                    userID = model.ID;
                }
                ShowMainGrid();
            }
            catch (Exception ex)
            {
                LocalUtils.ShowErrorMessage(this, ex.Message);
            }
        }
Ejemplo n.º 13
0
        public void LoadMainGrid()
        {
            try
            {
                var criteria = txtSearch.Text;
                var date     = dtSearchDate.Value;

                var models = Factories.CreateProductSale().GetAllByMonth(date, criteria);
                gridMain.Rows.Clear();
                int count = 0;
                foreach (var item in models)
                {
                    count++;
                    gridMain.Rows.Add(new string[] { item.ID.ToString(), count.ToString(),

                                                     item.Date.ToShortDateString(),
                                                     item.CustomerName,
                                                     item.ProductName,
                                                     item.Quantity.ToString(),
                                                     item.Total.ToString(), });
                }
            }
            catch (Exception ex)
            {
                LocalUtils.ShowErrorMessage(this, ex.ToString());
            }
        }
Ejemplo n.º 14
0
        public void Edit()
        {
            try
            {
                if (gridList.SelectedRows.Count > 0)
                {
                    // get id
                    id = int.Parse(gridList.SelectedRows[0].Cells[0].Value.ToString());
                    if (id != 0)
                    {
                        //show and hide controls

                        lblAddEditTitle.Text = "Edit Record";
                        SetData();
                        mainPage.SetPage(pageDetail);
                        bunifuTransition1.HideSync(pnlSide, false, BunifuAnimatorNS.Animation.Transparent);
                    }
                    else
                    {
                        supplyClassID = int.Parse(gridList.SelectedRows[0].Cells[1].Value.ToString());
                        supplyTypeID  = int.Parse(gridList.SelectedRows[0].Cells[2].Value.ToString());
                        Save();
                        SetData();
                    }
                }
                else
                {
                    LocalUtils.ShowNoRecordSelectedMessage(this);
                }
            }
            catch (Exception ex)
            {
                LocalUtils.ShowErrorMessage(this, ex.Message);
            }
        }
 /// <summary>
 /// Use to get initial data when adding new milk utilization
 /// </summary>
 private void SetInitialAddData()
 {
     try
     {
         var initialDate = dtDate.Value;
         var model       = Factories.CreateMilkUtilize().GetRecord(date: dtDate.Value);
         if (model.ID == 0)
         {
             txtBeginningBalance.Text            = model.BeginningVolumeBalance.ToString();
             txtEndingBalance.Text               = model.EndingVolumeBalance.ToString();
             txtRawMilkProcess.Text              = model.RawMilkProcess.ToString();
             txtTotalRawMilkSold.Text            = model.RawMilkSold.ToString();
             txtTotalMilkDeliveredByFarmers.Text = model.TotalMilkDeliveredFromFarmers.ToString();
             txtTotalMilkForUtilization.Text     = model.TotalMilkForUtilization.ToString();
             txtTotalRawMilkWithdrawn.Text       = model.TotalRawMilkWithdrawn.ToString();
         }
         else
         {
             dtDate.Value = initialDate;
             LocalUtils.ShowErrorMessage(this, "Record Already exists for this date!");
         }
     }
     catch (Exception)
     {
     }
 }
Ejemplo n.º 16
0
 bool AdminCheck()
 {
     if (!CurrentUser.HasRoles("Administrator"))
     {
         LocalUtils.ShowErrorMessage(this, "Your not allowed for this action!");
         return(false);
     }
     return(true);
 }
Ejemplo n.º 17
0
 private void btnSaveRawMaterial_Click(object sender, EventArgs e)
 {
     try
     {
         SaveProductRawMaterial();
     }
     catch (Exception ex)
     {
         LocalUtils.ShowErrorMessage(this, ex.Message);
     }
 }
Ejemplo n.º 18
0
 private void btnEditRawMaterial_Click(object sender, EventArgs e)
 {
     try
     {
         SetProductRawMaterialData();
     }
     catch (Exception ex)
     {
         LocalUtils.ShowErrorMessage(this, ex.ToString());
     }
 }
Ejemplo n.º 19
0
 void SetData()
 {
     try
     {
         var model = Factories.CreateProductLog().GetProduct(productID);
     }
     catch (Exception ex)
     {
         LocalUtils.ShowErrorMessage(this, ex.Message);
     }
 }
Ejemplo n.º 20
0
 private void btnDeleteRawMaterials_Click(object sender, EventArgs e)
 {
     try
     {
         DeleteProductRawMaterial();
     }
     catch (Exception ex)
     {
         LocalUtils.ShowErrorMessage(this, ex.ToString());
     }
 }
Ejemplo n.º 21
0
        private void txtProductCode_OnIconRightClick(object sender, EventArgs e)
        {
            if (txtQuantity.Text == "" || txtMember.Text == "")
            {
                LocalUtils.ShowErrorMessage(this, "Please provide member and quanity of item first!");
                return;
            }
            var productLookupForm = new frmTransactionProducts();

            productLookupForm.OnProductSelected += productLookupForm_OnProductSelected;
            productLookupForm.ShowDialog();
        }
Ejemplo n.º 22
0
        private void btnSubtract_Click(object sender, EventArgs e)
        {
            if (_productID == 0)
            {
                LocalUtils.ShowErrorMessage(this, "Please save new product before removing quantity!");
                return;
            }
            var frm = new frmUpdateProductQuantity(_productID, "Stock Out");

            frm.OnProductUpdated += frm_OnProductUpdated;
            frm.ShowDialog();
        }
Ejemplo n.º 23
0
        public void LoadMainGrid()
        {
            try
            {
                var date = dtSearchDate.Value;

                var models = Factories.CreateDailySale().GetAllByMonth(date);
                gridList.Rows.Clear();
                int count = 0;
                foreach (var item in models)
                {
                    count++;
                    gridList.Rows.Add(new string[] { item.ID.ToString(), count.ToString(),

                                                     item.Date.ToShortDateString(),
                                                     item.OutletSale1.ToString(),
                                                     item.OutletSale2.ToString(),
                                                     item.ProcessingSale.ToString(),
                                                     item.TotalCashSales.ToString(),
                                                     item.SaleOnAccount.ToString(),
                                                     item.TotalSaleForDairyProduct.ToString(),
                                                     item.TotalSales.ToString(),
                                                     item.Debtor });
                }

                //use 0 id to avoid null exception while click edit button
                ////Adds space
                //var summaryModels = mainLogic.GetAllSummary(date);

                //gridList.Rows.Add(new string[] { "0","",
                //            "",
                //            "Total",
                //            summaryModels.TotalMilkSold               .ToString()   ,
                //            summaryModels.TotalMilkSoldAmount         .ToString()   ,
                //            summaryModels.TotalB1plus1                .ToString()   ,
                //            summaryModels.TotalDiscountSale           .ToString()   ,
                //            summaryModels.TotalEcoBag                 .ToString()   ,
                //            summaryModels.TotalOutletSale1            .ToString()   ,
                //            summaryModels.TotalOutletSale2            .ToString()   ,
                //            summaryModels.TotalProcessingSale         .ToString()   ,
                //            summaryModels.GrandTotalCashSale          .ToString()   ,
                //            summaryModels.TotalSaleOnAccount          .ToString()   ,
                //            summaryModels.GrandTotalSaleDairyProduct  .ToString()   ,
                //           });


                SetGridListCustomDesign();
            }
            catch (Exception ex)
            {
                LocalUtils.ShowErrorMessage(this, ex.ToString());
            }
        }
Ejemplo n.º 24
0
 private void CheckTrialVersion()
 {
     if (expDate.Date <= DateTime.Now.Date)
     {
         LocalUtils.ShowErrorMessage(this, "Your trial version has been ended! Please contact developer.");
         Application.Exit();
     }
     else
     {
         LocalUtils.ShowInfo(this, "This application is a trial version and will be expired on " + expDate.ToString("MMMM dd, yyyy"));
     }
 }
Ejemplo n.º 25
0
 void LoadMembersAutoComplete()
 {
     try
     {
         var memberNames = Factories.CreateMember().GetAllFullNamesOnly();
         var autoCStr    = new AutoCompleteStringCollection();
         autoCStr.AddRange(memberNames.ToArray());
         txtMember.AutoCompleteCustomSource = autoCStr;
     }
     catch (Exception ex)
     {
         LocalUtils.ShowErrorMessage(this, ex.Message);
     }
 }
Ejemplo n.º 26
0
 private void SetTransactionProductID()
 {
     try
     {
         if (grid.SelectedRows.Count > 0)
         {
             posTransactionProductID = int.Parse(grid.SelectedRows[0].Cells[0].Value.ToString());
         }
     }
     catch (Exception ex)
     {
         LocalUtils.ShowErrorMessage(this, ex.ToString());
     }
 }
Ejemplo n.º 27
0
 private void SetData()
 {
     try
     {
         var model = Factories.CreateMember().Get(memberID);
         txtAddress.Text       = model.Address;
         txtFullName.Text      = model.FullName;
         txtContactNumber.Text = model.ContactNumber;
     }
     catch (Exception ex)
     {
         LocalUtils.ShowErrorMessage(this, ex.Message);
     }
 }
Ejemplo n.º 28
0
 private void Save()
 {
     try
     {
         ValidateField();
         var quantity = Utils.ConvertToInteger(txtQuantity.Text);
         Factories.CreatePosTransaction().UpdateQuantity(posTransactionProductID, quantity);
         ProductUpdated();
         this.Close();
     }
     catch (Exception ex)
     {
         LocalUtils.ShowErrorMessage(this, ex.Message);
     }
 }
Ejemplo n.º 29
0
        public void Add()
        {
            try
            {
                mainPage.SetPage(pageDetail);
                ResetInputs();
                productSaleID = 0;

                bunifuTransition1.HideSync(pnlSide, false, BunifuAnimatorNS.Animation.HorizBlind);
            }
            catch (Exception ex)
            {
                LocalUtils.ShowErrorMessage(this, ex.ToString());
            }
        }
Ejemplo n.º 30
0
 public void SetInitialData()
 {
     try
     {
         // populate data
         var model = Factories.CreateDailySale().GetInitial(dtDate.Value);
         dtDate.Value         = model.Date;
         txtOutletSale1.Text  = model.OutletSale1.ToString();
         txtOutletSale2.Text  = model.OutletSale2.ToString();
         txtRawMilkSales.Text = model.RawMilkSales.ToString();
     }
     catch (Exception ex)
     {
         LocalUtils.ShowErrorMessage(this, ex.ToString());
     }
 }