コード例 #1
0
        public FrmCustomer(ApplicationPresenter ap, BOCustomer model)
            : base(ap)
        {
            InitializeComponent();

            mModel     = model;
            mViewModel = new BOViewModel(mModel);
            mViewModel.ErrorProvider = errorProvider;

            BindViews();
            RegisterEventHandlers();
        }
コード例 #2
0
        public bool IsEmail(BOCustomer Customer)
        {
            string MatchEmailPattern = @"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@" + @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\." + @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|" + @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$";

            if (Customer.CustomerEmail != null)
            {
                return(Regex.IsMatch(Customer.CustomerEmail, MatchEmailPattern));
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        public void MapBOToModelList()
        {
            var        mapper = new BOLCustomerMapper();
            BOCustomer bo     = new BOCustomer();

            bo.SetProperties(1, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), 1, 1);
            List <ApiCustomerResponseModel> response = mapper.MapBOToModel(new List <BOCustomer>()
            {
                { bo }
            });

            response.Count.Should().Be(1);
        }
コード例 #4
0
        public void MapModelToBO()
        {
            var mapper = new BOLCustomerMapper();
            ApiCustomerRequestModel model = new ApiCustomerRequestModel();

            model.SetProperties("A", "A", "A", "A");
            BOCustomer response = mapper.MapModelToBO(1, model);

            response.Email.Should().Be("A");
            response.FirstName.Should().Be("A");
            response.LastName.Should().Be("A");
            response.Phone.Should().Be("A");
        }
コード例 #5
0
        public void MapBOToModelList()
        {
            var        mapper = new BOLCustomerMapper();
            BOCustomer bo     = new BOCustomer();

            bo.SetProperties(1, "A", "A", "A", "A");
            List <ApiCustomerResponseModel> response = mapper.MapBOToModel(new List <BOCustomer>()
            {
                { bo }
            });

            response.Count.Should().Be(1);
        }
コード例 #6
0
        public void MapBOToModel()
        {
            var        mapper = new BOLCustomerMapper();
            BOCustomer bo     = new BOCustomer();

            bo.SetProperties(1, "A", "A", "A", "A");
            ApiCustomerResponseModel response = mapper.MapBOToModel(bo);

            response.Email.Should().Be("A");
            response.FirstName.Should().Be("A");
            response.Id.Should().Be(1);
            response.LastName.Should().Be("A");
            response.Phone.Should().Be("A");
        }
コード例 #7
0
 public Task <bool> CustomerExists(BOCustomer customer)
 {
     using (var content = new CustomerContext())
     {
         return(content.Customers.AnyAsync(x =>
                                           x.Name == customer.Name &&
                                           x.FirstName == customer.FirstName &&
                                           x.DeliveryAddress.City == customer.DeliveryAddress.City &&
                                           x.DeliveryAddress.ZipCode == customer.DeliveryAddress.ZipCode &&
                                           x.DeliveryAddress.Street == customer.DeliveryAddress.Street &&
                                           x.DeliveryAddress.Number == customer.DeliveryAddress.Number
                                           ));
     }
 }
コード例 #8
0
        public void MapModelToBO()
        {
            var mapper = new BOLCustomerMapper();
            ApiCustomerRequestModel model = new ApiCustomerRequestModel();

            model.SetProperties("A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), 1, 1);
            BOCustomer response = mapper.MapModelToBO(1, model);

            response.AccountNumber.Should().Be("A");
            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.PersonID.Should().Be(1);
            response.Rowguid.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.StoreID.Should().Be(1);
            response.TerritoryID.Should().Be(1);
        }
コード例 #9
0
        public void MapEFToBO()
        {
            var      mapper = new DALCustomerMapper();
            Customer entity = new Customer();

            entity.SetProperties("A", "A", 1, "A", "A");

            BOCustomer response = mapper.MapEFToBO(entity);

            response.Email.Should().Be("A");
            response.FirstName.Should().Be("A");
            response.Id.Should().Be(1);
            response.LastName.Should().Be("A");
            response.Phone.Should().Be("A");
        }
コード例 #10
0
        public void MapBOToEF()
        {
            var mapper = new DALCustomerMapper();
            var bo     = new BOCustomer();

            bo.SetProperties(1, "A", "A", "A", "A");

            Customer response = mapper.MapBOToEF(bo);

            response.Email.Should().Be("A");
            response.FirstName.Should().Be("A");
            response.Id.Should().Be(1);
            response.LastName.Should().Be("A");
            response.Phone.Should().Be("A");
        }
コード例 #11
0
        private void dataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            try
            {
                DataGridViewRow row = dataGridView1.SelectedRows[0];
                this.Hide();
                frmInvoice frm = new frmInvoice();
                frm.Show();

                frm.txtInvoiceNo.Text    = row.Cells[0].Value.ToString();
                frm.dtpInvoiceDate.Text  = row.Cells[1].Value.ToString();
                frm.txtCustID.Text       = row.Cells[2].Value.ToString();
                frm.txtCustName.Text     = row.Cells[3].Value.ToString();
                frm.txtSubTotal.Text     = row.Cells[4].Value.ToString();
                frm.txtVAT.Text          = row.Cells[5].Value.ToString();
                frm.txtVatAmount.Text    = row.Cells[6].Value.ToString();
                frm.txtGrandTotal.Text   = row.Cells[7].Value.ToString();
                frm.txtTotalPayment.Text = row.Cells[8].Value.ToString();
                frm.txtPaymentDue.Text   = row.Cells[9].Value.ToString();
                frm.txtRemarks.Text      = row.Cells[10].Value.ToString();
                frm.btnUpdate.Enabled    = true;
                frm.btnDelete.Enabled    = true;
                frm.btnPrint.Enabled     = true;
                frm.btnSave.Enabled      = false;

                BOCustomer      BO = new BOCustomer();
                BusinessManager BM = new BusinessManager();
                BO.InvoiceNo = frm.txtInvoiceNo.Text.Trim();
                DataTable dt = BM.BALSalesRecordFillList(BO);
                foreach (DataRow drow in dt.Rows)
                {
                    //cmbCustomerName.Items.Add(drow[0].ToString());
                    ListViewItem lst = new ListViewItem();
                    lst.SubItems.Add(drow[0].ToString().Trim());
                    lst.SubItems.Add(drow[1].ToString().Trim());
                    lst.SubItems.Add(drow[2].ToString().Trim());
                    lst.SubItems.Add(drow[3].ToString().Trim());
                    lst.SubItems.Add(drow[4].ToString().Trim());
                    frm.listView1.Items.Add(lst);
                }
                frm.listView1.Enabled  = false;
                frm.btnAddCart.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #12
0
        public void MapBOToModel()
        {
            var        mapper = new BOLCustomerMapper();
            BOCustomer bo     = new BOCustomer();

            bo.SetProperties(1, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), 1, 1);
            ApiCustomerResponseModel response = mapper.MapBOToModel(bo);

            response.AccountNumber.Should().Be("A");
            response.CustomerID.Should().Be(1);
            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.PersonID.Should().Be(1);
            response.Rowguid.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.StoreID.Should().Be(1);
            response.TerritoryID.Should().Be(1);
        }
コード例 #13
0
        public void MapEFToBO()
        {
            var      mapper = new DALCustomerMapper();
            Customer entity = new Customer();

            entity.SetProperties("A", 1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), 1, 1);

            BOCustomer response = mapper.MapEFToBO(entity);

            response.AccountNumber.Should().Be("A");
            response.CustomerID.Should().Be(1);
            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.PersonID.Should().Be(1);
            response.Rowguid.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.StoreID.Should().Be(1);
            response.TerritoryID.Should().Be(1);
        }
コード例 #14
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                try
                {
                    auto_generate_id();
                    BusinessManager BM = new BusinessManager();
                    BOCustomer      BO = new BOCustomer();
                    BO.CustomerID         = txtCustomerID.Text.Trim();
                    BO.CustomerName       = txtCustomerName.Text.Trim();
                    BO.CustomerAddress    = txtAddress.Text.Trim();
                    BO.CustomerPlace      = txtPlace.Text.Trim();
                    BO.CustomerCity       = txtCity.Text.Trim();
                    BO.CustomerZone       = cmbZone.Text.Trim();
                    BO.CustomerPostalCode = txtPostalCode.Text.Trim();
                    BO.CustomerPhone      = txtPhone.Text.Trim();
                    BO.CustomerMobile     = txtMobile.Text.Trim();
                    BO.CustomerFax        = txtFax.Text.Trim();
                    BO.CustomerEmail      = txtEmail.Text.Trim();
                    BO.CustomerNotes      = txtNote.Text.Trim();

                    bool res          = BM.BALVerifyCustomerName(BO);
                    int  rowsAffected = 0;
                    if (res == true)
                    {
                        MessageBox.Show("Customer ID already exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        New();
                    }
                    else
                    {
                        rowsAffected = BM.BALInsertIntoCustomer(BO);
                        if (rowsAffected > 0)
                        {
                            MessageBox.Show("Successfully saved", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            btnSave.Enabled = false;
                            New();
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #15
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                try
                {
                    BusinessManager BM = new BusinessManager();
                    BOCustomer      BO = new BOCustomer();
                    BO.CustomerID         = txtCustomerID.Text.Trim();
                    BO.CustomerName       = txtCustomerName.Text.Trim();
                    BO.CustomerAddress    = txtAddress.Text.Trim();
                    BO.CustomerPlace      = txtPlace.Text.Trim();
                    BO.CustomerCity       = txtCity.Text.Trim();
                    BO.CustomerZone       = cmbZone.Text.Trim();
                    BO.CustomerPostalCode = txtPostalCode.Text.Trim();
                    BO.CustomerPhone      = txtPhone.Text.Trim();
                    BO.CustomerMobile     = txtMobile.Text.Trim();
                    BO.CustomerFax        = txtFax.Text.Trim();
                    BO.CustomerEmail      = txtEmail.Text.Trim();
                    BO.CustomerNotes      = txtNote.Text.Trim();
                    int rowsAffected = BM.BALUpdateCustomer(BO);

                    if (rowsAffected > 0)
                    {
                        MessageBox.Show("Successfully updated!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        btnRegister.Enabled = false;
                        New();
                    }
                    else
                    {
                        MessageBox.Show("Couldn't be updated!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        btnRegister.Enabled = false;
                        New();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #16
0
        public async Task OnMessageRequest(ProcessRequest processRequest)
        {
            var msg = (Contracts.Customer.Registration)processRequest.Message;

            Message result = null;

            var mappedRegistation = new BOCustomer();

            var denial = Denial.Create("Kunde kenn ich schon :-(", processRequest.MessageId);

            await StartProcess("MessageDispatcher", denial, processRequest.SenderId).ConfigureAwait(false);

            //if (await _customerRepository.CustomerExists(mappedRegistation))
            //{
            //    result = Denial.Create("Der Kunden ist bereits vorhanden", msg.Id);
            //}
            //else
            //{
            //    result = Confirmation.Create(msg.Id);
            //}
            //await StartProcess("MessageDispatcher", result, processRequest.SenderId);
        }
コード例 #17
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                try
                {
                    if (txtCustID.Text == "")
                    {
                        MessageBox.Show("Please retrieve Customer ID", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtCustID.Focus();
                        return;
                    }

                    if (txtVAT.Text == "")
                    {
                        MessageBox.Show("Please enter VAT percentage", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtVAT.Focus();
                        return;
                    }

                    if (txtTotalPayment.Text == "")
                    {
                        MessageBox.Show("Please enter total payment", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtTotalPayment.Focus();
                        return;
                    }
                    if (listView1.Items.Count == 0)
                    {
                        MessageBox.Show("Sorry no product added", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    auto_generate_id();
                    BusinessManager BM  = new BusinessManager();
                    BOSales         BOS = new BOSales();
                    BOCustomer      BOC = new BOCustomer();
                    BOProduct       BOP = new BOProduct();
                    BOInventory     BOI = new BOInventory();
                    BOS.InvoiceNo    = txtInvoiceNo.Text;
                    BOS.InvoiceDate  = dtpInvoiceDate.Text;
                    BOC.CustomerID   = txtCustID.Text;
                    BOS.SubTotal     = txtSubTotal.Text;
                    BOS.VATPercent   = txtVAT.Text;
                    BOS.VATAmount    = txtVatAmount.Text;
                    BOS.GrandTotal   = txtGrandTotal.Text;
                    BOS.TotalPayment = txtTotalPayment.Text;
                    BOS.PaymentDue   = txtPaymentDue.Text;
                    BOS.Remarks      = txtRemarks.Text;

                    bool res = BM.BALVerifyInvoiceNumber(BOS);

                    if (res == true)
                    {
                        MessageBox.Show("Invoice No. already exists", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        BM.BALInsertIntoSales(BOS, BOC);
                    }

                    for (int i = 0; i <= listView1.Items.Count - 1; i++)
                    {
                        BOS.InvoiceNo       = txtInvoiceNo.Text;
                        BOP.ConfigID        = listView1.Items[i].SubItems[1].Text;
                        BOP.ProductQuantity = listView1.Items[i].SubItems[4].Text;
                        BOP.Price           = listView1.Items[i].SubItems[3].Text;
                        BOP.TotalAmount     = listView1.Items[i].SubItems[5].Text;
                        BM.BALInsertIntoProductSold(BOS, BOP);
                    }

                    for (int i = 0; i <= listView1.Items.Count - 1; i++)
                    {
                        BOI.Quantity = listView1.Items[i].SubItems[4].Text;
                        BOP.ConfigID = listView1.Items[i].SubItems[1].Text;
                        BM.BALUpdateInventoryQuantity(BOI, BOP);
                    }

                    for (int i = 0; i <= listView1.Items.Count - 1; i++)
                    {
                        BOI.TotalPrice = listView1.Items[i].SubItems[5].Text;
                        BOP.ConfigID   = listView1.Items[i].SubItems[1].Text;
                        BM.BALUpdateInventoryTotalPrice(BOI, BOP);
                    }

                    btnSave.Enabled          = false;
                    btnPrint.Enabled         = true;
                    dataGridView1.DataSource = BM.BALGetInvoiceData();
                    MessageBox.Show("Successfully saved", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #18
0
        public int BALInsertIntoCustomer(BOCustomer Customer)
        {
            DBManager DALObject = new DBManager();

            return(DALObject.InsertIntoCustomer(Customer));
        }
コード例 #19
0
        public int BALUpdateCustomer(BOCustomer Customer)
        {
            DBManager DALObject = new DBManager();

            return(DALObject.UpdateCustomer(Customer));
        }
コード例 #20
0
        public DataSet BALSalesRecordCombo(BOCustomer Customer)
        {
            DBManager DALObject = new DBManager();

            return(DALObject.SalesRecordCombo(Customer));
        }
コード例 #21
0
        public DataTable BALSalesRecordFillList(BOCustomer Customer)
        {
            DBManager DALObject = new DBManager();

            return(DALObject.SalesRecordFillList(Customer));
        }
コード例 #22
0
        public int BALDeleteFromCustomer(BOCustomer Customer)
        {
            DBManager DALObject = new DBManager();

            return(DALObject.DeleteFromCustomer(Customer));
        }
コード例 #23
0
        public void BALInsertIntoSales(BOSales Sales, BOCustomer Customer)
        {
            DBManager DALObject = new DBManager();

            DALObject.InsertIntoSales(Sales, Customer);
        }
コード例 #24
0
        public DataSet BALSalesReportByCustomer(BOCustomer Customer)
        {
            DBManager DALObject = new DBManager();

            return(DALObject.SalesReportByCustomer(Customer));
        }
コード例 #25
0
        public bool BALVerifyCustomerName(BOCustomer Customer)
        {
            DBManager DALObject = new DBManager();

            return(DALObject.VerifyCustomerName(Customer));
        }