Esempio n. 1
0
        private void FrmProductAdvance_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (_isFromSale)
            {
                return;
            }

            if ((DialogResult == DialogResult.Cancel) && (_isModified))
            {
                const string briefMsg  = "អំពីការបោះបង់";
                var          detailMsg = Resources.MsgOperationRequestCancel;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr  = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                    {
                        e.Cancel = true;
                        return;
                    }
                }
            }

            if (_isModified)
            {
                return;
            }

            DialogResult = DialogResult.Cancel;
        }
Esempio n. 2
0
        private void BtnLogInClick(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtLogIn.Text) || string.IsNullOrEmpty(txtPwd.Text))
            {
                ShowErrorMessage();
                return;
            }

            try
            {
                User = _userService.GetUser(txtLogIn.Text, txtPwd.Text);
                if (User == null)
                {
                    const string briefMsg  = "អំពីការចូលទៅក្នុងប្រព័ន្ឋ";
                    var          detailMsg = Resources.MsgOperationRequestLogInFail;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr    = briefMsg;
                        frmMessageBox.DetailMsgStr   = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }

                DialogResult = DialogResult.OK;
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Esempio n. 3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            string briefMsg, detailMsg;

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

            SetFocusToSupplierList();

            detailMsg = string.Empty;
            briefMsg = "អំពីការលុប";
            if (dgvSupplier.CurrentRow != null)
                detailMsg =
                    Resources.MsgOperationRequestDelete +
                    "\n" +
                    dgvSupplier.CurrentRow.Cells["SupplierName"].Value + " ?";
            using (var frmMessageBox = new FrmExtendedMessageBox())
            {
                frmMessageBox.BriefMsgStr = briefMsg;
                frmMessageBox.DetailMsgStr = detailMsg;
                if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                    return;
            }

            try
            {
                if (dgvSupplier.CurrentRow != null)
                    _SupplierService.SupplierManagement(
                        _SupplierList[dgvSupplier.CurrentRow.Index],
                        Resources.OperationRequestDelete);

                ThreadStart threadStart = UpdateControlContent;
                var thread = new Thread(threadStart);
                thread.Start();

                if (dgvSupplier.CurrentRow != null)
                    _SupplierList.RemoveAt(dgvSupplier.CurrentRow.Index);
                dgvSupplier.Refresh();

                UpdateResultInfo();
                EnableActionButton();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Esempio n. 4
0
        private static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                var frmSplash = new FrmSplash();

                //Keep application context
                ApplicationContext = new ApplicationContext(frmSplash);
                Application.Run(ApplicationContext);
            }
            catch (Exception)
            {
                const string briefMsg  = "អំពីការចូលទៅក្នុងប្រព័ន្ឋ";
                var          detailMsg = Resources.MsgConnectionLost;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr    = briefMsg;
                    frmMessageBox.DetailMsgStr   = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog();
                }
            }
        }
Esempio n. 5
0
        private static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                var frmSplash = new FrmSplash();

                //Keep application context
                ApplicationContext = new ApplicationContext(frmSplash);
                Application.Run(ApplicationContext);
            }
            catch (Exception)
            {
                const string briefMsg = "អំពីការចូលទៅក្នុងប្រព័ន្ឋ";
                var detailMsg = Resources.MsgConnectionLost;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog();
                }
            }
        }
Esempio n. 6
0
        private void BtnLogInClick(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtLogIn.Text) || string.IsNullOrEmpty(txtPwd.Text))
            {
                ShowErrorMessage();
                return;
            }

            try
            {
                User = _userService.GetUser(txtLogIn.Text, txtPwd.Text);
                if (User == null)
                {
                    const string briefMsg = "អំពីការចូលទៅក្នុងប្រព័ន្ឋ";
                    var detailMsg = Resources.MsgOperationRequestLogInFail;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr = briefMsg;
                        frmMessageBox.DetailMsgStr = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }

                DialogResult = DialogResult.OK;
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Esempio n. 7
0
        private void DiscountCardDistribution(
            Customer customer,
            string currentCardType,
            string nextCardType)
        {
            if (customer == null)
            {
                return;
            }

            if (customer.DiscountRejected == 1)
            {
                return;
            }

            string briefMsgStr, detailMsgStr;

            if (String.IsNullOrEmpty(currentCardType))
            {
                briefMsgStr  = "ការប្រគល់ប័ណ្ណបញ្ចុះតំលៃ";
                detailMsgStr = String.Format(
                    "សូម​មេត្តា​ផ្ដល់​ប័ណ្ណ​កាត​បញ្ចុះ​តំលៃ​ប្រភេទ​​ {0} ជូន​ទៅ​អតិថិជន {1}",
                    nextCardType,
                    customer.CustomerName);
            }
            else
            {
                briefMsgStr  = "កាផ្លាស់ប្ដូរប័ណ្ណបញ្ចុះតំលៃ";
                detailMsgStr = string.Format(
                    "សូមមេត្តាប្ដូរប័ណ្ណបញ្ចុះតំលៃពីប្រភេទ {0} ទៅប្រភេទ {1} ជូនអតិថិជន {2}",
                    currentCardType,
                    nextCardType,
                    customer.CustomerName);
            }

            using (var frmMessageBox = new FrmExtendedMessageBox())
            {
                frmMessageBox.BriefMsgStr  = briefMsgStr;
                frmMessageBox.DetailMsgStr = detailMsgStr;

                if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                Visible = false;
                using (var frmCustomer = new FrmCustomer())
                {
                    frmCustomer.Customer = customer;
                    if (frmCustomer.ShowDialog(this) == DialogResult.OK)
                    {
                        Customer = frmCustomer.Customer;
                    }
                    Visible = true;
                }
            }
        }
Esempio n. 8
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            string briefMsg, detailMsg;

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

                //ExtendedMessageBox.InformMessage(Resources.MsgUserPermissionDeny);
                //return;
            }

            //if (!ExtendedMessageBox.ConfirmMessage(
            //    "MsgOperationRequestDelete",
            //    "\n\n" + dgvUser.CurrentRow.Cells["UserName"].Value))
            //    return;
            //string briefMsg, detailMsg;
            briefMsg = "អំពីការលុប";
            detailMsg = Resources.MsgOperationRequestDelete + "\n" +
                        dgvUser.CurrentRow.Cells["UserName"].Value + " ?";
            using (var frmMessageBox = new FrmExtendedMessageBox())
            {
                frmMessageBox.BriefMsgStr = briefMsg;
                frmMessageBox.DetailMsgStr = detailMsg;
                if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                    return;
            }

            try
            {
                _UserService.UserManagement(
                    _UserList[dgvUser.CurrentRow.Index],
                    null,
                    Resources.OperationRequestDelete);

                _UserList.RemoveAt(dgvUser.CurrentRow.Index);
                dgvUser.Refresh();
                UpdateResultInfo();
                EnableActionButton();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Esempio n. 9
0
        private void ShowErrorMessage()
        {
            const string briefMsg  = "អំពីការចូលទៅក្នុងប្រព័ន្ឋ";
            var          detailMsg = Resources.MsgOperationRequestLogInFail;

            using (var frmMessageBox = new FrmExtendedMessageBox())
            {
                frmMessageBox.BriefMsgStr    = briefMsg;
                frmMessageBox.DetailMsgStr   = detailMsg;
                frmMessageBox.IsCanceledOnly = true;
                frmMessageBox.ShowDialog(this);
            }
        }
Esempio n. 10
0
        private void TsmImportClick(object sender, EventArgs e)
        {
            if (!UserService.AllowToPerform(Resources.PermissionImportExportProduct))
            {
                const string briefMsg  = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                var          detailMsg = Resources.MsgUserPermissionDeny;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr    = briefMsg;
                    frmMessageBox.DetailMsgStr   = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog(this);
                    return;
                }
            }

            using (var folderBrowserDialog = new FolderBrowserDialog())
            {
                folderBrowserDialog.ShowNewFolderButton = false;
                if (folderBrowserDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                const string briefMsg  = "អំពីការលុប";
                var          detailMsg = Resources.MsgOperationImportGroupCatalog;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr  = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                    {
                        return;
                    }
                }

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

                _productService.ImportProductFromXml(
                    folderBrowserDialog.SelectedPath,
                    "ProductList.xml");

                _isModified  = true;
                DialogResult = DialogResult.OK;
            }
        }
