Beispiel #1
0
        private void readUsers()
        {
            SICDbEntities      use  = new SICDbEntities();
            IEnumerable <User> list = from U in use.Users select U;

            dgvUsersList.DataSource = list.ToList();
        }
Beispiel #2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            SICDbEntities      User = new SICDbEntities();
            IEnumerable <User> list = from u in User.Users where u.FirstName == txtSearch.Text || u.LastName == txtSearch.Text || u.JobTitle == txtSearch.Text || u.EmployeeId == txtSearch.Text || u.Email == txtSearch.Text || u.ADM == txtSearch.Text select u;

            dgvUsersList.DataSource = list.ToList();
        }
Beispiel #3
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            SICDbEntities          Cust = new SICDbEntities();
            IEnumerable <Customer> list = from c in Cust.Customers where c.CompanyName == txtSearch.Text || c.BIN == txtSearch.Text || c.Email == txtSearch.Text || c.Province == txtSearch.Text || c.City == txtSearch.Text select c;

            dgvCustomerList.DataSource = list.ToList();
        }
Beispiel #4
0
        private void readCustomer()
        {
            SICDbEntities          cust = new SICDbEntities();
            IEnumerable <Customer> list = from C in cust.Customers select C;

            dgvCustomerList.DataSource = list.ToList();
        }
Beispiel #5
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            SICDbEntities       Ord  = new SICDbEntities();
            IEnumerable <Order> list = from o in Ord.Orders where o.ProductName == txtSearch.Text || o.Brand == txtSearch.Text || o.Specification == txtSearch.Text || o.Warehouse == txtSearch.Text || o.Room == txtSearch.Text || o.Aisle == txtSearch.Text || o.Shelf == txtSearch.Text || o.ProductType == txtSearch.Text || o.Quantity == txtSearch.Text select o;

            dgvOrdersList.DataSource = list.ToList();
        }
Beispiel #6
0
        private void readOrder()
        {
            SICDbEntities       ord  = new SICDbEntities();
            IEnumerable <Order> list = from o in ord.Orders select o;

            dgvOrdersList.DataSource = list.ToList();
        }
Beispiel #7
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();
            }
        }
Beispiel #8
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();
            }
        }
Beispiel #9
0
        private void FindCustomerSearch(int CustomerId)
        {
            SICDbEntities context = new SICDbEntities();
            Customer      cust    = context.Customers.First(u => u.CustomerId == CustomerId);

            txtCustomerName.Text = cust.CompanyName;
            txtCustomerId.Text   = cust.CustomerId.ToString();
        }
Beispiel #10
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();
                    }
                }
            }
        }
Beispiel #11
0
        private void ReportOrders_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'SICDbDataSet6.Orders' table. You can move, or remove it, as needed.
            this.OrdersTableAdapter.Fill(this.SICDbDataSet6.Orders);

            SICDbEntities       Ord  = new SICDbEntities();
            IEnumerable <Order> list = from o in Ord.Orders select o;

            rpwOrders.LocalReport.ReportEmbeddedResource = "ReportOrders.rdlc";
            Microsoft.Reporting.WinForms.ReportDataSource rds = new Microsoft.Reporting.WinForms.ReportDataSource("DataSetOrders", list);
            rds.Name  = "DataSetOrders";
            rds.Value = list;
            rpwOrders.LocalReport.DataSources.Add(rds);
            rpwOrders.RefreshReport();
        }
Beispiel #12
0
        private void FindCustomer(int CustomerId)
        {
            SICDbEntities context = new SICDbEntities();
            Customer      cust    = context.Customers.First(u => u.CustomerId == CustomerId);

            txtEmail.Text       = cust.Email;
            txtCompanyName.Text = cust.CompanyName;
            txtBIN.Text         = cust.BIN;
            txtAddress.Text     = cust.Address;
            txtCity.Text        = cust.City;
            txtPhone.Text       = cust.Phone;
            txtPostalCode.Text  = cust.PostalCode;
            cmbProvince.Text    = cust.Province;
            txtCustomerId.Text  = cust.CustomerId.ToString();
        }
