コード例 #1
0
        private void DisplayPartialPicture(
            int numPicture,
            int startIndex,
            int stopIndex,
            ScrollEventType scrollEventType)
        {
            try
            {
                if ((scrollEventType == ScrollEventType.SmallDecrement) ||
                    (scrollEventType == ScrollEventType.LargeDecrement))
                {
                    var tmpIndex = startIndex;
                    startIndex = stopIndex;
                    stopIndex  = tmpIndex;

                    for (var counter = startIndex + numPicture; counter < stopIndex + numPicture; counter++)
                    {
                        if (counter < _productList.Count)
                        {
                            _productList[counter].ProductPic = null;
                        }
                    }

                    for (var counter = startIndex; counter < startIndex + numPicture; counter++)
                    {
                        SetProductPicture(_productList[counter]);
                    }
                }
                else
                {
                    for (var counter = startIndex; counter < stopIndex; counter++)
                    {
                        _productList[counter].ProductPic = null;
                        if (counter >= numPicture)
                        {
                            break;
                        }
                    }

                    for (var counter = stopIndex; counter < stopIndex + numPicture; counter++)
                    {
                        SetProductPicture(_productList[counter]);
                    }
                }
                dgvProduct.Refresh();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #2
0
 private void AppParamManagement(AppParameter appParameter, string operationRequest)
 {
     try
     {
         _CommonService.AppParameterManagement(appParameter, operationRequest);
     }
     catch (Exception exception)
     {
         FrmExtendedMessageBox.UnknownErrorMessage(
             Resources.MsgCaptionUnknownError,
             exception.Message);
     }
 }
コード例 #3
0
        private void CtrlSupplier_Load(object sender, EventArgs e)
        {
            try
            {
                if (_CommonService == null)
                {
                    _CommonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();
                }
                if (_SupplierService == null)
                {
                    _SupplierService = ServiceFactory.GenerateServiceInstance().GenerateSupplierService();
                }
                if (!UserService.AllowToPerform(Resources.PermissionViewSuppResultInfo))
                {
                    lblResultInfo.Visible = false;
                }
                InitialSupplierList();

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

                //IList objList = _SupplierService.GetSuppliers();
                //cmbCustomer.CustomizedDataBinding(
                //    objList,
                //    Customer.CONST_CUSTOMER_NAME,
                //    Customer.CONST_CUSTOMER_Id,
                //    false);

                //var customerList = new List<Customer>();
                //foreach (Customer customer in objList)
                //    customerList.Add(customer);

                //cmbCustomerHidden.CustomizedDataBinding(
                //    customerList,
                //    Customer.CONST_CUSTOMER_NAME,
                //    Customer.CONST_CUSTOMER_Id,
                //    false);

                //btnSearch_Click(sender, e);
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #4
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;
            }
        }
コード例 #5
0
        private void lsbProduct_SelectedIndexChanged(object sender, EventArgs e)
        {
            if ((lsbAppParam.SelectedIndex == -1) || (StringHelper.Length(lsbAppParam.DisplayMember) == 0) ||
                (StringHelper.Length(lsbAppParam.ValueMember) == 0))
            {
                return;
            }

            try
            {
                //Will change later
                if (Int32.Parse(lsbAppParam.SelectedValue.ToString(), AppContext.CultureInfo) == 21)
                {
                    using (var frmExchangeRate = new FrmExchangeRate())
                    {
                        frmExchangeRate.ShowDialog(this);
                        return;
                    }
                }

                _AppParamList =
                    _CommonService.GetAppParametersByType(
                        Int32.Parse(lsbAppParam.SelectedValue.ToString(), AppContext.CultureInfo));
                dgvAppParameter.DataSource = CommonService.IListToDataTable(typeof(AppParameter), _AppParamList);

                cmbAppParamValue.DataSource = _AppParamList;
                if (StringHelper.Length(cmbAppParamValue.DisplayMember) == 0)
                {
                    cmbAppParamValue.DisplayMember = AppParameter.ConstParameterValue;
                }
                if (StringHelper.Length(cmbAppParamValue.ValueMember) == 0)
                {
                    cmbAppParamValue.ValueMember = AppParameter.ConstParameterId;
                }

                if (_AppParamList.Count != 0)
                {
                    cmbAppParamValue.SelectedIndex = _AppParamList.Count - 1;
                    dgvAppParameter.Columns["ParameterTypeId"].Visible     = false;
                    dgvAppParameter.Columns["ParameterLabel"].DisplayIndex = 0;
                    dgvAppParameter.Columns["ParameterCode"].DisplayIndex  = 1;
                    dgvAppParameter.Columns["ParameterValue"].DisplayIndex = 2;
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError, exception.Message);
            }
        }
コード例 #6
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);
            }
        }
