Exemplo n.º 1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            SICDbEntities context    = new SICDbEntities();
            int           CustomerId = Convert.ToInt32(txtCustomerId.Text);
            Customer      cust       = context.Customers.First(u => u.CustomerId == CustomerId);

            cust.Email       = txtEmail.Text;
            cust.CompanyName = txtCompanyName.Text;
            cust.Address     = txtAddress.Text;
            cust.City        = txtCity.Text;
            cust.BIN         = txtBIN.Text;
            cust.PostalCode  = txtPostalCode.Text;
            cust.CustomerId  = Convert.ToInt32(txtCustomerId.Text);
            cust.Phone       = txtPhone.Text;
            cust.Province    = cmbProvince.Text;

            var m = MessageBox.Show("Are you sure?", "Update", MessageBoxButtons.YesNo);

            if (m.ToString() == "Yes")
            {
                context.SaveChanges();
                readCustomer();
            }
            else
            {
                readCustomer();
            }
        }
Exemplo n.º 2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            SICDbEntities context = new SICDbEntities();
            int           OrderId = Convert.ToInt32(txtOrderId.Text);
            Order         ord     = context.Orders.First(o => o.OrderId == OrderId);

            ord.ProductName   = txtProductName.Text;
            ord.Brand         = txtBrand.Text;
            ord.Specification = txtSpecification.Text;
            ord.Currency      = cmbCurrency.Text;
            ord.Price         = txtPrice.Text;
            ord.Warehouse     = cmbWarehouse.Text;
            ord.Room          = cmbRoom.Text;
            ord.Aisle         = cmbAisle.Text;
            ord.ProductType   = cmbProductType.Text;
            ord.Shelf         = cmbShelf.Text;
            ord.Quantity      = txtQuantity.Text;
            ord.OrderId       = Convert.ToInt32(txtOrderId.Text);

            var m = MessageBox.Show("Are you sure?", "Update", MessageBoxButtons.YesNo);

            if (m.ToString() == "Yes")
            {
                context.SaveChanges();
                readOrder();
            }
            else
            {
                readOrder();
            }
        }
Exemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtProductName.Text == "")
            {
                MessageBox.Show("The field Product Name must be filled!", "Warning", MessageBoxButtons.OK);
            }
            else
            {
                if (txtCustomerId.Text == "" || txtCustomerName.Text == "")
                {
                    MessageBox.Show("The fields Customer Id and Customer Name  must be filled!", "Warning", MessageBoxButtons.OK);
                }
                else
                {
                    using (var db = new SICDbEntities())
                    {
                        var ord = new Order();

                        ord.CustomerCustomerId = Convert.ToInt32(txtCustomerId.Text);
                        ord.ProductName        = txtProductName.Text;
                        ord.Brand         = txtBrand.Text;
                        ord.Specification = txtSpecification.Text;
                        ord.Currency      = Convert.ToString(cmbCurrency.SelectedItem);
                        ord.Price         = txtPrice.Text;
                        ord.Warehouse     = Convert.ToString(cmbWarehouse.SelectedItem);
                        ord.Room          = Convert.ToString(cmbRoom.SelectedItem);
                        ord.Aisle         = Convert.ToString(cmbAisle.SelectedItem);
                        ord.ProductType   = Convert.ToString(cmbProductType.SelectedItem);
                        ord.Shelf         = Convert.ToString(cmbShelf.SelectedItem);
                        ord.Quantity      = txtQuantity.Text;


                        db.Orders.Add(ord);
                        db.SaveChanges();
                    }

                    MessageBox.Show("Order released sucessfully!", "Order Release Info", MessageBoxButtons.OK);
                    var m = MessageBox.Show("Do you want add one more Order now?", "Warning", MessageBoxButtons.YesNo);
                    if (m.ToString() == "Yes")
                    {
                        txtBrand.Text         = "";
                        txtPrice.Text         = "";
                        txtProductName.Text   = "";
                        txtQuantity.Text      = "";
                        txtSpecification.Text = "";
                        cmbProductType.Text   = "";
                    }
                    else
                    {
                        Form.ActiveForm.Close();
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            SICDbEntities context    = new SICDbEntities();
            int           CustomerId = Convert.ToInt32(txtCustomerId.Text);
            Customer      user       = context.Customers.First(u => u.CustomerId == CustomerId);
            var           m          = MessageBox.Show("Are you sure?", "Delete", MessageBoxButtons.YesNo);

            if (m.ToString() == "Yes")
            {
                context.Customers.Remove(user);
                context.SaveChanges();
            }
            else
            {
                readCustomer();
            }

            readCustomer();
        }
Exemplo n.º 5
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (txtPassword.Text != txtRetypePassword.Text)
            {
                lblWrongPassword.Visible = true;
            }
            else
            {
                var option = "";
                if (rdbYES.Checked == true)
                {
                    option = "YES";
                }
                else if (rdbNO.Checked == true)
                {
                    option = "NO";
                }
                SICDbEntities context = new SICDbEntities();
                int           UserId  = Convert.ToInt32(txtUserId.Text);
                User          user    = context.Users.First(u => u.UserId == UserId);

                user.Email      = txtEmail.Text;
                user.FirstName  = txtFirstName.Text;
                user.LastName   = txtLastName.Text;
                user.EmployeeId = txtEmployeeId.Text;
                user.JobTitle   = txtJobTitle.Text;
                user.Password   = txtPassword.Text;
                user.UserId     = Convert.ToInt32(txtUserId.Text);
                user.ADM        = option;

                var m = MessageBox.Show("Are you sure?", "Update", MessageBoxButtons.YesNo);
                if (m.ToString() == "Yes")
                {
                    context.SaveChanges();
                    readUsers();
                    lblWrongPassword.Visible = false;
                }
                else
                {
                    readUsers();
                }
            }
        }
Exemplo n.º 6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtCompanyName.Text == "" || txtEmail.Text == "")
            {
                MessageBox.Show("The fields Company Name and Email must be filled!", "Warning", MessageBoxButtons.OK);
            }
            else
            {
                using (var db = new SICDbEntities())
                {
                    var cust = new Customer();
                    cust.CompanyName = txtCompanyName.Text;
                    cust.BIN         = txtBIN.Text;
                    cust.Email       = txtEmail.Text;
                    cust.Address     = txtAddress.Text;
                    cust.Phone       = txtPhone.Text;
                    cust.City        = txtCity.Text;
                    cust.PostalCode  = txtPostalCode.Text;
                    cust.Province    = Convert.ToString(cmbProvince.SelectedItem);

                    db.Customers.Add(cust);
                    db.SaveChanges();
                }
                MessageBox.Show("Customer added sucessfully!", "New Customer Info", MessageBoxButtons.OK);
                var m = MessageBox.Show("Do you want add one more Customer now?", "Warning", MessageBoxButtons.YesNo);
                if (m.ToString() == "Yes")
                {
                    txtAddress.Text     = "";
                    txtBIN.Text         = "";
                    txtCity.Text        = "";
                    txtCompanyName.Text = "";
                    txtEmail.Text       = "";
                    txtPhone.Text       = "";
                    txtPostalCode.Text  = "";
                    cmbProvince.Text    = "";
                }
                else
                {
                    Form.ActiveForm.Close();
                }
            }
        }
Exemplo n.º 7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtEmail.Text == "" || txtEmployeeId.Text == "" || txtPassword.Text == "")
            {
                MessageBox.Show("The fields Email,Password and EmployeeId must be filled!", "Warning", MessageBoxButtons.OK);
            }
            else
            {
                if (txtPassword.Text != txtRetypePassword.Text)
                {
                    lblWrongPassword.Visible = true;
                }
                else
                {
                    var option = "";
                    if (rdbYES.Checked)
                    {
                        option = "YES";
                    }
                    else if (rdbNO.Checked)
                    {
                        option = "NO";
                    }
                    else
                    {
                        MessageBox.Show("Error", "Warning", MessageBoxButtons.OK);
                    }
                    using (var db = new SICDbEntities())
                    {
                        var user = new User();
                        user.FirstName  = txtFirstName.Text;
                        user.LastName   = txtLastName.Text;
                        user.Email      = txtEmail.Text;
                        user.JobTitle   = txtJobTitle.Text;
                        user.EmployeeId = txtEmployeeId.Text;
                        user.Password   = txtPassword.Text;
                        user.ADM        = option;

                        db.Users.Add(user);
                        db.SaveChanges();
                    }

                    lblWrongPassword.Visible = false;
                    MessageBox.Show("User added sucessfully!", "New User Info", MessageBoxButtons.OK);
                    var m = MessageBox.Show("Do you want add one more Users now?", "Warning", MessageBoxButtons.YesNo);
                    if (m.ToString() == "Yes")
                    {
                        txtFirstName.Text        = "";
                        txtEmail.Text            = "";
                        txtEmployeeId.Text       = "";
                        txtJobTitle.Text         = "";
                        txtLastName.Text         = "";
                        txtPassword.Text         = "";
                        txtRetypePassword.Text   = "";
                        rdbNO.Checked            = true;
                        rdbYES.Checked           = false;
                        lblWrongPassword.Visible = false;
                    }
                    else
                    {
                        Form.ActiveForm.Close();
                    }
                }
            }
        }