Beispiel #13
0
        private void manageUsersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SICDbEntities context = new SICDbEntities();
            String        Email   = lblEmailUserLogonText.Text;
            User          user    = context.Users.First(u => u.Email == Email);

            if (user.ADM == "YES")
            {
                Form ManagerUser = new ManagerUsers();
                ManagerUser.Show();
            }
            else
            {
                MessageBox.Show("You are not an Adminstrator!", "Warning", MessageBoxButtons.OK);
            }
        }
Beispiel #14
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();
        }
Beispiel #15
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();
                }
            }
        }
Beispiel #16
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();
                }
            }
        }
Beispiel #17
0
        public void btnLogin_Click_1(object sender, EventArgs e)
        {
            using (var db = new SICDbEntities())
            {
                var EmailResult =
                    (from em in db.Users
                     where em.Email == txtEmail.Text
                     select em.Email).SingleOrDefault();

                var PasswordResult =
                    (from en in db.Users
                     where en.Email == txtEmail.Text
                     select en.Password).SingleOrDefault();

                if (EmailResult != txtEmail.Text)
                {
                    MessageBox.Show("Email incorrect or no registered!", "Login Error", MessageBoxButtons.OK);
                }
                else if (PasswordResult != txtPassword.Text)
                {
                    MessageBox.Show("Password incorrect or no registered!", "Login Error", MessageBoxButtons.OK);
                }
                else
                {
                    if (Application.OpenForms["Main"] == null)
                    {
                        string email = txtEmail.Text;

                        Main NewMain = new Main(email);
                        NewMain.Show();
                        //txtEmail.Text = "";
                        txtPassword.Text = "";
                    }
                    else
                    {
                        MessageBox.Show("You must click on Logout to allow opening as another User!", "Warning", MessageBoxButtons.OK);
                    }
                }
            }
        }
Beispiel #18
0
        private void FindOrder(int OrderId)
        // private void FindOrder(int OrderId, int CustomerId)
        {
            SICDbEntities context = new SICDbEntities();
            Order         ord     = context.Orders.First(o => o.OrderId == OrderId);

            //Customer cust = context.Orders.First(c => c.CustomerCustomerId == CustomerId);

            txtCustomerId.Text    = ord.CustomerCustomerId.ToString();
            txtCustomerName.Text  = ord.Customer.CompanyName;
            txtProductName.Text   = ord.ProductName;
            txtBrand.Text         = ord.Brand;
            txtSpecification.Text = ord.Specification;
            cmbCurrency.Text      = ord.Currency;
            txtPrice.Text         = ord.Price;
            cmbWarehouse.Text     = ord.Warehouse;
            cmbRoom.Text          = ord.Room;
            cmbAisle.Text         = ord.Aisle;
            cmbProductType.Text   = ord.ProductType;
            cmbShelf.Text         = ord.Shelf;
            txtQuantity.Text      = ord.Quantity;
            txtOrderId.Text       = ord.OrderId.ToString();
        }
Beispiel #19
0
        private void FindUsers(int UserId)
        {
            SICDbEntities context = new SICDbEntities();
            User          user    = context.Users.First(u => u.UserId == UserId);

            if (user.ADM == "YES")
            {
                rdbYES.Checked = true;
            }
            else
            {
                rdbNO.Checked = true;
            }

            txtEmail.Text          = user.Email;
            txtFirstName.Text      = user.FirstName;
            txtLastName.Text       = user.LastName;
            txtEmployeeId.Text     = user.EmployeeId;
            txtJobTitle.Text       = user.JobTitle;
            txtPassword.Text       = user.Password;
            txtRetypePassword.Text = user.Password;
            txtUserId.Text         = user.UserId.ToString();
        }
Beispiel #20
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();
                    }
                }
            }
        }