public void AddMOMTransaction(MomBO pMomBO, ParticipantsBO[] pParticipantsBO, ActionItemsBO[] pActionItemsBO, AgendaBO[] pAgendaBO) { try { MomDA objMomDA = new MomDA(); objMomDA.AddMOMTransaction(pMomBO, pParticipantsBO, pActionItemsBO, pAgendaBO); } catch (Exception pEx) { throw pEx; } }
public static string BindMOMTable() { DataTable dt = new DataTable(); List <MomBO> MomDetails = new List <MomBO>(); JavaScriptSerializer js = new JavaScriptSerializer(); HttpContext Context = HttpContext.Current; MomBL objMomBL = new MomBL(); dt = objMomBL.GetMomList(); foreach (DataRow dtrow in dt.Rows) { DateTime temp = Convert.ToDateTime(dtrow["Date"]); var MomList = new MomBO { Id = Convert.ToInt32(dtrow["ID"]), //DateTime temp= dtrow["Date"].Date.ToS tempDate = temp.ToString("MM/dd/yyyy"), Title = dtrow["Title"].ToString(), //Facilitator = Convert.ToInt32(dtrow["Facilitator"]), tempFacilitator = dtrow["tempFacilitator"].ToString(), //Recorder = Convert.ToInt32(dtrow["Recorder"]), tempRecorder = dtrow["tempRecorder"].ToString(), LocationDetails = dtrow["LocationDetails"].ToString() }; MomDetails.Add(MomList); } string JsonData = js.Serialize(MomDetails); return(JsonData); }
public static void AddMOMTransaction(MomBO MomBO, ParticipantsBO[] ParticipantsBO, ActionItemsBO[] ActionItemsBO, AgendaBO[] AgendaBO) { MomBL objUserBL = new MomBL(); objUserBL.AddMOMTransaction(MomBO, ParticipantsBO, ActionItemsBO, AgendaBO); }
//MomBO objMomBO, ParticipantsBO objPartBO, AgendaBO objAgendaBO, ActionItemsBO objActionBO public void AddMOMTransaction(MomBO pMomBO, ParticipantsBO[] pParticipantsBO, ActionItemsBO[] pActionItemsBO, AgendaBO[] pAgendaBO) { #region //without transaction and seperate procedure DBHelper.ExecuteProcedure("AddMOM", "@Title", pMomBO.Title, "@Date", pMomBO.Date, "@Facilitator", pMomBO.Facilitator, "@Recorder", pMomBO.Recorder, "@LocationDetails", pMomBO.LocationDetails, "@CreatedBy", "Sujeet Kumar", "@CreatedDate", DateTime.Now, "@ModifiedBy", "Sujeet Kumar", "@ModifiedDate", DateTime.Now); DataTable dt = DBHelper.ExecuteQuery("select mid from tempMomID where id=1"); int pNewMomID = Convert.ToInt32(dt.Rows[0][0]); foreach (ActionItemsBO item in pActionItemsBO) { DBHelper.ExecuteProcedure("AddActionItems", "@ActionItem", item.ActionItem, "@Responsible", item.Responsible, "@Status", item.Status, "@DueDate", item.DueDate, "@CloseDate", item.CloseDate, "@MomId", pNewMomID, "@Discussion", item.Discussion); } foreach (AgendaBO item in pAgendaBO) { DBHelper.ExecuteProcedure("AddAgenda", "@DiscussionTopic", item.DiscussionTopic, "@Responsible", item.Responsible, "@MomId", pNewMomID, "@Time", item.Time, "@Purpose", item.Purpose, "@Discussion", item.Discussion); } foreach (ParticipantsBO item in pParticipantsBO) //MomId will be fetched from database and here the sequesce of query executed matters It should be executed just after AddMOM SP { DBHelper.ExecuteProcedure("AddParticipants", "@UserID", item.UserID, "@MomID", pNewMomID, "@Availability", item.Availability); } #endregion #region //old code with Transaction //string connectionString = "Integrated Security =sspi; database=ESupport; server=PACL5XS5AL\\SQLEXPRESS"; //using (SqlConnection connection = new SqlConnection(connectionString)) //{ // connection.Open(); // SqlCommand command = connection.CreateCommand(); // SqlTransaction transaction; // transaction = connection.BeginTransaction("MOMTransaction"); // command.Connection = connection; // command.Transaction = transaction; // try // { // //command.CommandText = "AddMOM"; // //command.CommandType = System.Data.CommandType.StoredProcedure; // //int pNewMomID = Convert.ToInt32(DBHelper.ExecuteScalar(connection,"select SCOPE_IDENTITY()")); // command.CommandText = "select SCOPE_IDENTITY()"; // //Int32 pNewMomID = (Int32) command.ExecuteScalar(); // //int pNewMomID = Convert.ToInt32(command.ExecuteNonQuery()); // foreach (ParticipantsBO item in pParticipantsBO) // { // DBHelper.ExecuteProcedure("AddParticipants",connection, "@UserID", item.UserID, "@MomID", pNewMomID, "@Availability", item.Availability); // } // foreach (ActionItemsBO item in pActionItemsBO) // { // DBHelper.ExecuteProcedure("AddActionItems", connection, "@ActionItem", item.ActionItem, "@Responsible", item.Responsible, "@Status", item.Status, "@DueDate", item.DueDate, "@CloseDate", item.CloseDate, "@MomId", pNewMomID, "@Discussion", item.Discussion); // } // foreach (AgendaBO item in pAgendaBO) // { // DBHelper.ExecuteProcedure("AddAgenda", connection, "@DiscussionTopic", item.DiscussionTopic, "@Responsible", item.Responsible, "@MomId", pNewMomID, "@Time", item.Time, "@Purpose", item.Purpose, "@Discussion", item.Discussion); // } // transaction.Commit(); // connection.Close(); // //DBHelper.ExecuteProcedure("AddActionItems", "@ActionItem", pParticipantsBO. "@Responsible", "@Status", "@DueDate", "@CloseDate", "@MomId") // } // catch (Exception pEx) // { // connection.Close(); // //try // //{ // // transaction.Rollback(); // //} // //catch (Exception pEx2) // //{ // // throw pEx2; // //} // throw pEx; // } //} #endregion }