Esempio n. 11
0
        private void TmsGroupClick(object sender, EventArgs e)
        {
            using (var openFileDialog = new OpenFileDialog())
            {
                openFileDialog.Filter      = Resources.ConstExtensionImage;
                openFileDialog.Multiselect = true;
                if (openFileDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                if (openFileDialog.FileNames.Length == 0)
                {
                    return;
                }

                const string briefMsg  = "អំពីការបង្កើតផលិតផល";
                var          detailMsg = Resources.MsgOperationImportGroupCatalog;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr  = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                    {
                        return;
                    }
                }

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

                _productService.ImportGroupCatalog(
                    openFileDialog.FileNames,
                    Int32.Parse(cmbCategory.SelectedValue.ToString()),
                    cmbCategory.Text,
                    Int32.Parse(cmbMark.SelectedValue.ToString()),
                    cmbMark.Text,
                    Int32.Parse(cmbColor.SelectedValue.ToString()),
                    cmbColor.Text,
                    Int32.Parse(cmbSize.SelectedValue.ToString()),
                    cmbSize.Text);

                _isModified  = true;
                DialogResult = DialogResult.OK;
            }
        }
Esempio n. 12
0
        private void BtnDeleteClick(object sender, EventArgs e)
        {
            string briefMsg, detailMsg;

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

            briefMsg = "អំពីការលុប";
            detailMsg = Resources.MsgOperationRequestDelete + "\n" +
                        dgvExpense.CurrentRow.Cells["Description"].Value + " ?";
            using (var frmMessageBox = new FrmExtendedMessageBox())
            {
                frmMessageBox.BriefMsgStr = briefMsg;
                frmMessageBox.DetailMsgStr = detailMsg;
                if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                    return;
            }

            try
            {
                _ExpenseService.ExpenseManagement(_ExpenseList[dgvExpense.CurrentRow.Index],
                                                  Resources.OperationRequestDelete);

                _ExpenseList.RemoveAt(dgvExpense.CurrentRow.Index);
                dgvExpense.Refresh();
                UpdateResultInfo();
                EnableActionButton();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Esempio n. 13
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);
            }
        }
Esempio n. 14
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);
            }
        }
Esempio n. 15
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;
            }
        }
Esempio n. 16
0
        private void ImportAllCatalogs()
        {
            using (var folderBrowserDialog = new FolderBrowserDialog())
            {
                folderBrowserDialog.ShowNewFolderButton = false;
                if (folderBrowserDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                const string briefMsg  = "អំពីការលុប";
                var          detailMsg = Resources.MsgOperationImportGroupCatalog;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr  = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                    {
                        return;
                    }
                }

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

                _productService.ImportGroupCatalog(
                    folderBrowserDialog.SelectedPath,
                    Int32.Parse(cmbCategory.SelectedValue.ToString()),
                    cmbCategory.Text,
                    Int32.Parse(cmbMark.SelectedValue.ToString()),
                    cmbMark.Text,
                    Int32.Parse(cmbColor.SelectedValue.ToString()),
                    cmbColor.Text,
                    Int32.Parse(cmbSize.SelectedValue.ToString()),
                    cmbSize.Text);

                _isModified  = true;
                DialogResult = DialogResult.OK;
            }
        }
Esempio n. 17
0
        private void BtnValidateClick(object sender, EventArgs e)
        {
            int qtySold;

            if (!Int32.TryParse(txtQtySale.Text, out qtySold))
            {
                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 qtyBonus = CalculateQtyBonus(
                qtySold,
                Int32.Parse(_saleItem.FkProduct.QtyPromotion.ToString("N0", AppContext.CultureInfo)),
                Int32.Parse(_saleItem.FkProduct.QtyBonus.ToString("N0", AppContext.CultureInfo)));

            if ((qtySold < 0) || ((qtySold + qtyBonus) > _saleItem.FkProduct.QtyInStock))
            {
                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;
                }
            }

            _saleItem.QtySold  = qtySold;
            _saleItem.QtyBonus = qtyBonus;
            DialogResult       = DialogResult.OK;
        }
Esempio n. 18
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);
            }
        }
Esempio 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);
            }
        }
Esempio n. 20
0
        private void BtnValidateClick(object sender, EventArgs e)
        {
            int qtySold;
            if(!Int32.TryParse(txtQtySale.Text, out qtySold))
            {
                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 qtyBonus = CalculateQtyBonus(
                qtySold,
                Int32.Parse(_saleItem.FkProduct.QtyPromotion.ToString("N0", AppContext.CultureInfo)),
                Int32.Parse(_saleItem.FkProduct.QtyBonus.ToString("N0", AppContext.CultureInfo)));
            if((qtySold < 0) ||((qtySold + qtyBonus) > _saleItem.FkProduct.QtyInStock))
            {
                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;
                }
            }

            _saleItem.QtySold = qtySold;
            _saleItem.QtyBonus = qtyBonus;
            DialogResult = DialogResult.OK;
        }
Esempio n. 21
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);
            }
        }
Esempio n. 22
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);
            }
        }
Esempio n. 23
0
        private void RefreshReportStock()
        {
            try
            {
                if (rdbStockDetail.Checked)
                {
                    if (!UserService.AllowToPerform(Resources.PermissionViewDetailStockReport))
                    {
                        const string briefMsg = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                        var detailMsg = Resources.MsgUserPermissionDeny;
                        using (var frmMessageBox = new FrmExtendedMessageBox())
                        {
                            frmMessageBox.BriefMsgStr = briefMsg;
                            frmMessageBox.DetailMsgStr = detailMsg;
                            frmMessageBox.IsCanceledOnly = true;
                            frmMessageBox.ShowDialog(this);
                            return;
                        }
                    }
                }
                else if (rdbStockShort.Checked)
                {
                    if (!UserService.AllowToPerform(Resources.PermissionViewStockReport))
                    {
                        const string briefMsg = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                        var detailMsg = Resources.MsgUserPermissionDeny;
                        using (var frmMessageBox = new FrmExtendedMessageBox())
                        {
                            frmMessageBox.BriefMsgStr = briefMsg;
                            frmMessageBox.DetailMsgStr = detailMsg;
                            frmMessageBox.IsCanceledOnly = true;
                            frmMessageBox.ShowDialog(this);
                            return;
                        }
                    }
                }
                else
                {
                    if (!UserService.AllowToPerform(Resources.PermissionViewExpiredProductReport))
                    {
                        const string briefMsg = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                        var detailMsg = Resources.MsgUserPermissionDeny;
                        using (var frmMessageBox = new FrmExtendedMessageBox())
                        {
                            frmMessageBox.BriefMsgStr = briefMsg;
                            frmMessageBox.DetailMsgStr = detailMsg;
                            frmMessageBox.IsCanceledOnly = true;
                            frmMessageBox.ShowDialog(this);
                            return;
                        }
                    }
                }

                var searchCriteria = new List<string> {"QtyInStock > 0"};
                if (rdbProductExpired.Checked)
                    searchCriteria.Add(
                        "LastUpdate <= CONVERT(DATETIME, '" +
                        DateTime.Now.AddMonths(-1).ToString("dd/MM/yyyy") +
                        "', 103)");

                var productList = _ProductService.GetObjects(searchCriteria);

                DataSet dtsProduct = new DtsModels();
                var propertyInfos = typeof (Product).GetProperties();
                foreach (var objInstance in productList)
                {
                    var dataRow = dtsProduct.Tables[0].NewRow();
                    foreach (var propertyInfo in propertyInfos)
                        dataRow[propertyInfo.Name] = propertyInfo.GetValue(objInstance, null);
                    dtsProduct.Tables[0].Rows.Add(dataRow);
                }

                if ((rdbStockDetail.Checked) || (rdbProductExpired.Checked))
                {
                    var csrCatalog = new CsrCatalog();
                    csrCatalog.SetDataSource(dtsProduct);
                    crvReport.ReportSource = csrCatalog;
                }
                else
                {
                    var csrCatalogShorten = new CsrCatalogShorten();
                    csrCatalogShorten.SetDataSource(dtsProduct);
                    crvReport.ReportSource = csrCatalogShorten;
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Esempio n. 24
0
        private void DgvCustomerCellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (!UserService.AllowToPerform(Resources.PermissionEditCustomer))
            {
                const string briefMsg = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                var detailMsg = Resources.MsgUserPermissionDeny;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog(this);
                    return;
                }
            }

            CustomerManagement(Resources.OperationRequestUpdate);
        }
Esempio n. 25
0
        private void TxtHiddenKeyDown(object sender, KeyEventArgs e)
        {
            if (e == null)
                return;

            try
            {
                switch (e.KeyCode)
                {
                    case Keys.Escape:
                        CancelSale();
                        break;
                    case Keys.Delete:
                        if (_saleItemBindingList.Count == 0)
                            return;
                        UpdateSaleItem(Resources.OperationRequestDelete,
                                       dgvSaleItem.SelectedRows[0].Index);
                        break;
                    case Keys.Add:
                        if (!btnValid.Enabled)
                            return;

                        if (_saleItemBindingList.Count == 0)
                            return;
                        UpdateSaleItem(Resources.OperationRequestInsert,
                                       dgvSaleItem.SelectedRows[0].Index);
                        break;
                    case Keys.Subtract:
                        if (!btnValid.Enabled)
                            return;

                        if (_saleItemBindingList.Count == 0)
                            return;
                        UpdateSaleItem(Resources.OperationRequestUpdate,
                                       dgvSaleItem.SelectedRows[0].Index);
                        break;
                    case Keys.Up:
                        if (_saleItemBindingList.Count == 0)
                            return;
                        UpdateSelectedIndex(dgvSaleItem.SelectedRows[0].Index - 1);
                        break;
                    case Keys.Down:
                        if (_saleItemBindingList.Count == 0)
                            return;
                        UpdateSelectedIndex(dgvSaleItem.SelectedRows[0].Index + 1);
                        break;
                    case Keys.Return:
                        DoProductFetching(txtHidden.Text, true);
                        break;
                    case Keys.F1:
                        Visible = false;
                        using (var frmProductList = new FrmProductSearch())
                        {
                            if(frmProductList.ShowDialog(this) == DialogResult.OK)
                            {
                                var product = frmProductList.Product;
                                if(product != null)
                                {
                                    if (product.QtyInStock != 0)
                                    {
                                        _productList.Add(product);
                                        DoProductFetching(product.ProductCode, true);
                                    }
                                    else
                                    {
                                        txtHidden.Text = string.Empty;
                                        const string briefMsg = "អំពីផលិតផល";
                                        var detailMsg = Resources.MsgOperationRequestProductNotFound;
                                        using (var frmMessageBox = new FrmExtendedMessageBox())
                                        {
                                            frmMessageBox.BriefMsgStr = briefMsg;
                                            frmMessageBox.DetailMsgStr = detailMsg;
                                            frmMessageBox.IsCanceledOnly = true;
                                            frmMessageBox.ShowDialog(this);
                                        }
                                    }
                                }
                            }
                            Visible = true;
                        }
                        break;
                    case Keys.F2:
                        if(dgvSaleItem.CurrentRow == null)
                            return;

                        var selectedIndex =
                            dgvSaleItem.SelectedRows[0].Index;
                        var saleItem = _saleItemBindingList[selectedIndex];
                        if (saleItem == null)
                            return;

                        Visible = false;
                        using (var frmSaleQty = new FrmSaleQty())
                        {
                            frmSaleQty.SaleItem = saleItem;
                            if (frmSaleQty.ShowDialog(this) == DialogResult.OK)
                            {
                                saleItem = frmSaleQty.SaleItem;
                                _saleItemBindingList[selectedIndex] = saleItem;

                                var product = saleItem.FkProduct;
                                saleItem.Discount = product.DiscountPercentage;

                                var publicUnitPriceOut =
                                    product.UnitPriceIn + ((product.UnitPriceIn * product.ExtraPercentage) / 100);

                                publicUnitPriceOut =
                                    publicUnitPriceOut -
                                    ((publicUnitPriceOut * product.DiscountPercentage) / 100);

                                if (publicUnitPriceOut == product.UnitPriceIn)
                                    publicUnitPriceOut = product.UnitPriceOut;

                                publicUnitPriceOut =
                                    float.Parse(
                                        publicUnitPriceOut.ToString("N", AppContext.CultureInfo),
                                        AppContext.CultureInfo);
                                saleItem.PublicUpOut = publicUnitPriceOut;
                                saleItem.UnitPriceOut =
                                    product.UnitPriceIn +
                                    ((product.UnitPriceIn * product.ExtraPercentage) / 100);
                                saleItem.UnitPriceOut =
                                    float.Parse(
                                        saleItem.UnitPriceOut.ToString("N", AppContext.CultureInfo),
                                        AppContext.CultureInfo);
                                saleItem.SubTotal = saleItem.QtySold * publicUnitPriceOut;
                                dgvSaleItem.Refresh();
                                CalculateSale();
                            }

                            Visible = true;
                        }
                        break;
                    default:
                        break;
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Esempio n. 26
0
 private void ShowErrorMessage()
 {
     const string briefMsg = "អំពីការចូលទៅក្នុងប្រព័ន្ឋ";
     var detailMsg = Resources.MsgOperationRequestLogInFail;
     using (var frmMessageBox = new FrmExtendedMessageBox())
     {
         frmMessageBox.BriefMsgStr = briefMsg;
         frmMessageBox.DetailMsgStr = detailMsg;
         frmMessageBox.IsCanceledOnly = true;
         frmMessageBox.ShowDialog(this);
     }
 }
Esempio n. 27
0
        private void BtnCancelDepositClick(object sender, EventArgs e)
        {
            var briefMsg  = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
            var detailMsg = Resources.MsgUserPermissionDeny;

            if (!UserService.AllowToPerform(Resources.PermissionCancelDeposit))
            {
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr    = briefMsg;
                    frmMessageBox.DetailMsgStr   = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog(this);
                    return;
                }
            }

            if (_depositList == null)
            {
                return;
            }

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

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

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

            _depositItemList = new List <DepositItem>();
            //_DepositService.GetDepositItems(_Deposit.DepositId);

            //if (_Deposit == null)
            //    return;

            //if (_DepositItemList.Count == 0)
            //    return;

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

            _deposit.DepositDate = DateTime.Now;
            _deposit             = _depositService.RecordDeposit(
                _depositItemList,
                _deposit.AmountSoldInt,
                _deposit.AmountPaidInt,
                0,
                _deposit.FkCustomer,
                _deposit.DepositNumber,
                _deposit.Discount,
                true);

            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();
        }
Esempio n. 28
0
        private void BtnDepositClick(object sender, EventArgs e)
        {
            if (!UserService.AllowToPerform(Resources.PermissionAddDeposit))
            {
                const string briefMsg = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                var detailMsg = Resources.MsgUserPermissionDeny;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog(this);
                    return;
                }
            }

            ScanFocusHandler();

            if (_saleItemBindingList.Count == 0)
                return;

            Visible = false;
            try
            {
                using (var frmPayment = new FrmPayment())
                {
                    frmPayment.CommonService = _commonService;
                    frmPayment.CustomerService = _customerService;
                    frmPayment.TotalAmountInt = _totalAmountInt;
                    frmPayment.IsDeposit = true;
                    if (frmPayment.ShowDialog(this) == DialogResult.OK)
                    {
                        Visible = true;
                        var depositItemList = _depositService.GetDepositItems(_saleItemBindingList);

                        _deposit = _depositService.RecordDeposit(
                            depositItemList,
                            _totalAmountInt,
                            frmPayment.AmountPaidInt,
                            frmPayment.AmountPaidRiel,
                            frmPayment.Customer,
                            string.Empty,
                            frmPayment.Customer.FkDiscountCard.DiscountPercentage,
                            false);

                        if (_deposit == null)
                            return;

                        DoActivateControls(false);
                        SetCustomerInfo(frmPayment.Customer);
                        SetInvoiceInfo(
                            _deposit.DepositNumber,
                            _deposit.AmountSoldInt,
                            _deposit.AmountPaidInt,
                            _deposit.AmountPaidRiel,
                            _deposit.AmountReturnInt);
                        InvoicePrinting(
                            _deposit.FkCustomer,
                            _deposit.DepositNumber,
                            (DateTime)_deposit.DepositDate,
                            _deposit.Discount,
                            _deposit.AmountPaidInt,
                            0,
                            0,
                            true);

                        LocalStockHandler();

                        var frmThank = new FrmThank();
                        frmThank.ShowDialog(this);
                    }
                    Visible = true;
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Esempio n. 29
0
        private void RetrieveConfiguration()
        {
            try
            {
                SafeCrossCallBackDelegate safeCrossCallBackDelegate = null;

                if (pnlBody_Right.InvokeRequired)
                    safeCrossCallBackDelegate = RetrieveConfiguration;

                if (pnlBody_Right.InvokeRequired)
                    Invoke(safeCrossCallBackDelegate);
                else
                {
                    Thread.Sleep(100);

                    //Loading Service
                    pgbService.Value += 15;
                    _commonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();
                    pgbService.Value += 15;
                    _saleOrderService = ServiceFactory.GenerateServiceInstance().GenerateSaleOrderService();
                    pgbService.Value += 15;
                    _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService();
                    pgbService.Value += 15;
                    _customerService = ServiceFactory.GenerateServiceInstance().GenerateCustomerService();
                    pgbService.Value += 15;
                    _supplierService = ServiceFactory.GenerateServiceInstance().GenerateSupplierService();
                    pgbService.Value += 15;
                    _expenseService = ServiceFactory.GenerateServiceInstance().GenerateExpenseService();
                    pgbService.Value += 10;
                    _userService = ServiceFactory.GenerateServiceInstance().GenerateUserService();

                    //Connecting to database
                    pgbGlobalConfig.Value += 50;
                    _commonService.InitializeGlobalConfiguration();
                    pgbGlobalConfig.Value += 50;

                    //Initializing workspace
                    pgbInitialization.Value += 30;
                    _commonService.InitializeWorkSpace();
                    pgbInitialization.Value += 30;
                    if (AppContext.Counter == null)
                    {
                        const string briefMsg = "អំពីការចូលទៅក្នុងប្រព័ន្ឋ";
                        var detailMsg = Resources.MsgCounterNotInitialize;
                        using (var frmMessageBox = new FrmExtendedMessageBox())
                        {
                            frmMessageBox.BriefMsgStr = briefMsg;
                            frmMessageBox.DetailMsgStr = detailMsg;
                            frmMessageBox.IsCanceledOnly = true;
                            frmMessageBox.ShowDialog(this);
                            Close();
                            return;
                        }
                    }
                    pgbInitialization.Value += 40;

                    //Loading configuration
                    pgbCustomizedConfig.Value += 80;
                    Visible = false;

                    using (var frmLogIn = new FrmLogIn())
                    {
                        frmLogIn.UserService = _userService;
                        if (frmLogIn.ShowDialog(this) == DialogResult.OK)
                        {
                            Visible = true;

                            var frmMain = new FrmMain();
                            ApplicationContext.MainForm = frmMain;

                            frmMain.CommonService = _commonService;
                            frmMain.SaleOrderService = _saleOrderService;
                            frmMain.ProductService = _productService;
                            frmMain.CustomerService = _customerService;
                            frmMain.SupplierService = _supplierService;
                            frmMain.ExpenseService = _expenseService;
                            frmMain.UserService = _userService;

                            _commonService.InitializeCustomizedConfiguration(frmLogIn.User);
                            pgbCustomizedConfig.Value += 20;

                            _commonService.InsertOperationLog(
                                AppContext.User.UserId,
                                int.Parse(Resources.OperationLogIn));

                            frmMain.Show();
                            Close();
                        }
                        else
                            ApplicationContext.ExitThread();
                    }
                }
            }
            catch (Exception exception)
            {
                const string briefMsg = "អំពីការចូលទៅក្នុងប្រព័ន្ឋ";
                var detailMsg = Resources.MsgConnectionLost;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog(this);
                    Close();
                }
            }
        }
Esempio n. 30
0
        private void dgvAppParameter_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
        {
            string briefMsg, detailMsg;
            if (!UserService.AllowToPerform(Resources.PermissionDeleteConfig))
            {
                briefMsg = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                detailMsg = Resources.MsgUserPermissionDeny;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog(this);
                    return;
                }

                //ExtendedMessageBox.InformMessage(Resources.MsgUserPermissionDeny);
                //return;
            }

            var appParameter = (AppParameter) _AppParamList[e.Row.Index];
            briefMsg = "អំពីការលុប";
            detailMsg = Resources.MsgOperationRequestDelete + "\n" +
                        appParameter.ParameterLabel + " ?";
            using (var frmMessageBox = new FrmExtendedMessageBox())
            {
                frmMessageBox.BriefMsgStr = briefMsg;
                frmMessageBox.DetailMsgStr = detailMsg;
                if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                {
                    e.Cancel = true;
                    return;
                }
            }

            //if (!ExtendedMessageBox.ConfirmMessage(Resources.MsgOperationRequestDelete, appParameter.ParameterLabel))
            //{
            //    e.Cancel = true;
            //    return;
            //}

            AppParamManagement(appParameter, Resources.OperationRequestDelete);

            _AppParamList = _CommonService
                .GetAppParametersByType(Int32.Parse(lsbAppParam.SelectedValue.ToString(), AppContext.CultureInfo));
            cmbAppParamValue.DataSource = _AppParamList;
            if (StringHelper.Length(cmbAppParamValue.DisplayMember) == 0)
                cmbAppParamValue.DisplayMember = AppParameter.ConstParameterValue;
            if (StringHelper.Length(cmbAppParamValue.ValueMember) == 0)
                cmbAppParamValue.ValueMember = AppParameter.ConstParameterId;
            cmbAppParamValue.SelectedIndex = _AppParamList.Count - 1;
        }
Esempio n. 31
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);
            }
        }
