//Method for Adding an new CRA or updating a new one public int AddCRAActivite(CRA_ActiviteMODEL p_craACT) { int i; using (SqlConnection con = new SqlConnection(cs)) { con.Open(); SqlCommand com = new SqlCommand("sp_CRA_Activite__InsertUpdate", con); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@Id", p_craACT.Id); com.Parameters.AddWithValue("@UsersId", p_craACT.UsersId); com.Parameters.AddWithValue("@CRATypeId", p_craACT.CRATypeId); com.Parameters.AddWithValue("@Period", p_craACT.Period); com.Parameters.AddWithValue("@CreationDate", p_craACT.CreationDate); com.Parameters.AddWithValue("@CreatedBy", p_craACT.CreatedBy); com.Parameters.AddWithValue("@ModificaitonDate", p_craACT.ModificaitonDate); com.Parameters.AddWithValue("@ModificaitonBy", p_craACT.ModificaitonBy); com.Parameters.AddWithValue("@PeriodBegin", p_craACT.PeriodBegin); com.Parameters.AddWithValue("@PeriodEnd", p_craACT.PeriodEnd); com.Parameters.AddWithValue("@Action", "insert"); i = com.ExecuteNonQuery(); } return(i); }
public JsonResult AddCRAActivite(CRA_ActiviteMODEL p_cra) { var truc = ((CustomPrincipal)User); p_cra.UsersId = truc.UserId; p_cra.CreationDate = DateTime.Now; p_cra.CreatedBy = truc.FirstName + "_" + truc.LastName; return(Json(g_craAdb.AddCRAActivite(p_cra), JsonRequestBehavior.AllowGet)); }