Exemplo n.º 1
0
        private void FrmCustomer_Load(object sender, EventArgs e)
        {
            try
            {
                if (_CustomerService == null)
                {
                    _CustomerService = ServiceFactory.GenerateServiceInstance().GenerateCustomerService();
                }
                if (_CommonService == null)
                {
                    _CommonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();
                }

                var objList = _CommonService.GetAppParametersByType(
                    int.Parse(Resources.AppParamGender));

                _CommonService.PopAppParamExtendedCombobox(
                    ref cmbGender, objList, int.Parse(Resources.AppParamGender), true);

                objList = _CommonService.GetAppParametersByType(
                    int.Parse(Resources.AppParamDiscountType));

                _CommonService.PopAppParamExtendedCombobox(
                    ref cmbDCardType, objList, int.Parse(Resources.AppParamDiscountType), true);
                cmbDCardType.SelectedIndex = 0;
                lblDisPercentage.Text      = ((AppParameter)cmbDCardType.SelectedItem).ParameterValue;

                var criteriaList = new List <string> {
                    "CustomerId|0"
                };
                if (cmbDCardType.SelectedItem != null)
                {
                    criteriaList.Add("DiscountCardTypeId|" + ((AppParameter)cmbDCardType.SelectedItem).ParameterId);
                }

                objList = _CustomerService.GetDiscountCards(criteriaList);
                lsbDiscountCard.DataSource = objList;
                if (objList.Count != 0)
                {
                    lsbDiscountCard.DisplayMember = DiscountCard.ConstDiscountCardNumber;
                    lsbDiscountCard.ValueMember   = DiscountCard.ConstDiscountCardId;
                    lsbDiscountCard.SelectedIndex = -1;
                }

                SetCustomerInfo();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.InnerException.Message);
            }
        }
Exemplo n.º 2
0
 private void TxtUpInLeave(object sender, EventArgs e)
 {
     txtUPIn.TextChanged -= ModificationHandler;
     try
     {
         txtUPIn.Text = float.Parse(txtUPIn.Text).ToString("N3", AppContext.CultureInfo);
     }
     catch (Exception exception)
     {
         FrmExtendedMessageBox.UnknownErrorMessage(
             Resources.MsgCaptionUnknownError,
             exception.Message);
     }
 }
