private void btnUpdate_Click(object sender, EventArgs e) { int found = 0; if (txtname.Text.Equals("")) { MessageBox.Show("Please insert product name ."); } else { DataTable ProName = ClassProduct.selectOnePro(txtbarcode.Text); if (ProName.Rows.Count > 0 && !ProName.Rows[0][0].ToString().Equals(ProID.ToString())) { found = 1; MessageBox.Show("This Product or Barcode Already Exist . ."); } } if (found == 0) { int i = ClassManagmentReport.updatePro(ProID, txtname.Text, txtbarcode.Text, txtCategory.Text, txtCountry.Text, txtcity.Text, txtCompany.Text, "0", "0", "0", rtxtdiscrp.Text, rtxtnote.Text); txtname.Text = txtbarcode.Text = txtCategory.Text = txtCountry.Text = txtcity.Text = txtCompany.Text = rtxtdiscrp.Text = rtxtnote.Text = ""; MessageBox.Show("Done. ."); } this.Close(); }
private void btnSave_Click(object sender, EventArgs e) { btnSave.Enabled = false; int found = 0; if (txtname.Text.Equals("")) { MessageBox.Show("Please Insert Product Name ! "); } else { DataTable ProName = ClassProduct.selectOnePro(txtbarcode.Text); if (ProName.Rows.Count > 0) { found = 1; MessageBox.Show("This Product or Barcode Already Exist . ."); } if (found == 0) { int product = ClassProduct.insertPro(txtname.Text, txtbarcode.Text, txtCategory.Text, txtCountry.Text, txtcity.Text, txtCompany.Text, "0", "0", "0", rtxtdiscrp.Text, rtxtnote.Text); if (NumOfImage > 0) { DataTable LastOne = ClassProduct.LastPro(); for (int i = 0; i < images.Count; i++) { int AddImg = ClassProduct.insertIMG(images[i], int.Parse(LastOne.Rows[0][0].ToString())); } } txtname.Text = txtbarcode.Text = txtCategory.Text = txtCountry.Text = txtcity.Text = txtCompany.Text = rtxtdiscrp.Text = rtxtnote.Text = ""; lbNumIMG.Text = "0"; NumOfImage = 0; images.Clear(); MessageBox.Show("Done. ."); } } btnSave.Enabled = true; }