private void btnSave_Click(object sender, EventArgs e) { try { if (objMRMaterialCollec.Count > 0) { long MRNO = objMRDL.Add_BatchMR_Optional("N/A", objBatch.BatchID, objStore.StoreID, CurrentUser.EmployeeID, "Optional MR", MR.Status.Initial, MR.Type.Material, (int)MR.Origin.ToBatch); if (MRNO > 0) { objMR.MRNO = MRNO; foreach (MRMaterial obj in objMRMaterialCollec) { obj.MR = objMR; objMRMaterialDL.Add(obj); } MessageBox.Show(this, "Successfully Added to Database", "Successfull", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearItem(); ClearMR(); } } else { MessageBox.Show(this, "Item List is Empty,Please add Items before continue", "Item List is Empty", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }