protected void btnSave_Click(object sender, EventArgs e)
 {
     int id = Utils.CIntDef(Request.QueryString["id"], 0);
     _CustomerRepo = new CustomerRepo();
     Customer item = _CustomerRepo.GetById(id);
     if (item != null)
     {
         item.Fullname = txtTen.Value;
         item.Address = txtDiachi.Value;
         item.Appcode = lbAppcode.Text;
         item.Appnumber = Utils.CIntDef(txtSoluong.Value, 0);
         item.IsActive = (ddlKichhoat.SelectedItem.Value == "1") ? true : false;
         _CustomerRepo.Update(item);
     }
     else
     {
         item = new Customer();
         item.Fullname = txtTen.Value;
         item.Address = txtDiachi.Value;
         string appcode = CreateAppcode();
         item.Appcode = appcode; 
         item.Appnumber = Utils.CIntDef(txtSoluong.Value, 0);
         item.IsActive = (ddlKichhoat.SelectedItem.Value == "1") ? true : false;
         item.CreatedDate = DateTime.Now;
         _CustomerRepo.Create(item);
     }
     Response.Redirect("~/pages/customers.aspx");
 }
        private void button4_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(FirstNameTextbox.Text) || string.IsNullOrEmpty(AmountTextBox.Text) || string.IsNullOrEmpty(LastNameTextBox.Text) || string.IsNullOrEmpty(MobileNoTextBox.Text) || string.IsNullOrEmpty(EmailTextbox.Text) || string.IsNullOrEmpty(AddressTextBox.Text) || string.IsNullOrEmpty(InsuranceCoTextBox.Text) || string.IsNullOrEmpty(InsIDTextbox.Text) || string.IsNullOrEmpty(VehicleIdTextBox.Text))
            {
                MessageBox.Show("Insufficient Information \n Please Fill-up all information", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else
            {
                try
                {
                    int temp = Convert.ToInt32(AmountTextBox.Text);


                    try
                    {
                        var customerRegister = new customer
                        {
                            fName            = FirstNameTextbox.Text.Trim(),
                            lName            = LastNameTextBox.Text.Trim(),
                            mobile           = MobileNoTextBox.Text.Trim(),
                            email            = EmailTextbox.Text.Trim(),
                            address          = AddressTextBox.Text.Trim(),
                            insuranceCompany = InsuranceCoTextBox.Text.Trim(),
                            insuranceId      = InsIDTextbox.Text.Trim(),
                            invoiceDate      = InvoiceDatePicker.Value.Date,
                            warrentyS        = WstartDatePicker.Value.Date,
                            warrentyE        = WendDatePicker.Value.Date,
                            vehicleId        = Int32.Parse(VehicleIdTextBox.Text),
                            paymentType      = PaymentTypeComboBox.SelectedItem.ToString()
                        };
                        _repousr2.Create(customerRegister);
                        int id_of_car = AddViewDeleteF.carid;
                        int sellPrice = Int32.Parse(AmountTextBox.Text.Trim());
                        _repousr3.Update(id_of_car, sellPrice);

                        MessageBox.Show("Provided Informations Successfully Inserted!!");
                        this.Visible = false;
                        ViewSoldVehiclesF vsv = new ViewSoldVehiclesF();
                        vsv.Visible = true;
                    }

                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
                catch (Exception h)
                {
                    MessageBox.Show("Please provide number Input for Amount");
                }
            }
        }
        public IHttpActionResult PostCustomer(Customer customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (_cr.GetByEmail(customer.Email) != null)
            {
                return(BadRequest());
            }

            _cr.Create(customer);

            return(CreatedAtRoute("DefaultApi", new { id = customer.Id }, customer));
        }
Beispiel #4
0
        public void TestCreateCustomer()
        {
            c = new Customer()
            {
                Firstname    = "Test",
                Lastname     = "Test",
                Email        = "*****@*****.**",
                Street       = "EsbjergGade",
                StreetNumber = 1,
                Zipcode      = 1111,
                City         = "Esbjerg"
            };
            var createdCustomer = _cr.Create(c);

            Assert.IsTrue(createdCustomer.Id != 0);
        }
Beispiel #5
0
        public void TestCreateOrder()
        {
            Customer c = new Customer()
            {
                Firstname    = "Test",
                Lastname     = "Test",
                Email        = "*****@*****.**",
                Street       = "EsbjergGade",
                StreetNumber = 1,
                Zipcode      = 1111,
                City         = "Esbjerg"
            };

            createdCustomer = _cr.Create(c);
            Assert.IsTrue(createdCustomer.Id != 0);
            Order o = new Order()
            {
                Customer       = createdCustomer,
                DateOfPurchase = DateTime.Now,
                GiftCards      = new List <GiftCard>()
                {
                    new GiftCard()
                    {
                        Amount = 111, CardNumber = "1"
                    },
                    new GiftCard()
                    {
                        Amount = 222, CardNumber = "2"
                    },
                    new GiftCard()
                    {
                        Amount = 333, CardNumber = "3"
                    },
                    new GiftCard()
                    {
                        Amount = 444, CardNumber = "4"
                    }
                },
                IsCompleted = false
            };

            var created = _or.Create(o);

            createdId = created.Id;
            Assert.IsTrue(createdId != 0);
        }
        private void Save(string strLink = "")
        {
            try
            {
                var Customer = _CustomerRepo.GetById(id);
                if (id > 0 && Customer != null)
                {
                    Customer.FULLNAME = txtName.Text;
                    Customer.TAX_CODE = txtTaxCode.Text;
                    Customer.EMAIL    = txtEmail.Text;
                    Customer.PHONE    = txtPhone.Text;
                    Customer.ADDRESS  = txtAddress.Text;

                    _CustomerRepo.Update(Customer);

                    strLink = string.IsNullOrEmpty(strLink) ? "chi-tiet-khach-hang.aspx?id=" + id : strLink;
                }
                else
                {
                    Customer              = new CUSTOMER();
                    Customer.FULLNAME     = txtName.Text;
                    Customer.TAX_CODE     = txtTaxCode.Text;
                    Customer.EMAIL        = txtEmail.Text;
                    Customer.PHONE        = txtPhone.Text;
                    Customer.ADDRESS      = txtAddress.Text;
                    Customer.CREATOR_ID   = Utils.CIntDef(Session["Userid"]);
                    Customer.CREATED_DATE = DateTime.Now;

                    _CustomerRepo.Create(Customer);

                    strLink = string.IsNullOrEmpty(strLink) ? "chi-tiet-khach-hang.aspx?id=" + Customer.ID : strLink;
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (!string.IsNullOrEmpty(strLink))
                {
                    Response.Redirect(strLink);
                }
            }
        }
Beispiel #7
0
        public void CreateCustomerAccount()
        {
            Customer customer = new Customer();

            customer.BankId    = 7;
            customer.Firstname = "Pertti";
            customer.Lastname  = "Puunanen";
            customer.Account   = new List <Account>
            {
                new Account
                {
                    Balance = 10,
                    Name    = "Pertin Tili",
                    Iban    = "88449922",
                    BankId  = 7
                }
            };
            _customerRepo.Create(customer);
        }