public ControlJob Update(ControlJob CJ, string userid) { var sqlQuery = string.Format(@"UPDATE CONTROLJOB SET ITEMCODE = '{0}', ITEMDESCRIPTION = '{1}', CONTROLSYSTEM = '{2}', JOB = '{3}', ISACTIVE = '{4}', UPDATEBY = {5}, UPDATEDATE = '{6}' WHERE SID = {7}", CJ.ITEMCODE, CJ.ITEMDESCRIPTION, CJ.CONTROLSYSTEM, CJ.JOB, CJ.ISACTIVE, Convert.ToInt32(userid), DateTime.Now, CJ.SID); this._db.Execute(sqlQuery, CJ); return(CJ); }
public ControlJob Add(ControlJob CJ, string userid) { var sqlQuery = @"INSERT INTO CONTROLJOB (ITEMCODE, ITEMDESCRIPTION, CONTROLSYSTEM, JOB, ISACTIVE, INPUTBY, INPUTDATE, UPDATEBY, UPDATEDATE) VALUES ('" + CJ.ITEMCODE + "', '" + CJ.ITEMDESCRIPTION + "', '" + CJ.CONTROLSYSTEM + @"', '" + CJ.JOB + "', '" + CJ.ISACTIVE + "', " + Convert.ToInt32(userid) + ", '" + DateTime.Now + @"', " + Convert.ToInt32(userid) + ", '" + DateTime.Now + @"'); " + "SELECT CAST(SCOPE_IDENTITY() as int)"; var SID = _db.Query <int>(sqlQuery, CJ).Single(); CJ.SID = SID; return(CJ); }
public JsonResult Edit(ControlJob controljob, string userid) { try { if (ModelState.IsValid) { ICJ.Update(controljob, Session["userid"].ToString()); } } catch { return(Json("error")); } return(Json("success")); }