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); } }
private void RetrieveDataHandler() { try { var searchCriteria = new List <string> { "CustomerId|" + CustomerId, "AmountPaidInt < AmountSoldInt", "DepositNumber NOT IN (SELECT ReferenceNum FROM TDeposits WHERE ReferenceNum IS NOT NULL)" }; IListToBindingList( _depositService.GetDeposits(searchCriteria)); var searchInfo = String.Format( "ការស្វែងរករបស់អ្នកផ្ដល់លទ្ឋផលចំនួន {0}", _depositList.Count); lblSearchInfo.Text = searchInfo; } catch (Exception exception) { FrmExtendedMessageBox.UnknownErrorMessage( Resources.MsgCaptionUnknownError, exception.Message); } }
private void SetSupplierInfo() { if (_Supplier == null) { return; } try { if (_Supplier == null) { return; } txtSupplierName.Text = _Supplier.SupplierName; txtPhoneNumber.Text = _Supplier.PhoneNumber; txtFaxNumber.Text = _Supplier.FaxNumber; txtEmailAddress.Text = _Supplier.EmailAddress; txtWebsite.Text = _Supplier.Website; cmbCountry.SelectedValue = _Supplier.CountryId; txtBankInfo.Text = _Supplier.BankInformation; txtAddress.Text = _Supplier.Address; } catch (Exception exception) { FrmExtendedMessageBox.UnknownErrorMessage( Resources.MsgCaptionUnknownError, exception.Message); } }
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(); } } }
private void InitializeSaleOrderReportList() { try { if (_saleOrderReportList == null) { _saleOrderReportList = new BindingList <SaleOrderReport>(); } dgvSearchResult.DataSource = _saleOrderReportList; dgvSearchResult.Columns["SaleOrderNumber"].DisplayIndex = 0; dgvSearchResult.Columns["SaleOrderDate"].DisplayIndex = 1; dgvSearchResult.Columns["CustomerName"].DisplayIndex = 2; dgvSearchResult.Columns["CashierName"].DisplayIndex = 3; dgvSearchResult.Columns["AmountSoldInt"].DisplayIndex = 4; dgvSearchResult.Columns["AmountPaidInt"].DisplayIndex = 5; dgvSearchResult.Columns["AmountReturnInt"].DisplayIndex = 6; } catch (Exception exception) { FrmExtendedMessageBox.UnknownErrorMessage( Resources.MsgCaptionUnknownError, exception.Message); } }
private void FrmSaleOrderSearch_Load(object sender, EventArgs e) { try { if (_commonService == null) { _commonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService(); } dtpStartDate.Value = DateTime.Now.AddMonths(-1); InitializeSaleOrderReportList(); ThreadStart threadStart = UpdateControlContent; var thread = new Thread(threadStart) { Priority = ThreadPriority.Lowest }; thread.Start(); } catch (Exception exception) { FrmExtendedMessageBox.UnknownErrorMessage( Resources.MsgCaptionUnknownError, exception.Message); } }
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); } }
private void IListToBindingList(IList productList) { if (productList == null) { throw new ArgumentNullException("productList", "Product List"); } if (_productList == null) { btnValidate.Enabled = false; return; } try { _productList.Clear(); foreach (Product product in productList) { SetProductPicture(product); _productList.Add(product); } btnValidate.Enabled = _productList.Count != 0; } catch (Exception exception) { FrmExtendedMessageBox.UnknownErrorMessage( Resources.MsgCaptionUnknownError, exception.Message); } }
private void PaymentManagement() { try { if (string.IsNullOrEmpty(txtAmountPaidUsd.Text)) { txtAmountPaidUsd.Text = Resources.ConstAmountZeroTwoDigits; } if (string.IsNullOrEmpty(txtAmountPaidRiel.Text)) { txtAmountPaidRiel.Text = Resources.ConstAmountZeroTwoDigits; } if (string.IsNullOrEmpty(txtTotalAmountUsd.Text)) { txtTotalAmountUsd.Text = Resources.ConstAmountZeroTwoDigits; } var amountToPay = float.Parse(txtTotalAmountUsd.Text); AmountPaidInt = float.Parse(txtAmountPaidUsd.Text); AmountPaidRiel = float.Parse(txtAmountPaidRiel.Text); AmountPaidInt += float.Parse(txtAmountPaidRiel.Text) / _exchangeRate; txtAmountReturnUsd.Text = (AmountPaidInt - amountToPay).ToString("N", AppContext.CultureInfo); txtAmountReturnRiel.Text = ((AmountPaidInt - amountToPay) * _exchangeRate).ToString("N", AppContext. CultureInfo); } catch (Exception exception) { FrmExtendedMessageBox.UnknownErrorMessage( Resources.MsgCaptionUnknownError, exception.Message); } }
private void InitializeDepositList() { try { if (_depositList == null) { _depositList = new BindingList <Deposit>(); } dgvDeposit.DataSource = _depositList; dgvDeposit.Columns["DepositNumber"].DisplayIndex = 0; dgvDeposit.Columns["DepositDate"].DisplayIndex = 1; dgvDeposit.Columns["CashierName"].DisplayIndex = 2; dgvDeposit.Columns["AmountSoldInt"].DisplayIndex = 3; dgvDeposit.Columns["AmountPaidInt"].DisplayIndex = 4; dgvDeposit.Columns["AmountReturnInt"].DisplayIndex = 5; } catch (Exception exception) { FrmExtendedMessageBox.UnknownErrorMessage( Resources.MsgCaptionUnknownError, exception.Message); } }
private void FrmDeposit_Load(object sender, EventArgs e) { try { if (_commonService == null) { _commonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService(); } if (_depositService == null) { _depositService = ServiceFactory.GenerateServiceInstance().GenerateDepositService(); } if (_saleOrderService == null) { _saleOrderService = ServiceFactory.GenerateServiceInstance().GenerateSaleOrderService(); } InitializeDepositList(); RetrieveDataHandler(); } catch (Exception exception) { FrmExtendedMessageBox.UnknownErrorMessage( Resources.MsgCaptionUnknownError, exception.Message); } }
private void FrmProduct_Load(object sender, EventArgs e) { try { if (_saleItem == null) { DialogResult = DialogResult.Cancel; return; } if (_saleItem.FkProduct == null) { DialogResult = DialogResult.Cancel; return; } SetProductInfo(_saleItem.FkProduct); } catch (Exception exception) { FrmExtendedMessageBox.UnknownErrorMessage( Resources.MsgCaptionUnknownError, exception.Message); } }
private void cmdSave_Click(object sender, EventArgs e) { if (txtExchangeRate.Text == null) { return; } if (txtExchangeRate.Text.Length == 0) { return; } try { var exchangeRate = new ExchangeRate(); exchangeRate.ExchangeDateTime = dtpExchangeDate.Value; exchangeRate.ExchangeValue = float.Parse(txtExchangeRate.Text); exchangeRate.FromCurrencyId = Int32.Parse(cbbFromCurrency.SelectedValue.ToString()); exchangeRate.ToCurrencyId = Int32.Parse(cbbToCurrency.SelectedValue.ToString()); _CommonService.InsertExchangeRate(exchangeRate); Close(); } catch (Exception exception) { FrmExtendedMessageBox.UnknownErrorMessage( Resources.MsgCaptionUnknownError, exception.Message); } }
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; }
private void FrmProduct_Load(object sender, EventArgs e) { try { if (_productService == null) { _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService(); } if (_commonService == null) { _commonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService(); } InitializeProductList(); if (!string.IsNullOrEmpty(_codeProduct)) { txtProductCode.Text = _codeProduct; ProductFetching(); } } catch (Exception exception) { FrmExtendedMessageBox.UnknownErrorMessage( Resources.MsgCaptionUnknownError, exception.Message); } }
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; } } }
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); } }
private void ManageCustomer(Customer customer, string operationStr) { if (String.IsNullOrEmpty(operationStr)) { return; } Visible = false; using (var frmCustomer = new FrmCustomer()) { DiscountCard discountCard = null; if (customer != null) { frmCustomer.Customer = customer; discountCard = customer.FkDiscountCard; } if (frmCustomer.ShowDialog(this) == DialogResult.OK) { try { //Remove existing discount card of selected customer if (discountCard != null) { _discountCardList.Remove(discountCard); } //Add new discount card of selected customer if (frmCustomer.Customer.FkDiscountCard != null) { _discountCardList.Add(frmCustomer.Customer.FkDiscountCard); } //Customer if (operationStr.Equals(Resources.OperationRequestInsert)) { _customerList.Add(frmCustomer.Customer); } else { _customerList[_customerList.IndexOf(lsbCustomer.SelectedItem as Customer)] = frmCustomer.Customer; } lsbCustomer.SelectedIndex = -1; lsbCustomer.SelectedIndex = lsbCustomer.FindStringExact(frmCustomer.Customer.CustomerName); } catch (Exception exception) { FrmExtendedMessageBox.UnknownErrorMessage( Resources.MsgCaptionUnknownError, exception.Message); } } Visible = true; } }
private void TxtProductCodeKeyDown(object sender, KeyEventArgs e) { if (e == null) { return; } try { switch (e.KeyCode) { case Keys.Up: if (_productList.Count == 0) { return; } UpdateSelectedIndex(dgvProduct.SelectedRows[0].Index - 1); break; case Keys.Down: if (_productList.Count == 0) { return; } UpdateSelectedIndex(dgvProduct.SelectedRows[0].Index + 1); break; case Keys.Return: if (!txtProductCode.Text.Equals(_codeProduct)) { _codeProduct = txtProductCode.Text; ProductFetching(); return; } if (!btnValidate.Enabled) { return; } DialogResult = Product != null ? DialogResult.OK : DialogResult.Cancel; break; default: break; } } catch (Exception exception) { FrmExtendedMessageBox.UnknownErrorMessage( Resources.MsgCaptionUnknownError, exception.Message); } }
private void FrmCustomer_Load(object sender, EventArgs e) { try { if (_CustomerService == null) { _CustomerService = ServiceFactory.GenerateServiceInstance().GenerateCustomerService(); } if (_CommonService == null) { _CommonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService(); } var objList = _CommonService.GetAppParametersByType( int.Parse(Resources.AppParamGender)); _CommonService.PopAppParamExtendedCombobox( ref cmbGender, objList, int.Parse(Resources.AppParamGender), true); objList = _CommonService.GetAppParametersByType( int.Parse(Resources.AppParamDiscountType)); _CommonService.PopAppParamExtendedCombobox( ref cmbDCardType, objList, int.Parse(Resources.AppParamDiscountType), true); cmbDCardType.SelectedIndex = 0; lblDisPercentage.Text = ((AppParameter)cmbDCardType.SelectedItem).ParameterValue; var criteriaList = new List <string> { "CustomerId|0" }; if (cmbDCardType.SelectedItem != null) { criteriaList.Add("DiscountCardTypeId|" + ((AppParameter)cmbDCardType.SelectedItem).ParameterId); } objList = _CustomerService.GetDiscountCards(criteriaList); lsbDiscountCard.DataSource = objList; if (objList.Count != 0) { lsbDiscountCard.DisplayMember = DiscountCard.ConstDiscountCardNumber; lsbDiscountCard.ValueMember = DiscountCard.ConstDiscountCardId; lsbDiscountCard.SelectedIndex = -1; } SetCustomerInfo(); } catch (Exception exception) { FrmExtendedMessageBox.UnknownErrorMessage( Resources.MsgCaptionUnknownError, exception.InnerException.Message); } }
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); } }
private void TxtExpenseAmountIntLeave(object sender, EventArgs e) { txtExpenseAmountInt.TextChanged -= ModificationHandler; try { txtExpenseAmountInt.Text = float.Parse(txtExpenseAmountInt.Text).ToString("N"); } catch (Exception exception) { FrmExtendedMessageBox.UnknownErrorMessage( Resources.MsgCaptionUnknownError, exception.Message); } }
private void TxtUpInLeave(object sender, EventArgs e) { txtUPIn.TextChanged -= ModificationHandler; try { txtUPIn.Text = float.Parse(txtUPIn.Text).ToString("N3", AppContext.CultureInfo); } catch (Exception exception) { FrmExtendedMessageBox.UnknownErrorMessage( Resources.MsgCaptionUnknownError, exception.Message); } }
private void CalculateProductCost(bool waitStatus) { try { if (string.IsNullOrEmpty(txtUPIn.Text)) { txtUPIn.Text = Resources.ConstAmountZeroThreeDigits; } if (string.IsNullOrEmpty(txtExtraPercentage.Text)) { txtExtraPercentage.Text = Resources.ConstAmountZeroOneDigit; } if (string.IsNullOrEmpty(txtDiscount.Text)) { txtDiscount.Text = Resources.ConstAmountZeroOneDigit; } if (string.IsNullOrEmpty(txtUPOut.Text)) { txtUPOut.Text = Resources.ConstAmountZeroThreeDigits; } float discountPercentage; float unitPriceOut; if (waitStatus) { unitPriceOut = float.Parse(txtUPOut.Text); discountPercentage = 100 - ((100 * unitPriceOut) / _defaultUnitPriceOut); discountPercentage = discountPercentage < 0 ? 0 : discountPercentage; txtDiscount.Text = Math.Round(discountPercentage, 0).ToString("N", AppContext.CultureInfo); } else { var unitPriceIn = float.Parse(txtUPIn.Text); var extraPercentage = float.Parse(txtExtraPercentage.Text); discountPercentage = float.Parse(txtDiscount.Text); unitPriceOut = unitPriceIn + ((unitPriceIn * extraPercentage) / 100); unitPriceOut = unitPriceOut - ((unitPriceOut * discountPercentage) / 100); //txtUPOut.Text = Math.Round(unitPriceOut, 0).ToString("N", AppContext.CultureInfo); txtUPOut.Text = unitPriceOut.ToString("N3", AppContext.CultureInfo); _defaultUnitPriceOut = float.Parse(txtUPOut.Text); } } catch (Exception exception) { FrmExtendedMessageBox.UnknownErrorMessage( Resources.MsgCaptionUnknownError, exception.Message); } }
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; } }
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; } }
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); } }
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); } }
private void TxtProductCodeLeave(object sender, EventArgs e) { txtForeignCode.TextChanged -= ModificationHandler; string detailMsg; if (!_productService.IsValidatedProductCode(_product != null ? _product.ProductId : 0, txtForeignCode.Text, out detailMsg)) { const string briefMsg = "អំពីពត៌មាន"; using (var frmMessageBox = new FrmExtendedMessageBox()) { frmMessageBox.BriefMsgStr = briefMsg; frmMessageBox.DetailMsgStr = detailMsg; frmMessageBox.IsCanceledOnly = true; return; } } DoProductFetching(txtForeignCode.Text, true); }
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; } }
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; } }
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); } }
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; }
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); } }
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; }
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; }
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(); } } }
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; } }
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); } }
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); }
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); } }
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); } }
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; }
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); }
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; } } }
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); } }
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); } }
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); } }
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; }
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; }
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); }
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; } }
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); } }
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; } }
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); } }
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; } }