Esempio n. 32
0
        private void TmsGroupClick(object sender, EventArgs e)
        {
            using (var openFileDialog = new OpenFileDialog())
            {
                openFileDialog.Filter = Resources.ConstExtensionImage;
                openFileDialog.Multiselect = true;
                if (openFileDialog.ShowDialog() != DialogResult.OK)
                    return;

                if (openFileDialog.FileNames.Length == 0)
                    return;

                const string briefMsg = "អំពីការបង្កើតផលិតផល";
                var detailMsg = Resources.MsgOperationImportGroupCatalog;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                        return;
                }

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

                _productService.ImportGroupCatalog(
                    openFileDialog.FileNames,
                    Int32.Parse(cmbCategory.SelectedValue.ToString()),
                    cmbCategory.Text,
                    Int32.Parse(cmbMark.SelectedValue.ToString()),
                    cmbMark.Text,
                    Int32.Parse(cmbColor.SelectedValue.ToString()),
                    cmbColor.Text,
                    Int32.Parse(cmbSize.SelectedValue.ToString()),
                    cmbSize.Text);

                _isModified = true;
                DialogResult = DialogResult.OK;
            }
        }
Esempio n. 33
0
        private void DoCustomerFetching(string givenParam, bool isAllowed)
        {
            if (String.IsNullOrEmpty(givenParam))
            {
                return;
            }

            cmbDiscountCard.SelectedIndex = -1;
            lsbCustomer.SelectedIndex     = -1;

            var selectedIndex = cmbDiscountCard.FindStringExact(
                StringHelper.Right("000000000" + givenParam, 9));

            if (selectedIndex == -1)
            {
                selectedIndex = lsbCustomer.FindString(givenParam);
                if (selectedIndex == -1)
                {
                    foreach (var customer in _customerList)
                    {
                        if ((customer.CustomerName.ToUpper() != givenParam.ToUpper()) &&
                            (customer.PhoneNumber != givenParam) &&
                            (customer.LocalName != givenParam))
                        {
                            continue;
                        }

                        lsbCustomer.SelectedIndex = _customerList.IndexOf(customer);
                        break;
                    }
                }
                else
                {
                    lsbCustomer.SelectedIndex = selectedIndex;
                }
            }
            else
            {
                cmbDiscountCard.SelectedIndex = selectedIndex;
                lsbCustomer.SelectedValue     = ((DiscountCard)cmbDiscountCard.SelectedItem).CustomerId;
            }

            if ((lsbCustomer.SelectedIndex == -1) && (isAllowed))
            {
                var searchCriteria =
                    new List <string>
                {
                    "(CustomerName LIKE N'%" + givenParam + "%')" +
                    " OR (LocalName LIKE N'%" + givenParam + "%')" +
                    " OR (PhoneNumber LIKE '%" + givenParam + "%')" +
                    " OR (CustomerId IN (SELECT CustomerId FROM TDiscountCards WHERE CustomerId <> 0 AND CardNumber LIKE '%" +
                    givenParam + "%'))"
                };
                var customerList = _CustomerService.GetCustomers(searchCriteria);
                if (customerList.Count != 0)
                {
                    foreach (Customer customer in customerList)
                    {
                        _customerList.Add(customer);

                        var discountCardList =
                            _CustomerService.GetDiscountCardsByCustomer(customer.CustomerId);
                        foreach (DiscountCard discountCard in discountCardList)
                        {
                            _discountCardList.Add(discountCard);
                        }
                    }

                    DoCustomerFetching(givenParam, false);
                }
                else
                {
                    if (txtSearch.CanFocus)
                    {
                        txtSearch.Focus();
                    }

                    const string briefMsg  = "អំពីអតិថិជន";
                    var          detailMsg = Resources.MsgOperationRequestCustomerNotFound;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr    = briefMsg;
                        frmMessageBox.DetailMsgStr   = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }
            }

            if (lsbCustomer.CanFocus)
            {
                lsbCustomer.Focus();
            }
        }
Esempio n. 34
0
        private void RefreshReportSale()
        {
            if (chbShowBenefit.Checked)
            {
                if (!UserService.AllowToPerform(Resources.PermissionViewSaleDetailReport))
                {
                    const string briefMsg = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                    var detailMsg = Resources.MsgUserPermissionDeny;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr = briefMsg;
                        frmMessageBox.DetailMsgStr = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }
            }
            else
            {
                if (!UserService.AllowToPerform(Resources.PermissionViewSaleReport))
                {
                    const string briefMsg = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                    var detailMsg = Resources.MsgUserPermissionDeny;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr = briefMsg;
                        frmMessageBox.DetailMsgStr = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }
            }

            var searchCriteria =
                new List<string>
                {
                    "SaleOrderNumber IN (SELECT SaleOrderNumber FROM TSaleOrders WHERE SaleOrderTypeId = 0)",
                    "SaleOrderDate 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)"
                };
            var saleList = _SaleOrderService.GetSaleHistories(searchCriteria);

            DataSet dtsModel = new DtsModels();
            var propertyInfos = typeof (SaleOrderReport).GetProperties();
            foreach (var objInstance in saleList)
            {
                var dataRow = dtsModel.Tables[1].NewRow();
                foreach (var propertyInfo in propertyInfos)
                    dataRow[propertyInfo.Name] = propertyInfo.GetValue(objInstance, null);
                dtsModel.Tables[1].Rows.Add(dataRow);
            }

            if (chbShowQuantity.Checked)
            {
                var rptSaleOrderQuantity = new CsrSaleOrderQuantity();
                rptSaleOrderQuantity.SetDataSource(dtsModel);
                crvReport.ReportSource = rptSaleOrderQuantity;
            }
            else if(chbShowBenefit.Checked)
            {
                var rptSaleBenefit = new CsrSaleBenefit();
                rptSaleBenefit.SetDataSource(dtsModel);
                crvReport.ReportSource = rptSaleBenefit;
            }
            else
            {
                var rptSaleOrder = new CsrSaleOrder();
                rptSaleOrder.SetDataSource(dtsModel);
                crvReport.ReportSource = rptSaleOrder;
            }
        }
Esempio n. 35
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);
            }
        }
Esempio n. 36
0
        private void BtnSearchSaleClick(object sender, EventArgs e)
        {
            try
            {
                if (!UserService.AllowToPerform(Resources.PermissionByDatesReport))
                {
                    if ((!dtpStartDate.Value.Date.Equals(DateTime.Today)) || (!dtpStopDate.Value.Date.Equals(DateTime.Today)))
                    {
                        const string briefMsg = "សិទ្ធមើល របាយការណ៏តាមថ្ងៃ";
                        var detailMsg = Resources.MsgUserPermissionDeny;
                        using (var frmMessageBox = new FrmExtendedMessageBox())
                        {
                            frmMessageBox.BriefMsgStr = briefMsg;
                            frmMessageBox.DetailMsgStr = detailMsg;
                            frmMessageBox.IsCanceledOnly = true;
                            frmMessageBox.ShowDialog(this);
                            return;
                        }
                    }
                }

                crvReport.BringToFront();
                if (rdbSale.Checked)
                    RefreshReportSale();
                else if (rdbDeposit.Checked)
                    RefreshReportDeposit(chbAllDeposit.Checked);
                else if (rdbReturn.Checked)
                    RefreshReportReturn();
                else if (rdbExpense.Checked)
                    RefreshDailyExpenseReport();
                else
                    RefreshIncomeStatementReport();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
                throw;
            }
        }
Esempio n. 37
0
        private void RetrieveConfiguration()
        {
            try
            {
                SafeCrossCallBackDelegate safeCrossCallBackDelegate = null;

                if (pnlBody_Right.InvokeRequired)
                {
                    safeCrossCallBackDelegate = RetrieveConfiguration;
                }

                if (pnlBody_Right.InvokeRequired)
                {
                    Invoke(safeCrossCallBackDelegate);
                }
                else
                {
                    Thread.Sleep(100);

                    //Loading Service
                    pgbService.Value += 15;
                    _commonService    = ServiceFactory.GenerateServiceInstance().GenerateCommonService();
                    pgbService.Value += 15;
                    _saleOrderService = ServiceFactory.GenerateServiceInstance().GenerateSaleOrderService();
                    pgbService.Value += 15;
                    _productService   = ServiceFactory.GenerateServiceInstance().GenerateProductService();
                    pgbService.Value += 15;
                    _customerService  = ServiceFactory.GenerateServiceInstance().GenerateCustomerService();
                    pgbService.Value += 15;
                    _supplierService  = ServiceFactory.GenerateServiceInstance().GenerateSupplierService();
                    pgbService.Value += 15;
                    _expenseService   = ServiceFactory.GenerateServiceInstance().GenerateExpenseService();
                    pgbService.Value += 10;
                    _userService      = ServiceFactory.GenerateServiceInstance().GenerateUserService();

                    //Connecting to database
                    pgbGlobalConfig.Value += 50;
                    _commonService.InitializeGlobalConfiguration();
                    pgbGlobalConfig.Value += 50;

                    //Initializing workspace
                    pgbInitialization.Value += 30;
                    _commonService.InitializeWorkSpace();
                    pgbInitialization.Value += 30;
                    if (AppContext.Counter == null)
                    {
                        const string briefMsg  = "អំពីការចូលទៅក្នុងប្រព័ន្ឋ";
                        var          detailMsg = Resources.MsgCounterNotInitialize;
                        using (var frmMessageBox = new FrmExtendedMessageBox())
                        {
                            frmMessageBox.BriefMsgStr    = briefMsg;
                            frmMessageBox.DetailMsgStr   = detailMsg;
                            frmMessageBox.IsCanceledOnly = true;
                            frmMessageBox.ShowDialog(this);
                            Close();
                            return;
                        }
                    }
                    pgbInitialization.Value += 40;

                    //Loading configuration
                    pgbCustomizedConfig.Value += 80;
                    Visible = false;

                    using (var frmLogIn = new FrmLogIn())
                    {
                        frmLogIn.UserService = _userService;
                        if (frmLogIn.ShowDialog(this) == DialogResult.OK)
                        {
                            Visible = true;

                            var frmMain = new FrmMain();
                            ApplicationContext.MainForm = frmMain;

                            frmMain.CommonService    = _commonService;
                            frmMain.SaleOrderService = _saleOrderService;
                            frmMain.ProductService   = _productService;
                            frmMain.CustomerService  = _customerService;
                            frmMain.SupplierService  = _supplierService;
                            frmMain.ExpenseService   = _expenseService;
                            frmMain.UserService      = _userService;

                            _commonService.InitializeCustomizedConfiguration(frmLogIn.User);
                            pgbCustomizedConfig.Value += 20;

                            _commonService.InsertOperationLog(
                                AppContext.User.UserId,
                                int.Parse(Resources.OperationLogIn));

                            frmMain.Show();
                            Close();
                        }
                        else
                        {
                            ApplicationContext.ExitThread();
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                const string briefMsg  = "អំពីការចូលទៅក្នុងប្រព័ន្ឋ";
                var          detailMsg = Resources.MsgConnectionLost;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr    = briefMsg;
                    frmMessageBox.DetailMsgStr   = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog(this);
                    Close();
                }
            }
        }
Esempio n. 38
0
        private void DoProductFetching(string productCode, bool isAllowed)
        {
            if (String.IsNullOrEmpty(productCode))
                return;

            cmbProduct.SelectedIndex = -1;
            var selectedIndex = cmbProduct.FindStringExact(
                StringHelper.Right("000000000" + productCode, 9));

            //Switch to foreign code
            if(selectedIndex == -1)
            {
                cmbProduct.SelectedIndexChanged -= CmbProductSelectedIndexChanged;
                cmbProduct.DisplayMember = Product.ConstForeignCode;

                selectedIndex = cmbProduct.FindStringExact(productCode);

                //Switch to product code
                cmbProduct.DisplayMember = Product.ConstProductCode;
                cmbProduct.SelectedIndex = -1;
                cmbProduct.SelectedIndexChanged += CmbProductSelectedIndexChanged;
            }
            cmbProduct.SelectedIndex = selectedIndex;

            if ((selectedIndex != -1) || (!isAllowed))
                return;

            var strCriteria =
                new List<string>
                {
                    "(ProductCode = '" +
                    StringHelper.Right("000000000" + productCode, 9) +
                    "' OR ForeignCode = '" + productCode + "')",
                    "QtyInStock > 0"
                };

            var productList = _productService.GetObjects(strCriteria);
            if (productList.Count != 0)
            {
                if(productList.Count > 1)
                {
                    Visible = false;
                    using (var frmProductList = new FrmProductSearch())
                    {
                        frmProductList.CodeProduct = productCode;
                        if (frmProductList.ShowDialog(this) == DialogResult.OK)
                        {
                            var product = frmProductList.Product;
                            if (product != null)
                            {
                                _productList.Add(product);
                                DoProductFetching(product.ProductCode, true);
                            }
                        }
                        Visible = true;
                    }
                    return;
                }

                foreach (Product product in productList)
                    _productList.Add(product);

                DoProductFetching(productCode, false);
            }
            else
            {
                txtHidden.Text = string.Empty;
                const string briefMsg = "អំពីផលិតផល";
                var detailMsg = Resources.MsgOperationRequestProductNotFound;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog(this);
                    return;
                }
            }
        }
Esempio n. 39
0
        private void TsmImportClick(object sender, EventArgs e)
        {
            if (!UserService.AllowToPerform(Resources.PermissionImportExportProduct))
            {
                const string briefMsg = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                var detailMsg = Resources.MsgUserPermissionDeny;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog(this);
                    return;
                }
            }

            using (var folderBrowserDialog = new FolderBrowserDialog())
            {
                folderBrowserDialog.ShowNewFolderButton = false;
                if (folderBrowserDialog.ShowDialog() != DialogResult.OK)
                    return;

                const string briefMsg = "អំពីការលុប";
                var detailMsg = Resources.MsgOperationImportGroupCatalog;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                        return;
                }

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

                _productService.ImportProductFromXml(
                    folderBrowserDialog.SelectedPath,
                    "ProductList.xml");

                _isModified = true;
                DialogResult = DialogResult.OK;
            }
        }