Exemplo n.º 3
0
        private void CalculateProductCost(bool waitStatus)
        {
            try
            {
                if (string.IsNullOrEmpty(txtUPIn.Text))
                {
                    txtUPIn.Text = Resources.ConstAmountZeroThreeDigits;
                }
                if (string.IsNullOrEmpty(txtExtraPercentage.Text))
                {
                    txtExtraPercentage.Text = Resources.ConstAmountZeroOneDigit;
                }
                if (string.IsNullOrEmpty(txtDiscount.Text))
                {
                    txtDiscount.Text = Resources.ConstAmountZeroOneDigit;
                }
                if (string.IsNullOrEmpty(txtUPOut.Text))
                {
                    txtUPOut.Text = Resources.ConstAmountZeroThreeDigits;
                }

                float discountPercentage;
                float unitPriceOut;
                if (waitStatus)
                {
                    unitPriceOut       = float.Parse(txtUPOut.Text);
                    discountPercentage = 100 - ((100 * unitPriceOut) / _defaultUnitPriceOut);
                    discountPercentage = discountPercentage < 0 ? 0 : discountPercentage;
                    txtDiscount.Text   = Math.Round(discountPercentage, 0).ToString("N", AppContext.CultureInfo);
                }
                else
                {
                    var unitPriceIn     = float.Parse(txtUPIn.Text);
                    var extraPercentage = float.Parse(txtExtraPercentage.Text);

                    discountPercentage = float.Parse(txtDiscount.Text);
                    unitPriceOut       = unitPriceIn + ((unitPriceIn * extraPercentage) / 100);
                    unitPriceOut       = unitPriceOut - ((unitPriceOut * discountPercentage) / 100);
                    //txtUPOut.Text = Math.Round(unitPriceOut, 0).ToString("N", AppContext.CultureInfo);
                    txtUPOut.Text        = unitPriceOut.ToString("N3", AppContext.CultureInfo);
                    _defaultUnitPriceOut = float.Parse(txtUPOut.Text);
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Exemplo n.º 4
0
 private void TxtExpenseAmountIntLeave(object sender, EventArgs e)
 {
     txtExpenseAmountInt.TextChanged -= ModificationHandler;
     try
     {
         txtExpenseAmountInt.Text = float.Parse(txtExpenseAmountInt.Text).ToString("N");
     }
     catch (Exception exception)
     {
         FrmExtendedMessageBox.UnknownErrorMessage(
             Resources.MsgCaptionUnknownError,
             exception.Message);
     }
 }
Exemplo n.º 5
0
        private void BtnSaveClick(object sender, EventArgs e)
        {
            try
            {
                if (cmbExpenseType.SelectedIndex == -1)
                {
                    const string briefMsg  = "អំពីពត៌មាន";
                    var          detailMsg = Resources.MsgInvalidData;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr    = briefMsg;
                        frmMessageBox.DetailMsgStr   = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }

                if (_Expense == null)
                {
                    _Expense = new Expense();
                }

                _Expense.ExpenseTypeId     = int.Parse(cmbExpenseType.SelectedValue.ToString());
                _Expense.ExpenseTypeStr    = cmbExpenseType.Text;
                _Expense.ExpenseDate       = dtpExpenseDate.Value.Date;
                _Expense.Description       = txtDescription.Text;
                _Expense.ExpenseAmountRiel = float.Parse(txtExpenseAmountRiel.Text);
                _Expense.ExpenseAmountInt  = float.Parse(txtExpenseAmountInt.Text);
                _Expense.ExchangeRate      = AppContext.ExchangeRate.ExchangeValue;

                ExpenseService.ExpenseManagement(
                    _Expense,
                    _Expense.ExpenseId != 0 ? Resources.OperationRequestUpdate : Resources.OperationRequestInsert);

                DialogResult = DialogResult.OK;
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Exemplo n.º 6
0
        private void BtnNewClick(object sender, EventArgs e)
        {
            if (!UserService.AllowToPerform(Resources.PermissionAddCustomer))
            {
                const string briefMsg  = "អំពីសិទ្ឋប្រើប្រាស់";
                const string detailMsg = "អ្នក​ពុំ​មាន​សិទ្ឋ​គ្រប់​គ្រាន់​សំរាប់​ការ​ស្នើរ​សុំ​នេះ​ឡើយ ។";
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr    = briefMsg;
                    frmMessageBox.DetailMsgStr   = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog(this);
                }
                return;
            }

            Visible = false;
            using (var frmCustomer = new FrmCustomer())
            {
                if (frmCustomer.ShowDialog(this) == DialogResult.OK)
                {
                    try
                    {
                        _customerList.Add(frmCustomer.Customer);
                        if (frmCustomer.Customer.FkDiscountCard != null)
                        {
                            _discountCardList.Add(frmCustomer.Customer.FkDiscountCard);
                        }

                        lsbCustomer.SelectedIndex = -1;
                        lsbCustomer.SelectedIndex = lsbCustomer.FindStringExact(frmCustomer.Customer.CustomerName);
                    }
                    catch (Exception exception)
                    {
                        FrmExtendedMessageBox.UnknownErrorMessage(
                            Resources.MsgCaptionUnknownError,
                            exception.Message);
                    }
                }
                Visible = true;
            }
        }
Exemplo n.º 7
0
        private void CmbProductSelectedIndexChanged(object sender, EventArgs e)
        {
            if ((String.IsNullOrEmpty(cmbProduct.DisplayMember)) ||
                (String.IsNullOrEmpty(cmbProduct.ValueMember)) ||
                (cmbProduct.SelectedIndex == -1))
            {
                return;
            }

            try
            {
                var product = (Product)cmbProduct.SelectedItem;
                if (product == null)
                {
                    return;
                }

                const string briefMsg  = "អំពីពត៌មាន";
                var          detailMsg = Resources.MsgConfirmEditExistingProduct;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr  = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                    {
                        txtForeignCode.Text = string.Empty;
                        return;
                    }
                }

                _product = product;
                SetProductInfo(_product);
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Exemplo n.º 8
0
        private void SetExpenseInfo()
        {
            if (_Expense == null)
            {
                return;
            }

            try
            {
                cmbExpenseType.SelectedValue = _Expense.ExpenseTypeId;
                dtpExpenseDate.Value         = (DateTime)_Expense.ExpenseDate;
                txtDescription.Text          = _Expense.Description;
                txtExpenseAmountRiel.Text    = _Expense.ExpenseAmountRiel.ToString("N");
                txtExpenseAmountInt.Text     = _Expense.ExpenseAmountInt.ToString("N");
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Exemplo n.º 9
0
        private void IListToBindingList(IList depositList)
        {
            if (depositList == null)
            {
                throw new ArgumentNullException("depositList", Resources.MsgEmptyBindingList);
            }

            try
            {
                _depositList.Clear();
                foreach (Deposit deposit in depositList)
                {
                    _depositList.Add(deposit);
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Exemplo n.º 10
0
        private void IListToBindingList(IList saleOrderReportList)
        {
            if (saleOrderReportList == null)
            {
                throw new ArgumentNullException("saleOrderReportList", Resources.MsgInvalidSaleOrder);
            }

            try
            {
                _saleOrderReportList.Clear();
                foreach (SaleOrderReport saleOrderReport in saleOrderReportList)
                {
                    _saleOrderReportList.Add(saleOrderReport);
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Exemplo n.º 11
0
        private void FrmExchangeRate_Load(object sender, EventArgs e)
        {
            try
            {
                if (_CommonService == null)
                {
                    _CommonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();
                }

                IList objList = _CommonService.GetAppParametersByType(
                    Int32.Parse(Resources.AppParamCurrency));

                _CommonService.PopAppParamExtendedCombobox(
                    ref cbbFromCurrency, objList, Int32.Parse(Resources.AppParamCurrency), true);
                if (((IList)cbbFromCurrency.DataSource).Count != 0)
                {
                    cbbFromCurrency.SelectedValue = 15;
                }

                _CommonService.PopAppParamExtendedCombobox(
                    ref cbbToCurrency, objList, Int32.Parse(Resources.AppParamCurrency), true);
                if (((IList)cbbToCurrency.DataSource).Count != 0)
                {
                    cbbToCurrency.SelectedValue = 14;
                }

                if (txtExchangeRate.CanFocus)
                {
                    txtExchangeRate.Focus();
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Exemplo n.º 12
0
        private void TxtSearchKeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                switch (e.KeyCode)
                {
                case Keys.Return:
                    if (StringHelper.Length(txtSearch.Text) == 0)
                    {
                        return;
                    }

                    DoCustomerFetching(txtSearch.Text, true);
                    break;
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Exemplo n.º 13
0
        private void InitializeProductList()
        {
            try
            {
                if (_productList == null)
                {
                    _productList = new BindingList <Product>();
                }

                dgvProduct.DataSource = _productList;
                dgvProduct.Columns["PrintCheck"].DisplayIndex  = 0;
                dgvProduct.Columns["PublicQty"].DisplayIndex   = 1;
                dgvProduct.Columns["ProductPic"].DisplayIndex  = 2;
                dgvProduct.Columns["DisplayName"].DisplayIndex = 3;
                dgvProduct.Columns["Description"].DisplayIndex = 4;
                dgvProduct.Columns["QtyInStock"].DisplayIndex  = 5;
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Exemplo n.º 14
0
        private void BtnSaveClick(object sender, EventArgs e)
        {
            try
            {
                if ((cmbCategory.SelectedIndex == -1) || (cmbMark.SelectedIndex == -1) ||
                    (cmbColor.SelectedIndex == -1) || (cmbSize.SelectedIndex == -1))
                {
                    const string briefMsg  = "អំពីពត៌មាន";
                    var          detailMsg = Resources.MsgInvalidData;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr    = briefMsg;
                        frmMessageBox.DetailMsgStr   = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }

                if (_product == null)
                {
                    _product = new Product();
                }

                _product.CategoryId         = int.Parse(cmbCategory.SelectedValue.ToString());
                _product.CategoryStr        = cmbCategory.Text;
                _product.MarkId             = int.Parse(cmbMark.SelectedValue.ToString());
                _product.MarkStr            = cmbMark.Text;
                _product.ColorId            = int.Parse(cmbColor.SelectedValue.ToString());
                _product.ColorStr           = cmbColor.Text;
                _product.SizeId             = Int32.Parse(cmbSize.SelectedValue.ToString());
                _product.SizeStr            = cmbSize.Text;
                _product.ProductName        = _product.CategoryStr + @" \ " + _product.MarkStr + @" \ " + _product.ColorStr;
                _product.UnitPriceIn        = float.Parse(txtUPIn.Text);
                _product.ExtraPercentage    = float.Parse(txtExtraPercentage.Text);
                _product.UnitPriceOut       = float.Parse(txtUPOut.Text);
                _product.DiscountPercentage = float.Parse(txtDiscount.Text);
                _product.QtyInStock         = float.Parse(txtQtyInStock.Text);
                _product.QtyPromotion       = float.Parse(txtQtyPromotion.Text);
                _product.QtyBonus           = float.Parse(txtQtyBonus.Text);
                _product.ForeignCode        = txtForeignCode.Text;
                _product.Description        = txtDescription.Text;
                if (txtPhotoPath.Text.Length == 0)
                {
                    _product.PhotoPath  = _product.PhotoPath;
                    _product.ProductPic = Resources.NoImage;
                }
                else
                {
                    var fileInfo = new FileInfo(txtPhotoPath.Text);
                    if (fileInfo.Exists)
                    {
                        _product.PhotoPath  = txtPhotoPath.Text;
                        _product.ProductPic = Image.FromFile(_product.PhotoPath);
                    }
                    else
                    {
                        _product.ProductPic = Resources.NoImage;
                    }
                }

                if (_productService == null)
                {
                    _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService();
                }

                _product.DisplayName = _product.ProductName + "\r" +
                                       "Size: " + _product.SizeStr + "\r" +
                                       "Code: " + _product.ProductCode;
                if (!string.IsNullOrEmpty(_product.ForeignCode))
                {
                    _product.DisplayName += " (" + _product.ForeignCode + ")";
                }

                if (!_isFromSale)
                {
                    _productService.ManageProduct(
                        _product,
                        _product.ProductId != 0 ? Resources.OperationRequestUpdate : Resources.OperationRequestInsert);
                }

                DialogResult = DialogResult.OK;
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Exemplo n.º 15
0
        private void BtnSearchClick(object sender, EventArgs e)
        {
            if (btnSearch.Text == Resources.ConstRepeatSearch)
            {
                SetVisibleControls(true);
            }
            else
            {
                try
                {
                    if (rbtSale.Checked)
                    {
                        var searchCriteria =
                            new List <string>
                        {
                            "(ReportHeader = 1) AND (QtySold >= 0)",
                            "SaleOrderDate BETWEEN CONVERT(DATETIME, '" +
                            dtpStartDate.Value.ToString("dd/MM/yyyy") +
                            "', 103) AND CONVERT(DATETIME, '" +
                            dtpStopDate.Value.ToString("dd/MM/yyyy") + " 23:59', 103)"
                        };

                        if (!String.IsNullOrEmpty(txtInvoiceNumber.Text))
                        {
                            searchCriteria.Add(
                                "SaleOrderNumber LIKE '%" + txtInvoiceNumber.Text + "%'");
                        }

                        if (cmbCustomer.SelectedItem != null)
                        {
                            searchCriteria.Add(
                                "CustomerId = " + Int32.Parse(cmbCustomer.SelectedValue.ToString()));
                        }

                        if (!String.IsNullOrEmpty(txtPhoneNumber.Text))
                        {
                            searchCriteria.Add(
                                "CustomerId IN (SELECT CustomerId FROM TCustomers WHERE PhoneNumber LIKE '%" +
                                txtPhoneNumber.Text + "%')");
                        }

                        if (!String.IsNullOrEmpty(txtCardNumber.Text))
                        {
                            searchCriteria.Add(
                                "CardNumber LIKE '%" + txtCardNumber.Text + "%'");
                        }

                        if (cmbDiscountType.SelectedItem != null)
                        {
                            searchCriteria.Add(
                                "DiscountTypeId = " +
                                Int32.Parse(cmbDiscountType.SelectedValue.ToString()));
                        }

                        if (cmbCategory.SelectedItem != null)
                        {
                            searchCriteria.Add(
                                "ProductId IN (SELECT ProductId FROM TProducts WHERE CategoryId =  " +
                                Int32.Parse(cmbCategory.SelectedValue.ToString()) + ")");
                        }

                        if (cmbBrand.SelectedItem != null)
                        {
                            searchCriteria.Add(
                                "ProductId IN (SELECT ProductId FROM TProducts WHERE MarkId =  " +
                                Int32.Parse(cmbBrand.SelectedValue.ToString()) + ")");
                        }

                        if (cmbColor.SelectedItem != null)
                        {
                            searchCriteria.Add(
                                "ProductId IN (SELECT ProductId FROM TProducts WHERE ColorId =  " +
                                Int32.Parse(cmbColor.SelectedValue.ToString()) + ")");
                        }

                        if (!String.IsNullOrEmpty(txtProductCode.Text))
                        {
                            searchCriteria.Add(
                                "ProductId IN (SELECT ProductId FROM TProducts WHERE (ProductCode LIKE '%" +
                                txtProductCode.Text + "%') OR (ForeignCode LIKE '%" + txtProductCode.Text + "%'))");
                        }

                        var saleOrderService =
                            ServiceFactory.GenerateServiceInstance().GenerateSaleOrderService();
                        IListToBindingList(
                            saleOrderService.GetSaleHistories(searchCriteria));

                        var searchInfo = String.Format(
                            "ការ​ស្វែងរក​របស់​អ្នក​ផ្ដល់​លទ្ឋផល​ចំនួន {0}",
                            _saleOrderReportList.Count);
                        lblSearchInfo.Text = searchInfo;
                    }
                    else
                    {
                        var searchCriteria =
                            new List <string>
                        {
                            "(a.DepositDate BETWEEN CONVERT(DATETIME, '" +
                            dtpStartDate.Value.ToString("dd/MM/yyyy", AppContext.CultureInfo) +
                            "', 103) AND CONVERT(DATETIME, '" +
                            dtpStopDate.Value.ToString("dd/MM/yyyy", AppContext.CultureInfo) +
                            " 23:59', 103)) ",
                            "(a.AmountPaidInt < a.AmountSoldInt) ",
                            "DepositNumber NOT IN (SELECT ReferenceNum FROM TDeposits WHERE ReferenceNum IS NOT NULL) "
                        };

                        if (!String.IsNullOrEmpty(txtInvoiceNumber.Text))
                        {
                            searchCriteria.Add(
                                "a.DepositNumber LIKE '%" + txtInvoiceNumber.Text + "%'");
                        }

                        if (cmbCustomer.SelectedItem != null)
                        {
                            searchCriteria.Add(
                                "a.CustomerId = " + Int32.Parse(cmbCustomer.SelectedValue.ToString()));
                        }

                        if (!String.IsNullOrEmpty(txtPhoneNumber.Text))
                        {
                            searchCriteria.Add(
                                "a.CustomerId IN (SELECT CustomerId FROM TCustomers WHERE PhoneNumber LIKE '%" +
                                txtPhoneNumber.Text + "%')");
                        }

                        if (!String.IsNullOrEmpty(txtCardNumber.Text))
                        {
                            searchCriteria.Add(
                                "a.CardNumber LIKE '%" + txtCardNumber.Text + "%'");
                        }

                        if (cmbDiscountType.SelectedItem != null)
                        {
                            searchCriteria.Add(
                                "a.DiscountTypeId = " +
                                Int32.Parse(cmbDiscountType.SelectedValue.ToString()));
                        }

                        if (cmbCategory.SelectedItem != null)
                        {
                            searchCriteria.Add(
                                "e.ProductId IN (SELECT ProductId FROM TProducts WHERE CategoryId =  " +
                                Int32.Parse(cmbCategory.SelectedValue.ToString()) + ")");
                        }

                        if (cmbBrand.SelectedItem != null)
                        {
                            searchCriteria.Add(
                                "e.ProductId IN (SELECT ProductId FROM TProducts WHERE MarkId =  " +
                                Int32.Parse(cmbBrand.SelectedValue.ToString()) + ")");
                        }

                        if (cmbColor.SelectedItem != null)
                        {
                            searchCriteria.Add(
                                "e.ProductId IN (SELECT ProductId FROM TProducts WHERE ColorId =  " +
                                Int32.Parse(cmbColor.SelectedValue.ToString()) + ")");
                        }

                        if (!String.IsNullOrEmpty(txtProductCode.Text))
                        {
                            searchCriteria.Add(
                                "e.ProductId IN (SELECT ProductId FROM TProducts WHERE ProductCode LIKE '%" +
                                txtProductCode.Text + "%')");
                        }

                        var depositService =
                            ServiceFactory.GenerateServiceInstance().GenerateDepositService();
                        _depositReportList = depositService.GetDepositHistories(searchCriteria, true);
                        IListToBindingList(
                            depositService.GetSaleHistories(_depositReportList));
                        var searchInfo = String.Format(
                            "ការ​ស្វែងរក​របស់​អ្នក​ផ្ដល់​លទ្ឋផល​ចំនួន {0}",
                            _depositReportList.Count);
                        lblSearchInfo.Text = searchInfo;
                    }
                    SetVisibleControls(false);
                }
                catch (Exception exception)
                {
                    FrmExtendedMessageBox.UnknownErrorMessage(
                        Resources.MsgCaptionUnknownError,
                        exception.Message);
                }
            }
        }
Exemplo n.º 16
0
        private void FrmPayment_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                if (DialogResult != DialogResult.OK)
                {
                    return;
                }

                if (Customer == null)
                {
                    const string briefMsg  = "អំពីអតិថិជន";
                    const string detailMsg = "ការ​គិត​លុយ​ពុំ​អាច​ប្រព្រឹត្ត​ទៅ​ដោយ​គ្មាន​អតិថិជន​ឡើយ ។";
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr    = briefMsg;
                        frmMessageBox.DetailMsgStr   = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                    }

                    e.Cancel = true;
                    return;
                }

                PaymentManagement();
                var amountReturnRiel = float.Parse(txtAmountReturnRiel.Text);
                if (amountReturnRiel < 0)
                {
                    if (!IsDeposit)
                    {
                        if (((-1) * amountReturnRiel) >= 0)
                        {
                            const string briefMsg  = "អំពីការប្រគល់ប្រាក់";
                            const string detailMsg = "ទឹក​ប្រាក់​ដែល​អ្នក​បាន​បញ្ចូល​ពុំ​ទាន់​គ្រប់​គ្រាន់​ទេ ។";
                            using (var frmMessageBox = new FrmExtendedMessageBox())
                            {
                                frmMessageBox.BriefMsgStr    = briefMsg;
                                frmMessageBox.DetailMsgStr   = detailMsg;
                                frmMessageBox.IsCanceledOnly = true;
                                frmMessageBox.ShowDialog(this);
                            }

                            e.Cancel = true;
                            return;
                        }
                    }
                    else
                    {
                        const string briefMsg  = "អំពីការប្រគល់ប្រាក់";
                        var          detailMsg = Resources.MsgConfirmCreditPayment;
                        using (var frmMessageBox = new FrmExtendedMessageBox())
                        {
                            frmMessageBox.BriefMsgStr    = briefMsg;
                            frmMessageBox.DetailMsgStr   = detailMsg;
                            frmMessageBox.IsCanceledOnly = false;
                            if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                            {
                                e.Cancel = true;
                                return;
                            }
                        }
                    }
                }
                else if (IsDeposit)
                {
                    const string briefMsg  = "អំពីការប្រគល់ប្រាក់";
                    var          detailMsg = Resources.MsgInvalidDepositPayment;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr    = briefMsg;
                        frmMessageBox.DetailMsgStr   = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                        {
                            e.Cancel = true;
                            return;
                        }
                    }
                }

                if (CommonService.IsIntegratedModule(Resources.ModDiscountCard))
                {
                    DiscountCardManagement();
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Exemplo n.º 17
0
        private void BtnAdjustmentClick(object sender, EventArgs e)
        {
            if (_product == null)
            {
                return;
            }

            try
            {
                string briefMsg, detailMsg;
                if (!UserService.AllowToPerform(Resources.PermissionProductAdjustment))
                {
                    briefMsg  = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                    detailMsg = Resources.MsgUserPermissionDeny;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr    = briefMsg;
                        frmMessageBox.DetailMsgStr   = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }

                briefMsg  = "អំពីការសង";
                detailMsg = "សូម​មេត្តា​ចុច​លើ​ប៊ូតុង យល់​ព្រម ដើម្បី​បញ្ជាក់​ពី​ការ​ដកចេញពីឃ្លាំង​។";
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr  = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                    {
                        return;
                    }
                }

                using (var folderBrowserDialog = new FolderBrowserDialog())
                {
                    folderBrowserDialog.ShowNewFolderButton = false;
                    if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
                    {
                        if (_productService == null)
                        {
                            _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService();
                        }

                        IList listProduct2Export = new List <Product> {
                            _product
                        };

                        _productService.ExportProductToXml(
                            listProduct2Export,
                            folderBrowserDialog.SelectedPath,
                            "ProductList.xml");

                        var productAdjustment = new ProductAdjustment
                        {
                            ProductId   = _product.ProductId,
                            QtyInStock  = _product.QtyInStock,
                            QtyAdjusted = ((-1) * _product.QtyInStock),
                            FkProduct   = _product
                        };

                        if (_productService == null)
                        {
                            _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService();
                        }
                        _productService.ProductAdjustmentManagement(
                            Resources.OperationRequestInsert,
                            productAdjustment);

                        _isModified  = true;
                        DialogResult = DialogResult.OK;
                    }
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Exemplo n.º 18
0
        private void BtnDeliverClick(object sender, EventArgs e)
        {
            try
            {
                if (_depositList == null)
                {
                    return;
                }

                if (_depositList.Count == 0)
                {
                    return;
                }

                if (dgvDeposit.CurrentRow == null)
                {
                    return;
                }

                _deposit = _depositList[dgvDeposit.CurrentRow.Index];
                if (_deposit == null)
                {
                    return;
                }

                var briefMsg  = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                var detailMsg = Resources.MsgUserPermissionDeny;
                if (!UserService.AllowToPerform(Resources.PermissionEditDeposit))
                {
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr    = briefMsg;
                        frmMessageBox.DetailMsgStr   = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }

                var saleOrder = _saleOrderService.GetSaleOrder(_deposit);
                if (saleOrder == null)
                {
                    return;
                }

                briefMsg  = "អំពីការប្រគល់របស់";
                detailMsg = Resources.MsgConfirmDeliverProduct;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr  = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                    {
                        return;
                    }
                }

                _depositItemList = _depositService.GetDepositItems(_deposit.DepositId);
                var saleItemList = _saleOrderService.GetSaleItems(_depositItemList);

                _saleOrderService.RecordSaleOrder(
                    saleItemList,
                    saleOrder.AmountSoldInt,
                    saleOrder.AmountSoldInt - saleOrder.AmountPaidInt,
                    0,
                    0,
                    saleOrder.FkCustomer,
                    false,
                    _deposit.DepositNumber,
                    saleOrder.Discount,
                    _deposit.AmountPaidInt,
                    true);

                _deposit.AmountPaidInt   += (_deposit.AmountSoldInt - _deposit.AmountPaidInt);
                _deposit.AmountReturnInt  = 0f;
                _deposit.AmountReturnRiel = 0f;
                _deposit.UpdateDate       = DateTime.Now;
                _depositService.UpdateDeposit(_deposit);

                var paymentService = ServiceFactory.GenerateServiceInstance().GeneratePaymentService();
                var payment        =
                    new Model.Payments.Payment
                {
                    PaymentDate   = _deposit.DepositDate,
                    PaymentAmount = _deposit.AmountPaidInt,
                    SalesOrderId  = _deposit.DepositId,
                    CashierId     = _deposit.CashierId
                };
                paymentService.ManagePayment(Resources.OperationRequestInsert, payment);

                RetrieveDataHandler();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(Resources.MsgCaptionUnknownError, exception.Message);
            }
        }
Exemplo n.º 19
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtSupplierName.Text))
                {
                    const string briefMsg  = "អំពីពត៌មាន";
                    var          detailMsg = Resources.MsgInvalidData;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr    = briefMsg;
                        frmMessageBox.DetailMsgStr   = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }

                if (cmbCountry.SelectedIndex == -1)
                {
                    const string briefMsg  = "អំពីពត៌មាន";
                    var          detailMsg = Resources.MsgInvalidData;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr    = briefMsg;
                        frmMessageBox.DetailMsgStr   = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }

                if (_Supplier == null)
                {
                    _Supplier = new Supplier();
                }

                _Supplier.SupplierName    = txtSupplierName.Text;
                _Supplier.PhoneNumber     = txtPhoneNumber.Text;
                _Supplier.FaxNumber       = txtFaxNumber.Text;
                _Supplier.EmailAddress    = txtEmailAddress.Text;
                _Supplier.Website         = txtWebsite.Text;
                _Supplier.CountryId       = Int32.Parse(cmbCountry.SelectedValue.ToString());
                _Supplier.CountryStr      = cmbCountry.Text;
                _Supplier.BankInformation = txtBankInfo.Text;
                _Supplier.Address         = txtAddress.Text;

                if (_Supplier.SupplierId != 0)
                {
                    _SupplierService.SupplierManagement(
                        _Supplier,
                        Resources.OperationRequestUpdate);
                }
                else
                {
                    _SupplierService.SupplierManagement(
                        _Supplier,
                        Resources.OperationRequestInsert);
                }

                DialogResult = DialogResult.OK;
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Exemplo n.º 20
0
        private void BtnSaveClick(object sender, EventArgs e)
        {
            try
            {
                if ((cmbGender.SelectedIndex == -1) || (cmbMaritalStatus.SelectedIndex == -1) ||
                    (cmbPosition.SelectedIndex == -1) || (cmbContractType.SelectedIndex == -1) ||
                    (String.IsNullOrEmpty(txtUserName.Text)) || (String.IsNullOrEmpty(txtLogInName.Text)) ||
                    (String.IsNullOrEmpty(txtPassword.Text)))
                {
                    const string briefMsg  = "អំពីពត៌មាន";
                    var          detailMsg = Resources.MsgInvalidData;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr    = briefMsg;
                        frmMessageBox.DetailMsgStr   = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }

                var permissionList = new List <UserPermission>();
                var permissionNum  = ((IList)clbPermission.DataSource).Count;
                for (var counter = 0; counter < permissionNum; counter++)
                {
                    if (!clbPermission.GetItemChecked(counter))
                    {
                        continue;
                    }

                    var userPermission = new UserPermission
                    {
                        PermissionId =
                            ((Permission)clbPermission.Items[counter]).PermissionId
                    };
                    permissionList.Add(userPermission);
                }

                if (permissionList.Count == 0)
                {
                    const string briefMsg  = "អំពីពត៌មាន";
                    var          detailMsg = Resources.MsgInvalidData;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr    = briefMsg;
                        frmMessageBox.DetailMsgStr   = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }

                if (_user == null)
                {
                    _user = new User();
                }
                _user.UserName         = txtUserName.Text;
                _user.GenderId         = int.Parse(cmbGender.SelectedValue.ToString());
                _user.GenderStr        = cmbGender.Text;
                _user.MaritalStatusId  = int.Parse(cmbMaritalStatus.SelectedValue.ToString());
                _user.MaritalStatusStr = cmbMaritalStatus.Text;
                _user.BirthDate        = dtpBirthDate.Value;
                _user.PhoneNumber      = txtPhoneNumber.Text;
                _user.Address          = txtAddress.Text;
                _user.PositionId       = int.Parse(cmbPosition.SelectedValue.ToString());
                _user.PositionStr      = cmbPosition.Text;
                _user.ContractId       = int.Parse(cmbContractType.SelectedValue.ToString());
                _user.ContractStr      = cmbContractType.Text;
                _user.StartingDate     = dtpStartingDate.Value;
                _user.Salary           = float.Parse(txtSalary.Text);
                _user.LogInName        = txtLogInName.Text;
                _user.Password         = txtPassword.Text;
                _user.PhotoPath        = txtPhotoPath.Text.Length == 0 ? _user.PhotoPath : txtPhotoPath.Text;

                if (_userService == null)
                {
                    _userService = ServiceFactory.GenerateServiceInstance().GenerateUserService();
                }

                _userService.UserManagement(_user, permissionList,
                                            _user.UserId != 0
                                                ? Resources.OperationRequestUpdate
                                                : Resources.OperationRequestInsert);

                if (AppContext.User == null)
                {
                    return;
                }

                if (_user.UserId == AppContext.User.UserId)
                {
                    AppContext.UserPermissionList = permissionList;
                }

                DialogResult = DialogResult.OK;
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Exemplo n.º 21
0
        private void BtnSaveClick(object sender, EventArgs e)
        {
            try
            {
                if ((cmbGender.SelectedIndex == -1) || (String.IsNullOrEmpty(txtCustomerName.Text)))
                {
                    const string briefMsg  = "អំពីពត៌មាន";
                    var          detailMsg = Resources.MsgInvalidData;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr    = briefMsg;
                        frmMessageBox.DetailMsgStr   = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }

                if (_Customer == null)
                {
                    _Customer = new Customer();
                }

                _Customer.LocalName        = txtLocalName.Text;
                _Customer.CustomerName     = txtCustomerName.Text;
                _Customer.Address          = txtAddress.Text;
                _Customer.PhoneNumber      = txtPhoneNumber.Text;
                _Customer.EmailAddress     = txtEmailAddress.Text;
                _Customer.Website          = txtWebsite.Text;
                _Customer.GenderId         = Int32.Parse(cmbGender.SelectedValue.ToString());
                _Customer.GenderStr        = cmbGender.Text;
                _Customer.DiscountRejected = chbDiscountRejected.Checked ? 1 : 0;

                var isAllowed = false;
                if (lsbDiscountCard.SelectedItem != null)
                {
                    var discountCard = (DiscountCard)lsbDiscountCard.SelectedItem;
                    //if (discountCard != null)
                    //{
                    if ((discountCard.CustomerId != _Customer.CustomerId) ||
                        _Customer.CustomerId == 0)
                    {
                        isAllowed = true;

                        _Customer.FkDiscountCard     = discountCard;
                        _Customer.DiscountCardNumber = discountCard.CardNumber;
                        _Customer.DiscountCardType   = discountCard.DiscountCardTypeStr;
                        _Customer.DiscountPercentage = discountCard.DiscountPercentage;

                        if (cmbDCardType.SelectedValue != null)
                        {
                            float discountAmount =
                                float.Parse(((AppParameter)cmbDCardType.SelectedItem).ParameterCode);
                            if (_Customer.PurchasedAmount < discountAmount)
                            {
                                _Customer.PurchasedAmount = discountAmount;
                            }
                        }
                    }
                    //}
                }

                if (_CustomerService == null)
                {
                    _CustomerService = ServiceFactory.GenerateServiceInstance().GenerateCustomerService();
                }

                _CustomerService.CustomerManagement(_Customer,
                                                    _Customer.CustomerId != 0
                                                        ? Resources.OperationRequestUpdate
                                                        : Resources.OperationRequestInsert);

                if (isAllowed)
                {
                    var discountCard = (DiscountCard)lsbDiscountCard.SelectedItem;
                    discountCard.CustomerId = _Customer.CustomerId;
                    _CustomerService.DiscountCardManagement(
                        discountCard,
                        Resources.OperationRequestUpdate);
                }
                DialogResult = DialogResult.OK;
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Exemplo n.º 22
0
        private void FrmPayment_Load(object sender, EventArgs e)
        {
            try
            {
                if (_CustomerService == null)
                {
                    _CustomerService = ServiceFactory.GenerateServiceInstance().GenerateCustomerService();
                }
                if (_CommonService == null)
                {
                    _CommonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();
                }

                ThreadStart threadStart = UpdateControlContent;
                var         thread      = new Thread(threadStart)
                {
                    IsBackground = true
                };
                thread.Start();

                if (AppContext.ExchangeRate != null)
                {
                    _exchangeRate = AppContext.ExchangeRate.ExchangeValue;
                }

                _discountCardList             = new BindingList <DiscountCard>();
                cmbDiscountCard.DataSource    = _discountCardList;
                cmbDiscountCard.DisplayMember = DiscountCard.ConstDiscountCardNumber;
                cmbDiscountCard.ValueMember   = DiscountCard.ConstDiscountCardId;

                _customerList             = new BindingList <Customer>();
                lsbCustomer.DataSource    = _customerList;
                lsbCustomer.DisplayMember = Customer.ConstCustomerDisplayName;
                lsbCustomer.ValueMember   = Customer.ConstCustomerId;

                txtExchangeRate.Text      = _exchangeRate.ToString("N", AppContext.CultureInfo);
                txtCurrentSaleAmount.Text = _TotalAmountInt.ToString("N", AppContext.CultureInfo);
                CalculateDiscount();

                if (UserService.AllowToPerform(Resources.PermissionSpecialDiscount))
                {
                    cmbDCountType.Enabled = true;
                }

                if (CommonService.IsIntegratedModule(Resources.ModCustomer))
                {
                    IList searchCriteria = new List <string> {
                        "CustomerName|Retail customer"
                    };
                    var customerList = _CustomerService.GetCustomers(searchCriteria);
                    foreach (Customer customer in customerList)
                    {
                        _customerList.Add(customer);
                    }
                    //txtSearch.Enabled = false;
                    //lsbCustomer.Enabled = false;
                    //btnNew.Enabled = false;
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }