예제 #1
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   = "";
         }
     }
 }
예제 #2
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;
         }
     }
 }
예제 #3
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     b = false;
     ConnectDatabase.ClearData(this);
     ConnectDatabase.OnoffControls(this, true);
     txtid.Enabled = false;
     txtname.Focus();
     btnnew.Text  = "Cancel";
     btnnew.Image = BookstoreM3.Properties.Resources.cancel_32px;
 }
예제 #4
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);
            }
        }
예제 #5
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;
            }
        }
예제 #6
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;
        }
예제 #7
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;
            }
        }
예제 #8
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;
 }