private void btnStoreSave_Click(object sender, EventArgs e) { try { Store objStoreTemp = new Store(); Department objDep = (Department)cmbDepartment.SelectedItem; Employee objSK = (Employee)cmbStoreKeeper.SelectedItem; objStoreTemp.StoreDepartment = objDep; objStoreTemp.StoreDescription = txtStoreDesc.Text; objStoreTemp.StoreID = txtStoreID.Text; objStoreTemp.StoreKeeper = objSK; objStoreTemp.StoreName = txtStoreName.Text; if (this.StoreSelect) { int x = objStoreDL.Update(objStoreTemp, objStore.StoreID); if (x > 0) { MessageBox.Show(this, "Succesfully Updated to Database", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadStore(); ClearStore(); } else { MessageBox.Show(this, "Store ID is already in the Database, Please add another Store ID", "Store ID in Database", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { int x = objStoreDL.Add(objStoreTemp); if (x > 0) { MessageBox.Show(this, "Succesfully Added to Database", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadStore(); ClearStore(); } else { MessageBox.Show(this, "Store ID is already in the Database, Please add another Store ID", "Store ID in Database", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }