private void btnUpdateEmp_Click(object sender, EventArgs e)
        {
            name    = tbName.Text.ToString();
            rank    = tbRank.Text.ToString();
            phone   = tbPhone.Text.ToString();
            email   = tbMail.Text.ToString();
            address = tbAddress.Text.ToString();
            nid     = tbNid.Text.ToString();
            sal     = Convert.ToDecimal(tbSal.Text.ToString());
            gender  = cbGender.SelectedItem.ToString();

            if (!name.Equals("") && !rank.Equals("") && !phone.Equals("") && !email.Equals("") && !address.Equals("") &&
                !nid.Equals("") && !gender.Equals("") && sal > 0)
            {
                emp.emp_address = address;
                emp.emp_email   = email;
                emp.emp_gender  = gender;
                emp.emp_name    = name;
                emp.emp_nid     = nid;
                emp.emp_phone   = phone;
                emp.emp_sal     = sal;
                emp.emp_rank    = rank;

                idc.SubmitChanges();
                MessageBox.Show("Successfully updated an employee.");
            }
            else
            {
                lblError.Text = "Please select a row to delete.";
            }
        }
Пример #2
0
        private void btnEditProduct_Click(object sender, EventArgs e)
        {
            name     = txtName.Text.ToString();
            brand    = cbBrand.SelectedItem.ToString();
            cat      = cbCat.SelectedItem.ToString();
            price    = Convert.ToDecimal(txtProductPrice.Text.ToString());
            warranty = Convert.ToInt32(txtProductWarrenty.Text.ToString());
            quantity = Convert.ToInt32(txtProductQuantity.Text.ToString());


            if (!name.Equals("") && !brand.Equals("") && !cat.Equals("") && !price.Equals("") && !quantity.Equals("") &&
                !warranty.Equals(""))
            {
                pr.pro_brand    = brand;
                pr.Pro_cat      = cat;
                pr.pro_price    = price;
                pr.pro_quantity = quantity;
                pr.pro_title    = name;
                pr.pro_warranty = warranty;

                idc.SubmitChanges();
                MessageBox.Show("Successfully Added an product.");
            }
            else
            {
                lblError.Text = "Please fill all the fields.";
            }
        }
Пример #3
0
        private void btnAddCat_Click(object sender, EventArgs e)
        {
            name = tbCat.Text.ToString();

            category c = new category();

            c.cat_title = name;

            if (!name.Equals(""))
            {
                idc.categories.InsertOnSubmit(c);
                idc.SubmitChanges();
                MessageBox.Show("Successfully Added a category.");
            }
            else
            {
                lblError.Text = "Please fill all the fields.";
            }
        }
Пример #4
0
        private void btnAddBrand_Click(object sender, EventArgs e)
        {
            name = tbBrands.Text.ToString();

            brand b = new brand();

            b.brand_title = name;

            if (!name.Equals(""))
            {
                idc.brands.InsertOnSubmit(b);
                idc.SubmitChanges();
                MessageBox.Show("Successfully Added a brand.");
            }
            else
            {
                lblError.Text = "Please fill all the fields.";
            }
        }
Пример #5
0
        private void btnDelEmp_Click(object sender, EventArgs e)
        {
            if (gvEmp.SelectedCells[0].Value != null)
            {
                int id = Convert.ToInt32(gvEmp.SelectedCells[0].Value.ToString());

                employee emp = idc.employees.SingleOrDefault(x => x.emp_id == id);

                idc.employees.DeleteOnSubmit(emp);
                idc.SubmitChanges();
                MessageBox.Show("Successfully deleted an employee.");
            }
            else
            {
                lblErrorEmp.Text = "Please select a row to delete.";
            }
        }
Пример #6
0
        private void btnAddEmp_Click(object sender, EventArgs e)
        {
            name    = tbEmpName.Text.ToString();
            rank    = tbEmpRank.Text.ToString();
            phone   = tbEmpPhone.Text.ToString();
            email   = tbEmpMail.Text.ToString();
            address = tbEmpAddress.Text.ToString();
            nid     = tbEmpNID.Text.ToString();
            sal     = Convert.ToDecimal(tbEmpSal.Text.ToString());
            gender  = cbGender.SelectedItem.ToString();
            join    = dtpJoin.Value.ToString("yyyy-MM-dd");
            DOB     = dtpDOB.Value.ToString("yyyy-MM-dd");


            employee emp = new employee();


            emp.emp_address   = address;
            emp.emp_dob       = Convert.ToDateTime(DOB);
            emp.emp_email     = email;
            emp.emp_gender    = gender;
            emp.emp_join_date = Convert.ToDateTime(join);
            emp.emp_name      = name;
            emp.emp_nid       = nid;
            emp.emp_phone     = phone;
            emp.emp_sal       = sal;
            emp.emp_rank      = rank;


            if (!name.Equals("") && !rank.Equals("") && !phone.Equals("") && !email.Equals("") && !address.Equals("") &&
                !nid.Equals("") && !gender.Equals("") && sal > 0)
            {
                idc.employees.InsertOnSubmit(emp);
                idc.SubmitChanges();
                MessageBox.Show("Successfully Added an employee.");
            }
            else
            {
                lblError.Text = "Please fill all the fields.";
            }
        }