Esempio n. 40
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            if (!UserService.AllowToPerform(Resources.PermissionAddUser))
            {
                const string briefMsg = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                var detailMsg = Resources.MsgUserPermissionDeny;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog(this);
                    return;
                }

                //ExtendedMessageBox.InformMessage(Resources.MsgUserPermissionDeny);
                //return;
            }

            UserManagement(Resources.OperationRequestInsert);
        }
Esempio n. 41
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);
            }
        }
Esempio n. 42
0
        private void BtnDeleteDepositClick(object sender, EventArgs e)
        {
            var briefMsg  = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
            var detailMsg = Resources.MsgUserPermissionDeny;

            if (!UserService.AllowToPerform(Resources.PermissionCancelDeposit))
            {
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr    = briefMsg;
                    frmMessageBox.DetailMsgStr   = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog(this);
                    return;
                }
            }

            if (_depositReportList == null)
            {
                return;
            }

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

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

            var depositReport = _depositReportList[dgvSearchResult.CurrentRow.Index] as DepositReport;

            if (depositReport == null)
            {
                return;
            }

            var depositService = ServiceFactory.GenerateServiceInstance().GenerateDepositService();
            var searchCriteria = new List <string> {
                "DepositId|" + depositReport.DepositId
            };
            var depositList = depositService.GetDeposits(searchCriteria);

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

            var deposit = depositList[0] as Deposit;

            if (deposit == null)
            {
                return;
            }

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

            deposit.DepositDate = DateTime.Now;
            deposit             = depositService.RecordDeposit(
                new List <DepositItem>(),
                deposit.AmountSoldInt,
                deposit.AmountPaidInt,
                0,
                deposit.FkCustomer,
                deposit.DepositNumber,
                deposit.Discount,
                true);

            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);
            BtnSearchClick(null, null);
        }
Esempio n. 43
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);
            }
        }
Esempio n. 44
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);
            }
        }
Esempio n. 45
0
        private void RefreshDailyExpenseReport()
        {
            if (!UserService.AllowToPerform(Resources.PermissionViewExpenseReport))
            {
                const string briefMsg = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                var detailMsg = Resources.MsgUserPermissionDeny;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog(this);
                    return;
                }
            }

            var searchCriteria =
                new List<string>
                {
                    "CONVERT(DATETIME, ExpenseDate, 103) 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)"
                };
            var expenseList = _ExpenseService.GetExpenses(searchCriteria);

            DataSet dtsProduct = new DtsModels();
            var propertyInfos = typeof (Expense).GetProperties();
            foreach (var objInstance in expenseList)
            {
                var dataRow = dtsProduct.Tables["DtbExpenses"].NewRow();
                foreach (var propertyInfo in propertyInfos)
                    dataRow[propertyInfo.Name] = propertyInfo.GetValue(objInstance, null);
                dtsProduct.Tables["DtbExpenses"].Rows.Add(dataRow);
            }

            var csrExpense = new CsrExpense();
            csrExpense.SetDataSource(dtsProduct);
            crvReport.ReportSource = csrExpense;
        }
Esempio n. 46
0
        private void FrmSaleQty_FormClosing(object sender, FormClosingEventArgs e)
        {
            if ((DialogResult == DialogResult.Cancel) && (_isModified))
            {
                const string briefMsg = "អំពីការបោះបង់";
                var detailMsg = Resources.MsgOperationRequestCancel;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                    {
                        e.Cancel = true;
                        return;
                    }
                }
            }

            if (_isModified)
                return;

            DialogResult = DialogResult.Cancel;
            return;
        }