コード例 #7
0
        private void BtnSearchClick(object sender, EventArgs e)
        {
            try
            {
                var searchCriteria = new List <string>();
                if (StringHelper.Length(txtCustomerName.Text) != 0)
                {
                    searchCriteria.Add("CustomerName LIKE '%" + txtCustomerName.Text + "%'");
                }

                if (StringHelper.Length(txtPhoneNumber.Text) != 0)
                {
                    searchCriteria.Add("PhoneNumber LIKE '%" + txtPhoneNumber.Text + "%'");
                }

                if (chbDeposit.Checked)
                {
                    searchCriteria.Add(
                        "CustomerId IN (SELECT CustomerId FROM TDeposits WHERE (AmountPaidInt < AmountSoldInt) AND (DepositNumber NOT IN (SELECT ReferenceNum FROM TDeposits WHERE ReferenceNum IS NOT NULL)))");
                }

                if (StringHelper.Length(txtCardNum.Text) != 0)
                {
                    searchCriteria.Add(
                        "CustomerId IN (SELECT CustomerId FROM TDiscountCards WHERE CustomerId <> 0 AND CardNumber LIKE '%" +
                        StringHelper.Right("000000000" + txtCardNum.Text, 9) + "%')");
                }

                if (cmbDCardType.SelectedIndex != -1)
                {
                    searchCriteria.Add(
                        "CustomerId IN (SELECT CustomerId FROM TDiscountCards WHERE CustomerId <> 0 AND DiscountCardTypeId = " +
                        cmbDCardType.SelectedValue + ")");
                }

                IListToBindingList(
                    _customerService.GetCustomers(searchCriteria));
                dgvCustomer.Refresh();
            }
            catch (ADOException exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #8
0
        private void CustomerManagement(IEquatable <string> operationRequest)
        {
            using (var frmCustomer = new FrmCustomer())
            {
                frmCustomer.CommonService   = _commonService;
                frmCustomer.CustomerService = _customerService;

                if (operationRequest.Equals(Resources.OperationRequestUpdate))
                {
                    if (dgvCustomer.CurrentRow != null)
                    {
                        frmCustomer.Customer = _customerList[dgvCustomer.CurrentRow.Index];
                    }
                }

                if (frmCustomer.ShowDialog(this) == DialogResult.OK)
                {
                    try
                    {
                        ThreadStart threadStart = UpdateControlContent;
                        var         thread      = new Thread(threadStart);
                        thread.Start();

                        if (operationRequest.Equals(Resources.OperationRequestInsert))
                        {
                            _customerList.Add(frmCustomer.Customer);
                        }

                        dgvCustomer.Refresh();
                        SetCustomerInfo();
                        UpdateResultInfo();
                        EnableActionButton();
                    }
                    catch (Exception exception)
                    {
                        FrmExtendedMessageBox.UnknownErrorMessage(
                            Resources.MsgCaptionUnknownError,
                            exception.Message);
                    }
                }
            }

            SetFocusToCustomerList();
        }
コード例 #9
0
        private void CtrlCustomer_Load(object sender, EventArgs e)
        {
            try
            {
                if (!UserService.AllowToPerform(Resources.PermissionViewCustResultInfo))
                {
                    lblResultInfo.Visible = false;
                }
                if (_customerService == null)
                {
                    _customerService = ServiceFactory.GenerateServiceInstance().GenerateCustomerService();
                }
                if (_commonService == null)
                {
                    _commonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();
                }

                InitializeCustomerList();

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

                var discountCardList = _customerService.GetUsedDiscountCards();
                cmbDiscountCard.CustomizedDataBinding(
                    discountCardList,
                    DiscountCard.ConstDiscountCardNumber,
                    DiscountCard.ConstCustomerId,
                    false);

                IListToBindingList(_customerService.GetCustomers());
                dgvCustomer.Refresh();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #10
0
        private void IListToBindingList(IEnumerable productList)
        {
            if (productList == null)
            {
                throw new ArgumentNullException("productList", Resources.MsgInvalidProduct);
            }

            if (_productList == null)
            {
                return;
            }

            try
            {
                _productList.Clear();
                foreach (var product in productList.Cast <Product>().Where(product => product != null))
                {
                    var localProduct = product;
                    foreach (var barCode in _barCodeList.Where(barCode => localProduct.ProductCode == barCode.BarCodeValue))
                    {
                        product.PrintCheck = true;
                        product.PublicQty  = barCode.AdditionalStr;
                        break;
                    }
                    _productList.Add(product);
                }

                DisplayPartialPicture(
                    dgvProduct.DisplayedRowCount(true),
                    0,
                    0,
                    ScrollEventType.LargeIncrement);

                UpdateResultInfo();
                EnableActionButton();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #11
0
        private void CtrlCatalog_Load(object sender, EventArgs e)
        {
            try
            {
                if (_productService == null)
                {
                    _productService = ServiceFactory.GenerateServiceInstance().GenerateProductService();
                }

                if (_commonService == null)
                {
                    _commonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();
                }

                if (!UserService.AllowToPerform(Resources.PermissionViewAllProductInfo))
                {
                    UPInLbl.Visible            = false;
                    extraPercentageLbl.Visible = false;
                }
                if (!UserService.AllowToPerform(Resources.PermissionViewProdResultInfo))
                {
                    lblResultInfo.Visible = false;
                    //extraPercentageLbl.Visible = false;
                }
                InitializeProductList();

                ThreadStart threadStart = UpdateControlContent;
                var         thread      = new Thread(threadStart)
                {
                    IsBackground = true
                };
                thread.Start();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #12
0
        private void CmdSearchProductClick(object sender, EventArgs e)
        {
            try
            {
                var searchCriteria = new List <string>();
                if (cmbCategory.SelectedIndex != -1)
                {
                    searchCriteria.Add("CategoryId|" + cmbCategory.SelectedValue);
                }

                if (cmbMark.SelectedIndex != -1)
                {
                    searchCriteria.Add("MarkId|" + cmbMark.SelectedValue);
                }

                if (cmbColor.SelectedIndex != -1)
                {
                    searchCriteria.Add("ColorId|" + cmbColor.SelectedValue);
                }

                if (txtProductCode.Text.Length != 0)
                {
                    searchCriteria.Add(
                        "((ProductCode LIKE '%" + txtProductCode.Text + "%') OR " +
                        "(ForeignCode LIKE '%" + txtProductCode.Text + "%'))");
                }

                _productList.Clear();
                IListToBindingList(
                    _productService.GetCatalogs(searchCriteria, chbInstockOnly.Checked));
                SetFocusToProductList();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #13
0
        private void CtrBase_Load(object sender, EventArgs e)
        {
            try
            {
                if (_CommonService == null)
                {
                    _CommonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();
                }

                IList objectList = _CommonService.GetAppParameterTypes();
                lsbAppParam.DisplayMember = AppParameterType.ConstParameterLabel;
                lsbAppParam.ValueMember   = AppParameterType.ConstParameterId;
                lsbAppParam.DataSource    = objectList;

                _IsModified = false;
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError, exception.Message);
            }
        }
コード例 #14
0
ファイル: CtrlUser.cs プロジェクト: ViniciusConsultor/campos
        private void InitializeUserList()
        {
            try
            {
                if (_UserList == null)
                {
                    _UserList = new BindingList <User>();
                }

                dgvUser.DataSource = _UserList;
                dgvUser.Columns["UserName"].DisplayIndex    = 0;
                dgvUser.Columns["PhoneNumber"].DisplayIndex = 1;
                dgvUser.Columns["GenderStr"].DisplayIndex   = 2;
                dgvUser.Columns["PositionStr"].DisplayIndex = 3;
                dgvUser.Columns["LogInName"].DisplayIndex   = 4;
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #15
0
        private void InitializeExpenseList()
        {
            try
            {
                if (_ExpenseList == null)
                {
                    _ExpenseList = new BindingList <Expense>();
                }

                dgvExpense.DataSource = _ExpenseList;
                dgvExpense.Columns["ExpenseDate"].DisplayIndex       = 0;
                dgvExpense.Columns["ExpenseTypeStr"].DisplayIndex    = 1;
                dgvExpense.Columns["Description"].DisplayIndex       = 2;
                dgvExpense.Columns["ExpenseAmountInt"].DisplayIndex  = 3;
                dgvExpense.Columns["ExpenseAmountRiel"].DisplayIndex = 4;
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #16
0
        private void InitialSupplierList()
        {
            try
            {
                if (_SupplierList == null)
                {
                    _SupplierList = new BindingList <Supplier>();
                }

                dgvSupplier.DataSource = _SupplierList;

                dgvSupplier.Columns["SupplierName"].DisplayIndex = 0;
                dgvSupplier.Columns["PhoneNumber"].DisplayIndex  = 1;
                dgvSupplier.Columns["FaxNumber"].DisplayIndex    = 2;
                dgvSupplier.Columns["CountryStr"].DisplayIndex   = 3;
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #17
0
        private void CtrlExpense_Load(object sender, EventArgs e)
        {
            if (_CommonService == null)
            {
                _CommonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();
            }
            if (_ExpenseService == null)
            {
                _ExpenseService = ServiceFactory.GenerateServiceInstance().GenerateExpenseService();
            }

            try
            {
                if (!UserService.AllowToPerform(Resources.PermissionViewExpResultInfo))
                {
                    lblResultInfo.Visible = false;
                }

                InitializeExpenseList();

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

                IListToBindingList(_ExpenseService.GetExpenses());
                dgvExpense.Refresh();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #18
0
        private void InitialDiscountCardList()
        {
            try
            {
                if (_DiscountCardList == null)
                {
                    _DiscountCardList = new BindingList <object>();
                }

                dgvDiscountCard.DataSource = _DiscountCardList;

                dgvDiscountCard.Columns["PrintCheck"].DisplayIndex         = 0;
                dgvDiscountCard.Columns["CardNumber"].DisplayIndex         = 1;
                dgvDiscountCard.Columns["DiscountCardTypeId"].DisplayIndex = 2;
                dgvDiscountCard.Columns["DiscountPercentage"].DisplayIndex = 3;
                dgvDiscountCard.Columns["CustomerStr"].DisplayIndex        = 4;
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #19
0
        private void InitializeProductList()
        {
            try
            {
                if (_productList == null)
                {
                    _productList = new BindingList <Product>();
                }

                dgvProduct.DataSource = _productList;
                dgvProduct.Columns["PrintCheck"].DisplayIndex  = 0;
                dgvProduct.Columns["PublicQty"].DisplayIndex   = 1;
                dgvProduct.Columns["ProductPic"].DisplayIndex  = 2;
                dgvProduct.Columns["DisplayName"].DisplayIndex = 3;
                dgvProduct.Columns["Description"].DisplayIndex = 4;
                dgvProduct.Columns["QtyInStock"].DisplayIndex  = 5;
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #20
0
        private void DoPrintProduct()
        {
            try
            {
                if (!UserService.AllowToPerform(Resources.PermissionPrintProductCode))
                {
                    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;
                    }
                }

                //Generate product to print
                var selectedProductList = new BindingList <Product>();
                foreach (var product in
                         _productList.Where(product => product != null).Where(product => product.PrintCheck))
                {
                    selectedProductList.Add(product);
                }

                PrintProduct.InializePrinting(selectedProductList);
                SetFocusToProductList();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #21
0
 private void dgvAppParameter_DataError(object sender, DataGridViewDataErrorEventArgs e)
 {
     FrmExtendedMessageBox.UnknownErrorMessage(
         Resources.MsgCaptionUnknownError,
         e.Exception.Message);
 }
コード例 #22
0
        private void dgvAppParameter_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
        {
            if (!_IsModified)
            {
                return;
            }

            if (dgvAppParameter.Rows[e.RowIndex].Cells["ParameterLabel"].Value is DBNull)
            {
                e.Cancel = true;
            }

            if (e.Cancel)
            {
                return;
            }

            try
            {
                AppParameter appParameter;
                if (dgvAppParameter.Rows[e.RowIndex].Cells["ParameterId"].Value is DBNull)
                {
                    appParameter = new AppParameter();
                    _AppParamList.Add(appParameter);
                }
                else
                {
                    appParameter = _AppParamList[e.RowIndex] as AppParameter;
                }

                if (appParameter == null)
                {
                    e.Cancel = true;
                    return;
                }

                appParameter.ParameterLabel = dgvAppParameter.Rows[e.RowIndex].Cells["ParameterLabel"].Value.ToString();
                appParameter.ParameterValue = dgvAppParameter.Rows[e.RowIndex].Cells["ParameterValue"].Value.ToString();

                appParameter.ParameterCode   = dgvAppParameter.Rows[e.RowIndex].Cells["ParameterCode"].Value == null ? "" : dgvAppParameter.Rows[e.RowIndex].Cells["ParameterCode"].Value.ToString();
                appParameter.ParameterTypeId = Int32.Parse(LstProduct.SelectedValue.ToString(), AppContext.CultureInfo);

                SetModifyStatus(false);

                if (appParameter.ParameterId == 0)
                {
                    //appParameter.ParameterValue = _CommonService
                    //    .GenerateAppParamValue(cmbAppParamValue.Text);
                    //dgvAppParameter.Rows[e.RowIndex].Cells["ParameterValue"].Value = appParameter.ParameterValue;

                    AppParamManagement(appParameter,
                                       Resources.OperationRequestInsert);

                    _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;
                }
                else
                {
                    AppParamManagement(appParameter,
                                       Resources.OperationRequestUpdate);
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #23
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            if (cmbDiscountType.SelectedValue == null)
            {
                return;
            }

            if (txtNumCard.Text.Length == 0)
            {
                return;
            }

            try
            {
                if (!UserService.AllowToPerform(Resources.PermissionAddCard))
                {
                    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 discountCardTypeId  = Int32.Parse(cmbDiscountType.SelectedValue.ToString(), AppContext.CultureInfo);
                var discountCardTypeStr = ((AppParameter)cmbDiscountType.SelectedItem).ParameterLabel;
                var discountPercentage  =
                    float.Parse(((AppParameter)cmbDiscountType.SelectedItem).ParameterValue, AppContext.CultureInfo);

                var nbrDiscountCard = Int32.Parse(txtNumCard.Text, AppContext.CultureInfo);
                for (var counter = 0; counter < nbrDiscountCard; counter++)
                {
                    var discountCard = new DiscountCard
                    {
                        DiscountCardTypeId  = discountCardTypeId,
                        DiscountCardTypeStr = discountCardTypeStr,
                        DiscountPercentage  = discountPercentage,
                        ExpireDate          = DateTime.Now,
                        AllowDiscount       = 1
                    };
                    _CustomerService.DiscountCardManagement(
                        discountCard,
                        Resources.OperationRequestInsert);

                    _DiscountCardList.Add(discountCard);
                }
                dgvDiscountCard.Refresh();
                SetDiscountCardInfo();
                UpdateResultInfo();
                EnableActionButton();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #24
0
        private void DgvProductKeyDown(object sender, KeyEventArgs e)
        {
            if (e == null)
            {
                return;
            }

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

            try
            {
                if ((e.KeyCode == Keys.Add) || (e.KeyCode == Keys.Subtract))
                {
                    if (dgvProduct.CurrentRow == null)
                    {
                        return;
                    }

                    if (!_productList[dgvProduct.CurrentRow.Index].PrintCheck)
                    {
                        e.Handled = true;
                        return;
                    }
                }

                if (dgvProduct.CurrentRow != null)
                {
                    var tmpQty = dgvProduct.CurrentRow.Cells["PublicQty"].Value == null ? "0" : dgvProduct.CurrentRow.Cells["PublicQty"].Value.ToString();
                    if (String.IsNullOrEmpty(tmpQty))
                    {
                        return;
                    }

                    var printedQty = float.Parse(tmpQty.Split('/')[0]);
                    var totalQty   = _productList[dgvProduct.CurrentRow.Index].QtyInStock;
                    int selectedIndex;
                    switch (e.KeyCode)
                    {
                    case Keys.Add:
                        if (printedQty < totalQty)
                        {
                            DoPreBarCodePrinting(
                                printedQty,
                                1,
                                totalQty,
                                true,
                                false);
                        }
                        break;

                    //case Keys.A:
                    //    if (printedQty < totalQty)
                    //        DoPreBarCodePrinting(
                    //            printedQty,
                    //            1,
                    //            totalQty,
                    //            true,
                    //            false);
                    //    break;
                    case Keys.Subtract:
                        if (printedQty > 1)
                        {
                            DoPreBarCodePrinting(
                                printedQty,
                                1,
                                totalQty,
                                false,
                                false);
                        }
                        break;

                    //case Keys.B:
                    //    if (printedQty > 1)
                    //        DoPreBarCodePrinting(
                    //            printedQty,
                    //            1,
                    //            totalQty,
                    //            false,
                    //            false);
                    //    break;
                    case Keys.Up:
                        selectedIndex = dgvProduct.SelectedRows[0].Index;
                        if (selectedIndex > 0)
                        {
                            selectedIndex -= 1;
                            dgvProduct.Rows[selectedIndex].Selected = true;
                        }
                        break;

                    case Keys.Down:
                        selectedIndex = dgvProduct.SelectedRows[0].Index;
                        if (selectedIndex < (_productList.Count - 1))
                        {
                            selectedIndex += 1;
                            dgvProduct.Rows[selectedIndex].Selected = true;
                        }
                        break;

                    case Keys.Escape:
                        e.Handled = true;
                        break;
                    }
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #25
0
        private void CtrlDiscountCard_Load(object sender, EventArgs e)
        {
            if (_CommonService == null)
            {
                _CommonService = ServiceFactory.GenerateServiceInstance().GenerateCommonService();
            }
            if (_CustomerService == null)
            {
                _CustomerService = ServiceFactory.GenerateServiceInstance().GenerateCustomerService();
            }


            try
            {
                if (!UserService.AllowToPerform(Resources.PermissionViewCartResultInfo))
                {
                    lblResultInfo.Visible = false;
                }
                if (_CustomerService == null)
                {
                    _CustomerService = ServiceFactory.GenerateServiceInstance().GenerateCustomerService();
                }

                InitialDiscountCardList();

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

                var objList = _CustomerService.GetCustomers();
                cmbCustomer.CustomizedDataBinding(
                    objList,
                    Customer.ConstCustomerName,
                    Customer.ConstCustomerId,
                    false);

                var customerList = new List <Customer>();
                foreach (Customer customer in objList)
                {
                    customerList.Add(customer);
                }

                cmbCustomerHidden.CustomizedDataBinding(
                    customerList,
                    Customer.ConstCustomerName,
                    Customer.ConstCustomerId,
                    false);

                btnSearch_Click(sender, e);
                //IListToBindingList(
                //    _CustomerService.GetDiscountCards());
                //dgvDiscountCard.Refresh();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #26
0
        private void UpdateSelectedProduct(Product curProduct, float preQtyInStock)
        {
            if (curProduct == null)
            {
                throw new ArgumentNullException("curProduct", Resources.MsgInvalidProduct);
            }

            try
            {
                bool isIncremented;
                if ((curProduct.QtyInStock - preQtyInStock) < 0)
                {
                    isIncremented = false;
                    for (var counter = 0; counter < _barCodeList.Count; counter++)
                    {
                        if (curProduct.ProductCode != _barCodeList[counter].BarCodeValue)
                        {
                            continue;
                        }

                        if (_barCodeList.Count >= preQtyInStock)
                        {
                            _barCodeList.RemoveAt(counter);
                        }

                        counter       -= 1;
                        preQtyInStock -= 1;
                        if ((curProduct.QtyInStock - preQtyInStock) == 0)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    isIncremented = true;
                    if (String.IsNullOrEmpty(curProduct.PublicQty))
                    {
                        return;
                    }

                    for (var counter = 0; counter < (curProduct.QtyInStock - preQtyInStock); counter++)
                    {
                        var barCode =
                            new BarCode
                        {
                            BarCodeValue = curProduct.ProductCode,
                            DisplayStr   = curProduct.CategoryStr,
                            UnitPrice    = "$ " + curProduct.UnitPriceOut.ToString("N", AppContext.CultureInfo)
                        };

                        if (string.IsNullOrEmpty(curProduct.ForeignCode))
                        {
                            barCode.DisplayStr += " (" + curProduct.ForeignCode + ")";
                        }
                        _barCodeList.Add(barCode);
                    }
                }

                if (!String.IsNullOrEmpty(curProduct.PublicQty))
                {
                    var tmpQty     = curProduct.PublicQty;
                    var printedQty = float.Parse(tmpQty.Split('/')[0]);

                    if (isIncremented)
                    {
                        printedQty += (curProduct.QtyInStock - preQtyInStock);
                    }
                    else
                    {
                        if (printedQty > _barCodeList.Count)
                        {
                            printedQty = _barCodeList.Count;
                        }
                    }

                    curProduct.PublicQty =
                        printedQty + " / " + curProduct.QtyInStock;
                }

                rdbPrintSelected.Text = string.Format(
                    "{0}{1}{2}",
                    "កូដជ្រើសរើស (",
                    _barCodeList.Count.ToString("N0", AppContext.CultureInfo),
                    ")");
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #27
0
 private void DgvCustomerDataError(object sender, DataGridViewDataErrorEventArgs e)
 {
     FrmExtendedMessageBox.UnknownErrorMessage(
         Resources.MsgCaptionUnknownError,
         e.Exception.Message);
 }
コード例 #28
0
        private void BtnPrintClick(object sender, EventArgs e)
        {
            try
            {
                if (!UserService.AllowToPerform(Resources.PermissionPrintProductCode))
                {
                    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;
                    }
                }

                if (rdbProduct.Checked)
                {
                    DoPrintProduct();
                    return;
                }

                if (rdbPrintAll.Checked)
                {
                    _barCodeList.Clear();
                    foreach (var t in _productList)
                    {
                        var product = t;
                        if (product == null)
                        {
                            continue;
                        }

                        for (var qtyCounter = 0; qtyCounter < product.QtyInStock; qtyCounter++)
                        {
                            //var product = _ProductList[counter];
                            var barCode =
                                new BarCode
                            {
                                BarCodeValue  = product.ProductCode,
                                DisplayStr    = product.CategoryStr,
                                AdditionalStr = (product.QtyInStock.ToString("N0") + " / " + product.QtyInStock.ToString("N0")),
                                UnitPrice     = "$ " + (t).UnitPriceOut.ToString("N", AppContext.CultureInfo),
                                Description   = product.ProductName + @" \ " + product.SizeStr
                            };

                            var foreignCode = product.ForeignCode;
                            if (!string.IsNullOrEmpty(foreignCode))
                            {
                                barCode.DisplayStr += " (" + foreignCode + ")";
                            }
                            _barCodeList.Add(barCode);
                        }

                        (t).PrintCheck = true;
                        (t).PublicQty  =
                            (t).QtyInStock +
                            " / " +
                            (t).QtyInStock;
                    }
                    dgvProduct.Refresh();
                }

                var barCodeTemplate = AppContext.BarCodeTemplate;

                //var barCodePrintingTypeList =
                //    _CommonService.GetAppParametersByType(
                //        Int32.Parse(Resources.AppParamBarcodePrintingType, AppContext.CultureInfo));

                //var barCodePrintingType = string.Empty;
                //if (barCodePrintingTypeList != null)
                //{
                //    if(barCodePrintingTypeList.Count != 0)
                //    {
                //        var appParameter = (AppParameter) barCodePrintingTypeList[0];
                //        if (appParameter != null)
                //            barCodePrintingType = appParameter.ParameterValue;
                //    }
                //}

                if (string.IsNullOrEmpty(barCodeTemplate))
                {
                    barCodeTemplate = Resources.ConstBarCodeTemplate1;
                }

                if (!Resources.ConstBarCodeTemplate6.Equals(barCodeTemplate))
                {
                    PrintBarCode.InializePrinting(_barCodeList, barCodeTemplate);
                }
                else
                {
                    var fileName     = Resources.ConstBarcodeExcelFile;
                    var printBarCode = new PrintBarCode();
                    printBarCode.PrintBarcodeHandler(
                        Application.StartupPath + @"\" + fileName,
                        string.Empty,
                        _barCodeList);
                }

                SetFocusToProductList();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #29
0
        private void ProductManagement(IEquatable <string> operationRequest)
        {
            try
            {
                if ((dgvProduct.CurrentRow == null) && (!operationRequest.Equals(Resources.OperationRequestInsert)))
                {
                    return;
                }

                using (var frmCatalog = new FrmCatalog())
                {
                    float preQtyInStock = 0;
                    if (_productList.Count != 0)
                    {
                        preQtyInStock = (_productList[dgvProduct.CurrentRow.Index]).QtyInStock;
                    }
                    if (operationRequest.Equals(Resources.OperationRequestUpdate))
                    {
                        frmCatalog.Product = _productList[dgvProduct.CurrentRow.Index];
                    }

                    if (frmCatalog.ShowDialog(this) == DialogResult.OK)
                    {
                        try
                        {
                            if (frmCatalog.Product == null)
                            {
                                IListToBindingList(
                                    _productService.GetCatalogs(chbInstockOnly.Checked));
                            }
                            else
                            {
                                if (operationRequest.Equals(Resources.OperationRequestUpdate))
                                {
                                    UpdateSelectedProduct(
                                        frmCatalog.Product,
                                        preQtyInStock);

                                    if (frmCatalog.Product.QtyInStock == 0)
                                    {
                                        for (var counter = 0; counter < _productList.Count; counter++)
                                        {
                                            if (_productList[counter].ProductId == frmCatalog.Product.ProductId)
                                            {
                                                _productList.RemoveAt(counter);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    if (frmCatalog.Product.QtyInStock == 0)
                                    {
                                        _productList.Add(frmCatalog.Product);
                                    }
                                }
                            }
                            dgvProduct.Refresh();
                            SetProductInfo();

                            UpdateResultInfo();
                            EnableActionButton();
                        }
                        catch (Exception exception)
                        {
                            FrmExtendedMessageBox.UnknownErrorMessage(
                                Resources.MsgCaptionUnknownError,
                                exception.Message);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
コード例 #30
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);
            }
        }