private void Save() { bool result = false; BooksTransactionInMaster objBooksTransactionInMaster = GetTransactionInMasterInterface(); BooksTransactionInMasterHandler masterhandler = new BooksTransactionInMasterHandler(); List <BooksTransactionInDetails> objDetailsList = GetTransactionInDetailsInterface(); BooksTransactionInDetailsHandler objDetailsHandler = new BooksTransactionInDetailsHandler(); if (AddMode) { result = masterhandler.AddNewTransactionInMaster(objBooksTransactionInMaster); if (result) { result = objDetailsHandler.AddNewTransactionInDetails(objDetailsList); } if (result) { result = GlobalFunction.UpdateUniqueCode("BooksTransactionInMaster"); } } else if (EditMode) { result = masterhandler.UpdateTransactionIn(objBooksTransactionInMaster); if (result) { result = objDetailsHandler.DeleteTransactionInDetails(objBooksTransactionInMaster.TransactionID); if (result) { result = objDetailsHandler.AddNewTransactionInDetails(objDetailsList); } } } if (result == true) { if (AddMode) { MessageBox.Show("New Record added successfully"); } else { MessageBox.Show("Record updated successfully"); } ControlStatus(true); } else { MessageBox.Show("Errror Occurs!"); } }
public void DisplayData(string transactionID = "-1") { try { ClearControl(); //Master Data BooksTransactionInMasterHandler objMasterHandler = new BooksTransactionInMasterHandler(); BooksTransactionInMaster objMaster = objMasterHandler.GetTransactionInMaster(transactionID); txtTranID.Text = objMaster.TransactionID; dtpTranInDate.Value = objMaster.TransactionDate; txtRemarks.Text = objMaster.Remarks; //Transaction Data BooksTransactionInDetailsHandler tranDetailsHandler = new BooksTransactionInDetailsHandler(); List <BooksTransactionInDetails> list = new List <BooksTransactionInDetails>(); list = tranDetailsHandler.GetTransactionInList(transactionID); if (list.Count > 0) { int i; foreach (BooksTransactionInDetails obj in list) { i = dgvMain.RowCount; dgvMain.RowCount = i + 1; dgvMain.Rows[i].Cells[SNo].Value = i + 1; dgvMain.Rows[i].Cells[BookID].Value = obj.BookMaster.BookID; dgvMain.Rows[i].Cells[Subject].Value = obj.BookMaster.Subject; dgvMain.Rows[i].Cells[Author].Value = obj.BookMaster.Author; dgvMain.Rows[i].Cells[EditionYear].Value = obj.BookMaster.EditionYear; dgvMain.Rows[i].Cells[EditionNo].Value = obj.BookMaster.EditionNo; dgvMain.Rows[i].Cells[Unit].Value = obj.Unit; } } ControlStatus(true); } catch (Exception ex) { MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + "\n" + ex.Message); } }