Esempio n. 47
0
        private void RefreshIncomeStatementReport()
        {
            try
            {
                wbsReport.Navigate("about:blank");

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

                int counter;
                var startDate = dtpStartDate.Value.ToString("dd/MM/yyyy", AppContext.CultureInfo);
                var endDate = dtpStopDate.Value.ToString("dd/MM/yyyy", AppContext.CultureInfo);

                //Sales
                var saleOrderService = ServiceFactory.GenerateServiceInstance().GenerateSaleOrderService();
                var searchCriteria =
                    new List<string>
                        {
                            "SaleOrderDate BETWEEN CONVERT(DATETIME, '" +
                            startDate +
                            "', 103) AND CONVERT(DATETIME, '" +
                            endDate + " 23:59', 103)"
                        };

                var saleOrderList = saleOrderService.GetSaleHistoriesOrderByProductCategory(searchCriteria);

                var saleType = string.Empty;
                var saleAmount = 0f;
                var purchaseAmount = 0f;
                var groupSaleList = new List<List<object>>();
                foreach (var saleOrderReport in saleOrderList.Cast<SaleOrderReport>().Where(saleOrderReport => saleOrderReport != null))
                {
                    if (!saleOrderReport.CategoryStr.Equals(saleType))
                    {
                        List<object> groupSale;
                        if (groupSaleList.Count != 0)
                        {
                            counter = groupSaleList.Count;
                            groupSale = groupSaleList[counter - 1];

                            groupSale.Add(saleAmount);
                            groupSale.Add(purchaseAmount);

                        }

                        saleType = saleOrderReport.CategoryStr;

                        groupSale = new List<object> { saleType };
                        groupSaleList.Add(groupSale);

                        saleAmount = 0f;
                        purchaseAmount = 0f;
                    }

                    saleAmount += saleOrderReport.AmountSoldInt;
                    //saleAmount += (saleOrderReport.AmountSoldInt * saleOrderReport.ExchangeRate);
                    saleAmount += (saleOrderReport.DepositAmount);
                    //purchaseAmount += saleOrderReport.PurchaseUnitPrice;
                    purchaseAmount += (saleOrderReport.QtySold * saleOrderReport.UnitPriceIn);
                }

                if (groupSaleList.Count != 0)
                {
                    counter = groupSaleList.Count;
                    var groupExpense = groupSaleList[counter - 1];

                    groupExpense.Add(saleAmount);
                    groupExpense.Add(purchaseAmount);
                }

                //Expense
                var expenseService = ServiceFactory.GenerateServiceInstance().GenerateExpenseService();
                searchCriteria =
                    new List<string>
                    {
                        "ExpenseDate BETWEEN CONVERT(DATETIME, '" +
                        startDate +
                        "', 103) AND CONVERT(DATETIME, '" +
                        endDate +
                        "', 103)"
                    };
                var expenseList = expenseService.GetExpensesOrderByType(searchCriteria);

                var expenseType = string.Empty;
                var expenseAmount = 0f;
                var groupExpenseList = new List<List<object>>();
                foreach (var expense in expenseList.Cast<Expense>().Where(expense => expense != null))
                {
                    if (!expense.ExpenseTypeStr.Equals(expenseType))
                    {
                        List<object> groupExpense;
                        if (groupExpenseList.Count != 0)
                        {
                            counter = groupExpenseList.Count;
                            groupExpense = groupExpenseList[counter - 1];

                            groupExpense.Add(expenseAmount);
                        }

                        expenseType = expense.ExpenseTypeStr;

                        groupExpense = new List<object> { expenseType };
                        groupExpenseList.Add(groupExpense);

                        expenseAmount = 0f;
                    }

                    expenseAmount += expense.ExpenseAmountInt;
                    expenseAmount += (expense.ExpenseAmountRiel / expense.ExchangeRate);
                }

                if (groupExpenseList.Count != 0)
                {
                    counter = groupExpenseList.Count;
                    var groupExpense = groupExpenseList[counter - 1];

                    groupExpense.Add(expenseAmount);
                }

                //Write to Excel file
                var templateIncomeStatementFileName =
                    System.Windows.Forms.Application.StartupPath + @"\" +
                    Resources.ConstIncomeStatementExcelFile;

                var templateIncomeStatementFileInfo = new FileInfo(templateIncomeStatementFileName);
                if (!templateIncomeStatementFileInfo.Exists)
                {
                    const string briefMsg = "អំពីប្រព័ន្ឋ";
                    var detailMsg = Resources.MsgMissingIncomeStatement;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr = briefMsg;
                        frmMessageBox.DetailMsgStr = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }

                var temporaryIncomeStatementFileName =
                    System.Windows.Forms.Application.StartupPath + @"\" +
                    DateTime.Now.Ticks +
                    Resources.ConstIncomeStatementExcelFile;

                var invoicePeriode =
                    startDate + " ដល់ " + endDate;

                //Open workbook
                var excelApplication = new ExcelApplication();
                var workBook = excelApplication.Workbooks.Open(
                    templateIncomeStatementFileName,
                    0,
                    false,
                    5,
                    false,
                    string.Empty,
                    false,
                    XlPlatform.xlWindows,
                    string.Empty,
                    true,
                    false,
                    0,
                    true,
                    false,
                    false);

                //Invoice content
                var workSheet = (Worksheet)workBook.Worksheets[Resources.ConstSheetIncomeStatement];

                //Shop name
                var rowIndex = 1;
                var excelRange = workSheet.get_Range("A" + rowIndex, "A" + rowIndex);
                excelRange.Select();
                excelRange.Value2 = "របាយការណ៏ហិរញ្ញវុត្ថុរបស់ក្រុមហ៊ុន  " + AppContext.ShopNameLocal;

                rowIndex = 2;
                excelRange = workSheet.get_Range("A" + rowIndex, "A" + rowIndex);
                excelRange.Select();
                excelRange.Value2 = "Financial Statement of " + AppContext.ShopName;

                //Period
                rowIndex = 3;
                excelRange = workSheet.get_Range("A" + rowIndex, "A" + rowIndex);
                excelRange.Select();
                excelRange.Value2 = "ពី " + invoicePeriode;

                //Income
                rowIndex = 5;
                counter = 0;
                var totalPurchaseAmount = 0f;
                foreach (var saleReport in groupSaleList.Where(saleReport => saleReport != null))
                {
                    excelRange = workSheet.get_Range("B" + rowIndex, "B" + rowIndex);
                    excelRange.Select();
                    excelRange.Value2 = saleReport[0].ToString();

                    excelRange = workSheet.get_Range("C" + rowIndex, "C" + rowIndex);
                    excelRange.Select();
                    excelRange.Value2 = "…………………………………….";

                    excelRange = workSheet.get_Range("D" + rowIndex, "D" + rowIndex);
                    excelRange.Select();
                    excelRange.Value2 = "USD";

                    excelRange = workSheet.get_Range("E" + rowIndex, "E" + rowIndex);
                    excelRange.Select();
                    excelRange.Value2 = float.Parse(saleReport[1].ToString());
                    totalPurchaseAmount += float.Parse(saleReport[2].ToString());

                    rowIndex += 1;
                    excelRange = workSheet.get_Range("A" + rowIndex, "A" + rowIndex);
                    if (counter == (groupSaleList.Count - 1))
                        continue;

                    excelRange.EntireRow.Insert(XlInsertShiftDirection.xlShiftDown, 1);
                    counter += 1;
                }

                //Purchase amount
                rowIndex += 3;
                excelRange = workSheet.get_Range("E" + rowIndex, "E" + rowIndex);
                excelRange.Select();
                excelRange.Value2 = totalPurchaseAmount;

                //Expense
                rowIndex += 4;
                counter = 0;
                foreach (var expenseReport in groupExpenseList.Where(expenseReport => expenseReport != null))
                {
                    excelRange = workSheet.get_Range("B" + rowIndex, "B" + rowIndex);
                    excelRange.Select();
                    excelRange.Value2 = expenseReport[0].ToString();

                    excelRange = workSheet.get_Range("C" + rowIndex, "C" + rowIndex);
                    excelRange.Select();
                    excelRange.Value2 = "…………………………………….";

                    excelRange = workSheet.get_Range("D" + rowIndex, "D" + rowIndex);
                    excelRange.Select();
                    excelRange.Value2 = "USD";

                    excelRange = workSheet.get_Range("E" + rowIndex, "E" + rowIndex);
                    excelRange.Select();
                    excelRange.Value2 = expenseReport[1].ToString();

                    rowIndex += 1;
                    excelRange = workSheet.get_Range("A" + rowIndex, "A" + rowIndex);
                    if (counter == (groupExpenseList.Count - 1))
                        continue;

                    excelRange.EntireRow.Insert(XlInsertShiftDirection.xlShiftDown, 1);
                    counter += 1;
                }

                excelRange = workSheet.get_Range("A1", "A1");
                excelRange.Select();

                workBook.Close(
                    true,
                    temporaryIncomeStatementFileName,
                    System.Reflection.Missing.Value);

                excelApplication.Quit();

                Marshal.ReleaseComObject(excelApplication);
                GC.Collect(0, GCCollectionMode.Forced);
                GC.WaitForPendingFinalizers();

                //Open report
                wbsReport.BringToFront();
                wbsReport.Navigate(temporaryIncomeStatementFileName);
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Esempio n. 48
0
        private void BtnDeleteDepositClick(object sender, EventArgs e)
        {
            var briefMsg = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
            var detailMsg = Resources.MsgUserPermissionDeny;
            if (!UserService.AllowToPerform(Resources.PermissionCancelDeposit))
            {
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog(this);
                    return;
                }
            }

            if (_depositReportList == null)
                return;

            if (_depositReportList.Count == 0)
                return;

            if (dgvSearchResult.CurrentRow == null)
                return;

            var depositReport = _depositReportList[dgvSearchResult.CurrentRow.Index] as DepositReport;
            if(depositReport == null)
                return;

            var depositService = ServiceFactory.GenerateServiceInstance().GenerateDepositService();
            var searchCriteria = new List<string> {"DepositId|" + depositReport.DepositId};
            var depositList = depositService.GetDeposits(searchCriteria);
            if (depositList.Count == 0)
                return;

            var deposit = depositList[0] as Deposit;
            if (deposit == null)
                return;

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

            deposit.DepositDate = DateTime.Now;
            deposit = depositService.RecordDeposit(
                new List<DepositItem>(),
                deposit.AmountSoldInt,
                deposit.AmountPaidInt,
                0,
                deposit.FkCustomer,
                deposit.DepositNumber,
                deposit.Discount,
                true);

            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);
            BtnSearchClick(null, null);
        }
