示例#1
0
        private void SetCustomerInfo(Customer customer)
        {
            var strCustomerInfo = customer.CustomerName;
            if (customer.FkDiscountCard == null)
            {
                var dCardList = _customerService.GetDiscountCardsByCustomer(customer.CustomerId);
                if (dCardList != null)
                {
                    if (dCardList.Count != 0)
                        customer.FkDiscountCard = dCardList[0] as DiscountCard;
                    else
                        customer.FkDiscountCard = new DiscountCard();
                }

                if (customer.FkDiscountCard != null)
                {
                    customer.FkDiscountCard.DiscountPercentage = customer.DiscountPercentage;
                    customer.DiscountCardNumber = customer.FkDiscountCard.CardNumber;
                    customer.DiscountCardType = customer.FkDiscountCard.DiscountCardTypeStr;
                }
            }

            if (customer.FkDiscountCard != null)
                strCustomerInfo += "\n" +
                                   customer.FkDiscountCard.CardNumber + "\n" +
                                   customer.FkDiscountCard.DiscountPercentage.ToString("N0", AppContext.CultureInfo) +
                                   " %";

            lblCustomer.Text = strCustomerInfo;
        }
示例#2
0
        private void InvoicePrinting(
            Customer customer,
            string invoiceNumber,
            DateTime invoiceDate,
            float discountPercentage,
            float depositAmount,
            float paidAmount,
            float returnAmount,
            bool isDeposit)
        {
            bool issueReceipt;
            var issueReceiptStr = AppContext.IssueReceipt;
            bool.TryParse(issueReceiptStr, out issueReceipt);
            if(!issueReceipt)
                return;

            var receiptTemplate = AppContext.ReceiptTemplate;
            if (string.IsNullOrEmpty(receiptTemplate))
                receiptTemplate = Resources.ConstReceiptTemplate1;

            if (receiptTemplate.Equals(Resources.ConstReceiptTemplate1))
            {
                //Print
                double amountSold = paidAmount - returnAmount;
                //amountSold = amountSold/(1 - discountPercentage/100);

                var printReceipt = new PrintReceipt
                {
                    InvoiceNumber = invoiceNumber,
                    Cashier = AppContext.User.LogInName,
                    PrintDate = DateTime.Now.ToString("dd/MM/yyyy HH:mm", AppContext.CultureInfo),
                    Counter = AppContext.Counter.CounterName,
                    CustomerInfo =
                        ((string.IsNullOrEmpty(customer.CustomerName)
                              ? string.Empty
                              : customer.CustomerName) +
                         (string.IsNullOrEmpty(customer.PhoneNumber)
                              ? string.Empty
                              : " | " + customer.PhoneNumber)),
                    AmountSold =
                        amountSold.ToString("N", AppContext.CultureInfo),
                    AmountPaid =
                        (paidAmount).ToString("N",
                                                           AppContext.
                                                               CultureInfo),
                    AmountReturn = returnAmount.ToString("N", AppContext.CultureInfo),
                    Discount = (discountPercentage + " %"),
                    //AmountSubTotal =
                    //    ((saleOrder.AmountSoldInt * 100) / (100 - discountPercentage)).ToString("N",
                    //                                                                        AppContext
                    //                                                                            .
                    //                                                                            CultureInfo),
                    AmountSubTotal =
                        (((paidAmount - returnAmount) * 100) / (100 - discountPercentage)).ToString("N",
                                                                                            AppContext
                                                                                                .
                                                                                                CultureInfo),
                    BindingListObj = _saleItemBindingList
                };

                printReceipt.InializeReceiptPrinting();
                //var fileName = Resources.ConstReceiptExcelFile;
                //printReceipt.PrintReceiptHandler(
                //    Application.StartupPath + @"\" + fileName,
                //    string.Empty);
            }
            else
            {
                var fileName = isDeposit ? Resources.ConstDepositExcelFile : Resources.ConstSaleExcelFile;

                //Print
                var printInvoice = new PrintInvoice();
                printInvoice.ExcelInvoicePrintingHandler(
                    AppContext.Counter.ReceiptPrinter,
                    Application.StartupPath + @"\" + fileName,
                    string.Empty,
                    customer.CustomerName,
                    customer.Address,
                    invoiceNumber,
                    invoiceDate,
                    discountPercentage,
                    depositAmount,
                    paidAmount,
                    _saleItemBindingList,
                    isDeposit);
            }
        }
示例#3
0
        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;
            }
        }
示例#4
0
        private void BtnSaveClick(object sender, EventArgs e)
        {
            try
            {
                if ((cmbGender.SelectedIndex == -1) || (String.IsNullOrEmpty(txtCustomerName.Text)))
                {
                    const string briefMsg = "អំពីពត៌មាន";
                    var detailMsg = Resources.MsgInvalidData;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr = briefMsg;
                        frmMessageBox.DetailMsgStr = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }

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

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

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

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

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

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

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

                if (isAllowed)
                {
                    var discountCard = (DiscountCard) lsbDiscountCard.SelectedItem;
                    discountCard.CustomerId = _Customer.CustomerId;
                    _CustomerService.DiscountCardManagement(
                        discountCard,
                        Resources.OperationRequestUpdate);
                }
                DialogResult = DialogResult.OK;
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
示例#5
0
        private void DiscountCardDistribution(
            Customer customer,
            string currentCardType,
            string nextCardType)
        {
            if (customer == null)
                return;

            if (customer.DiscountRejected == 1)
                return;

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

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

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

                Visible = false;
                using (var frmCustomer = new FrmCustomer())
                {
                    frmCustomer.Customer = customer;
                    if (frmCustomer.ShowDialog(this) == DialogResult.OK)
                        Customer = frmCustomer.Customer;
                    Visible = true;
                }
            }
        }