private void btnSave_Click(object sender, EventArgs e) { int found = 0; btnSave.Enabled = false; if (txtCompName.Text.Equals("")) { MessageBox.Show("Please Insert Company Name !"); } else { DataTable dt = ClassSetting.searchCompanyByName(txtCompName.Text); for (int j = 0; j < dt.Rows.Count; j++) { if (txtCompName.Text.Equals(dt.Rows[j][0].ToString())) { found = 1; } } if (found == 1) { MessageBox.Show("This name already exists . ."); } else { int addcom = ClassSetting.sp_Addcompany(txtCompName.Text, (int)cmbCity.SelectedValue, (int)cmbCountry.SelectedValue); DataTable LastComp = ClassSetting.sp_selectTopCompany(); for (int i = 0; i < images.Count; i++) { int addIMG = ClassSetting.sp_AddcompanyIMG(images[i], int.Parse(LastComp.Rows[0][0].ToString())); } for (int i = 0; i < imagesBC.Count; i++) { int addIMGBC = ClassSetting.sp_AddcompanyBCard(imagesBC[i], int.Parse(LastComp.Rows[0][0].ToString())); } MessageBox.Show("Done"); txtCompName.Text = ""; images.Clear(); imagesBC.Clear(); lbBC.Text = lbIMG.Text = "?"; NumOfImage = NumOfImageBC = 0; } } btnSave.Enabled = true; }