Esempio n. 49
0
        private void RefreshReportDeposit(bool allDeposit)
        {
            if (!UserService.AllowToPerform(Resources.PermissionViewDepositReport))
            {
                const string briefMsg = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                var detailMsg = Resources.MsgUserPermissionDeny;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    frmMessageBox.IsCanceledOnly = true;
                    frmMessageBox.ShowDialog(this);
                    return;
                }
            }

            var searchCriteria =
                !allDeposit ?
                new List<string>
                {
                    "(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)) ",
                    "(AmountPaidInt < AmountSoldInt) ",
                    "DepositNumber NOT IN (SELECT ReferenceNum FROM TDeposits WHERE ReferenceNum IS NOT NULL) "
                } :
                new List<string>
                {
                    "(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)) "
                };
            var assessmentList = _depositService.GetDepositHistories(searchCriteria, false);

            DataSet dtsModel = new DtsModels();
            var propertyInfos = typeof(DepositReport).GetProperties();
            foreach (var objInstance in assessmentList)
            {
                var dataRow = dtsModel.Tables[3].NewRow();
                foreach (var propertyInfo in propertyInfos)
                    dataRow[propertyInfo.Name] = propertyInfo.GetValue(objInstance, null);
                dtsModel.Tables[3].Rows.Add(dataRow);
            }

            var rptDeposit = new CsrDeposit();
            rptDeposit.SetDataSource(dtsModel);
            crvReport.ReportSource = rptDeposit;
        }
Esempio n. 50
0
        private void BtnProductAdjustmentClick(object sender, EventArgs e)
        {
            ScanFocusHandler();
            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;
                }
            }

            if (_saleItemBindingList == null)
                return;

            if (_saleItemBindingList.Count == 0)
                return;

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

            try
            {
                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>();
                        foreach (var saleItem in _saleItemBindingList)
                        {
                            var product = saleItem.FkProduct;
                            //Save QtyInStock of product
                            saleItem.FkProduct.PublicQty = saleItem.FkProduct.QtyInStock.ToString("N2",
                                                                                                  AppContext.CultureInfo);
                            product.QtyInStock = saleItem.QtySold;
                            listProduct2Export.Add(product);
                        }

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

                        foreach (var saleItem in _saleItemBindingList.Where(saleItem => saleItem != null))
                        {
                            //Restore QtyInStock of product
                            saleItem.FkProduct.QtyInStock = float.Parse(saleItem.FkProduct.PublicQty);
                            //saleItem.QtySold = saleItem.FKProduct.QtyInStock;
                            saleItem.UnitPriceIn = 0;
                            saleItem.UnitPriceOut = 0;
                            saleItem.PublicUpOut = 0;
                            saleItem.SubTotal = 0;
                        }

                        dgvSaleItem.Refresh();
                        CalculateSale();
                        _productService.ProductAdjustmentManagement(
                            Resources.OperationRequestInsert,
                            _saleItemBindingList);
                        DoActivateControls(false);
                    }
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Esempio n. 51
0
        private void ImportAllCatalogs()
        {
            using (var folderBrowserDialog = new FolderBrowserDialog())
            {
                folderBrowserDialog.ShowNewFolderButton = false;
                if (folderBrowserDialog.ShowDialog() != DialogResult.OK)
                    return;

                const string briefMsg = "អំពីការលុប";
                var detailMsg = Resources.MsgOperationImportGroupCatalog;
                using (var frmMessageBox = new FrmExtendedMessageBox())
                {
                    frmMessageBox.BriefMsgStr = briefMsg;
                    frmMessageBox.DetailMsgStr = detailMsg;
                    if (frmMessageBox.ShowDialog(this) != DialogResult.OK)
                        return;
                }

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

                _productService.ImportGroupCatalog(
                    folderBrowserDialog.SelectedPath,
                    Int32.Parse(cmbCategory.SelectedValue.ToString()),
                    cmbCategory.Text,
                    Int32.Parse(cmbMark.SelectedValue.ToString()),
                    cmbMark.Text,
                    Int32.Parse(cmbColor.SelectedValue.ToString()),
                    cmbColor.Text,
                    Int32.Parse(cmbSize.SelectedValue.ToString()),
                    cmbSize.Text);

                _isModified = true;
                DialogResult = DialogResult.OK;
            }
        }
Esempio n. 52
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);
            }
        }
Esempio n. 53
0
        private void BtnSearchSaleOrderClick(object sender, EventArgs e)
        {
            ScanFocusHandler();
            try
            {
                if (!_returnEnabled)
                {
                    Visible = false;
                    using (var frmSaleSearch = new FrmSaleSearch())
                    {
                        if (frmSaleSearch.ShowDialog(this) == DialogResult.OK)
                        {
                            var saleOrderNumber = frmSaleSearch.SearchSoNumber;
                            var indexOf = saleOrderNumber.IndexOf(" (");
                            if(indexOf > 0)
                                saleOrderNumber = StringHelper.Left(saleOrderNumber, indexOf);

                            var searchCriteria = new List<string> { "SaleOrderNumber|" + saleOrderNumber };
                            var saleOrderList = _saleOrderService.GetSaleOrders(searchCriteria);
                            if (saleOrderList.Count == 0)
                            {
                                Visible = true;
                                return;
                            }

                            _saleOrder = (SaleOrder)saleOrderList[0];
                            if (_saleOrder == null)
                            {
                                Visible = true;
                                return;
                            }

                            dgvSaleItem.SelectionChanged += DgvSaleItemSelectionChanged;
                            IListToBindingList(
                                _saleOrderService.GetSaleItems(_saleOrder.SaleOrderId));
                            _saleOrder.FkCustomer.DiscountPercentage = _saleOrder.Discount;
                            SetCustomerInfo(_saleOrder.FkCustomer);
                            CalculateSale();
                            SetInvoiceInfo(
                                _saleOrder.SaleOrderNumber,
                                _saleOrder.AmountSoldInt,
                                _saleOrder.AmountPaidInt,
                                _saleOrder.AmountPaidRiel,
                                _saleOrder.AmountReturnInt);

                            ////If invoice has already been voided
                            //searchCriteria = new List<string> {"ReferenceNum|" + _saleOrder.SaleOrderNumber};
                            //saleOrderList = _saleOrderService.GetSaleOrders(searchCriteria);

                            //if (saleOrderList.Count != 0)
                            //{
                            //    _returnEnabled = false;
                            //    SaleItemBindingListChanged(null, null);
                            //}
                            //else
                            //{
                                DoActivateControls(false);
                                ReturnHandler(_returnEnabled = true);
                            //}
                        }
                        Visible = true;
                    }
                }
                else
                {
                    string briefMsg, detailMsg;
                    if (!UserService.AllowToPerform(Resources.PermissionReturnProduct))
                    {
                        briefMsg = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                        detailMsg = Resources.MsgUserPermissionDeny;
                        using (var frmMessageBox = new FrmExtendedMessageBox())
                        {
                            frmMessageBox.BriefMsgStr = briefMsg;
                            frmMessageBox.DetailMsgStr = detailMsg;
                            frmMessageBox.IsCanceledOnly = true;
                            frmMessageBox.ShowDialog(this);
                            return;
                        }
                    }

                    if (_saleOrder == null)
                        return;

                    if (_saleItemBindingList.Count == 0)
                        return;

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

                    _saleOrder = _saleOrderService.RecordSaleOrder(
                        _saleItemBindingList,
                        _totalAmountInt,
                        _totalAmountInt,
                        _totalAmountInt * AppContext.ExchangeRate.ExchangeValue,
                        0,
                        _saleOrder.FkCustomer,
                        true,
                        _saleOrder.SaleOrderNumber,
                        _saleOrder.Discount,
                        0,
                        false);

                    ReturnHandler(_returnEnabled = false);
                    SetInvoiceInfo(
                        _saleOrder.SaleOrderNumber,
                        _saleOrder.AmountSoldInt,
                        _saleOrder.AmountPaidInt,
                        _saleOrder.AmountPaidRiel,
                        _saleOrder.AmountReturnInt);

                    dgvSaleItem.Refresh();
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }