Ejemplo n.º 1
0
 private void btnNew_Click(object sender, EventArgs e)
 {
     if (btnNew.Text == "New")
     {
         b           = true;
         btnNew.Text = "Cancel";
         ConnectDatabase.ClearData(this);
         ConnectDatabase.OnoffControls(this, true);
         txtId.Enabled = true;
         txtId.Focus();
         btnDelete.Enabled = false;
         btnEdit.Enabled   = false;
         txtId.Text        = "";
         pictureBox1.Image = null;
     }
     else
     {
         DialogResult re;
         re = MessageBox.Show("Do you want to Cancel?", "Cancel", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (re == DialogResult.Yes)
         {
             btnNew.Text = "New";
             ConnectDatabase.ClearData(this);
             ConnectDatabase.OnoffControls(this, false);
             pictureBox1.Image = null;
             txtId.Text        = "";
             txtId.Enabled     = false;
         }
     }
 }
Ejemplo n.º 2
0
 private void btnnew_Click(object sender, EventArgs e)
 {
     if (btnnew.Text == "  New")
     {
         b            = true;
         btnnew.Text  = "   Cancel";
         btnnew.Image = BookstoreM3.Properties.Resources.cancel_32px;
         ConnectDatabase.ClearData(this);
         ConnectDatabase.OnoffControls(this, true);
         txtid.Enabled = true;
         txtid.Focus();
         btnDelete.Enabled = false;
         btnEdit.Enabled   = false;
     }
     else
     {
         DialogResult re;
         re = MessageBox.Show("Do you want to Cancel?", "Cancel", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (re == DialogResult.Yes)
         {
             btnnew.Text  = "  New";
             btnnew.Image = BookstoreM3.Properties.Resources.new_32px;
             ConnectDatabase.ClearData(this);
             ConnectDatabase.OnoffControls(this, false);
             picEmp.Image = null;
             txtid.Text   = "";
         }
     }
 }
Ejemplo n.º 3
0
        private void btnadd_Click(object sender, EventArgs e)
        {
            if (b == true)
            {
                cat.Type = txttype.Text;
                cat.AddCat(cat.Type);
                MessageBox.Show("You record was Inserted!");
                cat.GetCatByid(txtid);
                cat.GetCat(listCat);

                txttype.Text = "";
                ConnectDatabase.OnoffControls(this, false);
                btnnew.Text  = "  New";
                btnnew.Image = BookstoreM3.Properties.Resources.new_32px;
            }
            else
            {
                cat.Type = txttype.Text;
                cat.Id   = int.Parse(txtid.Text);
                cat.UpdateCategory(cat.Id, cat.Type);
                MessageBox.Show("Your record was updated!");
                cat.GetCat(listCat);
                txttype.Text = "";
                ConnectDatabase.OnoffControls(this, false);
                btnnew.Text  = "  New";
                btnnew.Image = BookstoreM3.Properties.Resources.new_32px;
            }
        }
Ejemplo n.º 4
0
 private void frmEmployee_Load_1(object sender, EventArgs e)
 {
     emp.GetEmp(dgvEmp);
     ConnectDatabase.OnoffControls(this, false);
     txtid.Enabled      = false;
     textBox1.Text      = "Searching ...";
     textBox1.ForeColor = Color.Gray;
 }
Ejemplo n.º 5
0
 private void frmCategory_Load(object sender, EventArgs e)
 {
     cat.GetCat(listCat);
     cat.GetCatByid(txtid);
     txtsearch.Text      = "Searching ...";
     txtsearch.ForeColor = Color.Gray;
     ConnectDatabase.OnoffControls(this, false);
 }
Ejemplo n.º 6
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     b = false;
     ConnectDatabase.OnoffControls(this, true);
     txttype.Focus();
     txtid.Enabled = false;
     btnnew.Text   = "    Cancel";
     btnnew.Image  = BookstoreM3.Properties.Resources.cancel_32px;
 }
Ejemplo n.º 7
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     b = false;
     ConnectDatabase.OnoffControls(this, true);
     txtId.Enabled = false;
     txtName.Focus();
     btnNew.Text            = "Cancel";
     cbCategory.DroppedDown = true;
 }
Ejemplo n.º 8
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult re;

            re = MessageBox.Show("Do you want to Close?", "Delete Employee", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (re == DialogResult.Yes)
            {
                getData();
                emp.Modify("DeleteEmp", emp.Eid, emp.Ename, emp.Gender, emp.Date, emp.Username, emp.Password);
                emp.GetEmp(dgvEmp);
                ConnectDatabase.ClearData(this);
                ConnectDatabase.OnoffControls(this, false);
            }
        }
Ejemplo n.º 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult re;

            re = MessageBox.Show("Do you want to Delete?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (re == DialogResult.Yes)
            {
                getData();
                pro.Modify("DelProduct", pro.Pid, pro.Pname, pro.Qty, pro.Price, cat_id);
                MessageBox.Show("Your record was deleted!");
                pro.GetProduct(dgvProduct);
                ConnectDatabase.ClearData(this);
                pictureBox1.Image = null;
                txtId.Text        = "";
                btnEdit.Enabled   = false;
                btnDelete.Enabled = false;
            }
        }
Ejemplo n.º 10
0
        private void dgvEmp_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int i = 0;

            if (dgvEmp.RowCount > 0)
            {
                i = e.RowIndex;
            }
            if (i < 0)
            {
                return;
            }
            DataGridViewRow row = dgvEmp.Rows[i];

            txtid.Text   = row.Cells[1].Value.ToString();
            txtname.Text = row.Cells[2].Value.ToString();
            if (row.Cells[3].Value.Equals("Male"))
            {
                rdMale.Checked = true;
            }
            else
            {
                rdFemale.Checked = true;
            }
            dtpdob.Text      = row.Cells[4].Value.ToString();
            txtusername.Text = row.Cells[6].Value.ToString();
            txtpassword.Text = row.Cells[7].Value.ToString();


            //read byte from datagridview

            photo = (byte[])row.Cells[5].Value;

            MemoryStream ms = new MemoryStream(photo);

            picEmp.Image = Image.FromStream(ms);
            ConnectDatabase.OnoffControls(this, false);
            ConnectDatabase.ClearData(this);
            txtid.Enabled     = false;
            btnEdit.Enabled   = true;
            btnDelete.Enabled = true;
        }
Ejemplo n.º 11
0
        private void frmProduct_Load(object sender, EventArgs e)
        {
            da = new SqlDataAdapter("SELECT * FROM tblCategory", ConnectDatabase.con);
            dt = new DataTable();
            da.Fill(dt);
            cbCategory.DataSource = null;
            cbCategory.Items.Clear();
            cbCategory.DataSource    = dt;
            cbCategory.DisplayMember = "Type";
            cbCategory.ValueMember   = "cid";

            pro.GetProduct(dgvProduct);

            //clear combobox selected item
            cbCategory.Text     = "";
            txtsearch.Text      = "Searching ...";
            txtsearch.ForeColor = Color.Gray;
            ConnectDatabase.OnoffControls(this, false);
            txtId.Enabled = false;
        }
Ejemplo n.º 12
0
 public frmCategory()
 {
     InitializeComponent();
     ConnectDatabase.Myconnection();
 }
Ejemplo n.º 13
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtid.Text) || string.IsNullOrWhiteSpace(txtid.Text))
            {
                MessageBox.Show("Invalid ID!");
                txtid.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtname.Text) || string.IsNullOrWhiteSpace(txtname.Text))
            {
                MessageBox.Show("Invalid Name!");
                txtname.Focus();
                return;
            }

            if (string.IsNullOrEmpty(txtusername.Text) || string.IsNullOrWhiteSpace(txtusername.Text))
            {
                MessageBox.Show("Invalid Username!");
                txtusername.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtpassword.Text) || string.IsNullOrWhiteSpace(txtpassword.Text))
            {
                MessageBox.Show("Invalid Password!");
                txtpassword.Focus();
                return;
            }
            if (picEmp.Image == null)
            {
                MessageBox.Show("Please choose image!");
                return;
            }
            if (b == true)
            {
                getData();
                emp.Modify("InsertEmp", emp.Eid, emp.Ename, emp.Gender, emp.Date, emp.Username, emp.Password);
                MessageBox.Show("Your record was Inserted!");
                emp.GetEmp(dgvEmp);
                txtid.Text     = "";
                btnnew.Text    = "  New";
                btnnew.Image   = BookstoreM3.Properties.Resources.new_32px;
                rdMale.Checked = true;
                txtid.Enabled  = false;
                ConnectDatabase.ClearData(this);
                ConnectDatabase.OnoffControls(this, false);
                picEmp.Image = null;
            }
            else
            {
                getData();
                emp.Modify("UpdateEmp", emp.Eid, emp.Ename, emp.Gender, emp.Date, emp.Username, emp.Password);
                MessageBox.Show("Your record was updated!");
                emp.GetEmp(dgvEmp);
                txtid.Text     = "";
                btnnew.Text    = "  New";
                btnnew.Image   = BookstoreM3.Properties.Resources.new_32px;
                rdMale.Checked = true;
                txtid.Enabled  = false;
                ConnectDatabase.ClearData(this);
                ConnectDatabase.OnoffControls(this, false);
                picEmp.Image = null;
            }
        }
Ejemplo n.º 14
0
 public frmEmployee()
 {
     InitializeComponent();
     ConnectDatabase.Myconnection();
 }
Ejemplo n.º 15
0
 public frmSaleReport()
 {
     InitializeComponent();
     ConnectDatabase.Myconnection();
 }
Ejemplo n.º 16
0
 public frmProduct()
 {
     InitializeComponent();
     ConnectDatabase.Myconnection();
 }
Ejemplo n.º 17
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtId.Text) || string.IsNullOrWhiteSpace(txtId.Text))
     {
         MessageBox.Show("Invalid product ID!");
         txtId.Focus();
         return;
     }
     if (string.IsNullOrEmpty(txtName.Text) || string.IsNullOrWhiteSpace(txtName.Text))
     {
         MessageBox.Show("Invalid product Name!");
         txtName.Focus();
         return;
     }
     if (string.IsNullOrEmpty(txtPrice.Text) || string.IsNullOrWhiteSpace(txtPrice.Text))
     {
         MessageBox.Show("Invalid product price!");
         txtPrice.Focus();
         return;
     }
     if (string.IsNullOrEmpty(txtQuantity.Text) || string.IsNullOrWhiteSpace(txtQuantity.Text))
     {
         MessageBox.Show("Invalid product Quantity!");
         txtQuantity.Focus();
         return;
     }
     if (string.IsNullOrEmpty(cbCategory.Text) || string.IsNullOrWhiteSpace(cbCategory.Text))
     {
         MessageBox.Show("Invalid product category!");
         cbCategory.DroppedDown = true;
         return;
     }
     if (pictureBox1.Image == null)
     {
         MessageBox.Show("Please choose product image!");
         return;
     }
     if (b == true)
     {
         getData();
         pro.Modify("InsertProduct", pro.Pid, pro.Pname, pro.Qty, pro.Price, cat_id);
         MessageBox.Show("Your record was Inserted!");
         pro.GetProduct(dgvProduct);
         ConnectDatabase.ClearData(this);
         ConnectDatabase.OnoffControls(this, false);
         btnNew.Text       = "New";
         txtId.Text        = "";
         pictureBox1.Image = null;
     }
     else
     {
         getData();
         pro.Modify("UpdateProduct", pro.Pid, pro.Pname, pro.Qty, pro.Price, cat_id);
         MessageBox.Show("Your record was updated!");
         pro.GetProduct(dgvProduct);
         ConnectDatabase.ClearData(this);
         ConnectDatabase.OnoffControls(this, false);
         btnNew.Text       = "New";
         txtId.Text        = "";
         pictureBox1.Image = null;
     }
     txtId.Enabled = false;
 }
Ejemplo n.º 18
0
 public frmSale()
 {
     InitializeComponent();
     ConnectDatabase.Myconnection();
     timer1.Start();
 }
Ejemplo n.º 19
0
 private void Form1_Load(object sender, EventArgs e)
 {
     ConnectDatabase.Myconnection();
 }