コード例 #1
0
        public CustomerBillDto GetCustomerByPhoneNumber(String phoneNumber)
        {
            CustomerBillDto dto = null;

            String message = this.validatePhoneNumber(phoneNumber);

            if (!"".Equals(message))
            {
                dto = new CustomerBillDto(message);
                return(dto);
            }

            Customer customer = this.customerRepository.GetByPhone(phoneNumber, true);

            if (customer == null)
            {
                dto = new CustomerBillDto(MessageContent.GET_CUSTOMER_ERROR + "\r\n" + MessageContent.REQUIRE_REINPUT_FIELD);
                return(dto);
            }


            dto         = Mapping.mapperCustomerBill.Map <CustomerBillDto>(customer);
            dto.Message = "";
            return(dto);
        }
コード例 #2
0
        public string SubmitBill(List <ProductBillDto> productBillDtos, CustomerBillDto customerBillDto, string total, bool delayBill = false)
        {
            string result = "";

            if (!delayBill)
            {
                result += this.updateCustomerInfo(customerBillDto);

                result += this.updateProductDetail(productBillDtos);

                result += this.addBill(productBillDtos, customerBillDto, total);
            }
            else
            {
                result += this.addBill(productBillDtos, customerBillDto, total, true);
            }

            return(result);
        }
コード例 #3
0
        // Lấy thông tin [Khách hàng]
        private void setCustomerInfo()
        {
            string phoneNumber = this.txtPhoneNumber.Text;

            if ("".Equals(phoneNumber.Trim()))
            {
                return;
            }

            this.customerBillDto = this.xuLyHoaDonService.GetCustomerByPhoneNumber(phoneNumber);

            if (!"".Equals(this.customerBillDto.Message.Trim()))
            {
                MessageBox.Show(this.customerBillDto.Message, MessageTitle.GET_CUSTOMER_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.customerBillDto = null;
                return;
            }

            this.txtCustomerName.Text = this.customerBillDto.FullName;
            this.txtProductCode.Focus();
            this.setSellProgramForCombobox();
        }
コード例 #4
0
        private string updateCustomerInfo(CustomerBillDto customerBillDto)
        {
            string result = "";

            if (customerBillDto != null)
            {
                Customer customer = this.customerRepository.GetByPhone(customerBillDto.PhoneNumer, true);

                if (customer == null)
                {
                    result += MessageContent.GET_CUSTOMER_ERROR + MessageContent.BREAK_LINE;
                }

                customer.Point = Convert.ToInt32(customerBillDto.Point);

                if (customer.Point >= 20000 && customer.Point < 40000)
                {
                    customer.CusTypeId = 3;
                }
                else if (customer.Point >= 40000 && customer.Point < 40000)
                {
                    customer.CusTypeId = 4;
                }

                try
                {
                    this.customerRepository.Update(customer);
                }
                catch
                {
                    result += String.Format(MessageContent.UPDATE_CUSTOMER_INFO_ERROR, customerBillDto.FullName) + MessageContent.BREAK_LINE;
                }
            }

            return(result);
        }
コード例 #5
0
        // Cập nhật lại Form
        private void resetForm()
        {
            this.txtDate.Text         = DateTime.UtcNow.ToString("dd/MM/yyyy");
            this.txtPhoneNumber.Text  = "";
            this.txtCustomerName.Text = "";
            this.txtProductCode.Text  = "";
            this.txtQuantity.Text     = "1";
            this.txtProductName.Text  = "";
            this.txtSell.Text         = "";
            this.txtPrice.Text        = "";
            this.lbTotal.Text         = "0";

            this.flagEnterPhoneNumberField = false;
            this.flagEnterProductCodeField = false;
            this.FlagDelay = false;

            this.productBillDto     = null;
            this.customerBillDto    = null;
            this.editBillDetailForm = null;
            this.delayBillForm      = null;
            this.productBillDtos    = new List <ProductBillDto>();
            this.saleBillDtos       = new List <SaleBillDto>();

            this.setSellProgramForCombobox();
            this.dgvListProduct.Rows.Clear();

            try
            {
                this.txtBillCode.Text = this.xuLyHoaDonService.GenerateBillCode();
            }
            catch
            {
                MessageBox.Show(MessageContent.SYSTEM_ERROR, MessageTitle.SYSTEM_ERROR,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #6
0
 public void ExportPdf(System.Collections.Generic.List <ProductBillDto> productBillDtos, CustomerBillDto customerBillDto)
 {
 }
コード例 #7
0
        private string addBill(List <ProductBillDto> productBillDtos, CustomerBillDto customerBillDto, string total, bool delayBill = false)
        {
            string result = "";

            string billCode = "";

            try
            {
                billCode = this.GenerateBillCode();
            }
            catch
            {
                result += MessageContent.SYSTEM_ERROR + MessageContent.BREAK_LINE;
            }

            Bill bill = new Bill();

            bill.BillId     = Convert.ToInt32(billCode);
            bill.CreateDate = DateTime.Now;
            bill.Total      = Convert.ToInt32(Regex.Replace(total, "[^.0-9]", ""));



            bill.BillDetails = new List <BillDetail>();

            if (customerBillDto != null)
            {
                Customer customer = this.customerRepository.GetById(Convert.ToInt32(customerBillDto.Id));
                bill.Customer   = customer;
                bill.CustomerId = Convert.ToInt32(customerBillDto.Id);
            }
            else
            {
                Customer customer = this.customerRepository.GetById(5);
                bill.CustomerId = 5;
                bill.Customer   = customer;
            }

            if (delayBill)
            {
                bill.Status = false;
            }
            else
            {
                bill.Status = true;
            }

            try
            {
                Bill bill1 = this.billRepository.GetById(bill.BillId);
                if (bill1 != null)
                {
                    bill1.Status = true;
                    this.billRepository.Update(bill1);
                    return("");
                }
            }
            catch
            {
            }



            this.billRepository.Add(bill);

            foreach (ProductBillDto dto in productBillDtos)
            {
                BillDetail billDetail = new BillDetail();
                billDetail.Quantity = Convert.ToInt32(dto.Quantity);

                billDetail.ProductDetailId = Convert.ToInt32(dto.DetailId);
                billDetail.BillId          = Convert.ToInt32(bill.BillId);

                this.billDetailRepository.Add(billDetail);
            }



            return(result);
        }