public ActionResult SaveShareConfig(ShareConfigSource scs) { if (scs.PKId == 0) { scs.CreateDateTime = DateTime.Now; scs.UpdateDateTime = DateTime.Now; scs.Creator = ThreadIdentity.Operator.Name; int pkid = ShareConfigManager.InsertShareConfig(scs); scs.PKId = pkid; //写操作记录 ShareConfigLog scl = new ShareConfigLog() { ConfigId = scs.PKId, Operator = ThreadIdentity.Operator.Name, OperateType = 0, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now }; ShareConfigManager.InsertShareConfigLog(scl); } else if (scs.PKId > 0) { scs.UpdateDateTime = DateTime.Now; string oldlocation = ShareConfigManager.SelectLocationByPKId(scs.PKId); string newlocation = scs.Location; ShareConfigManager.UpdateShareConfig(scs); //写操作记录 ShareConfigLog scl = new ShareConfigLog() { ConfigId = scs.PKId, Operator = ThreadIdentity.Operator.Name, OperateType = 1, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now }; ShareConfigManager.InsertShareConfigLog(scl); } else { scs.CreateDateTime = DateTime.Now; scs.UpdateDateTime = DateTime.Now; scs.Creator = ThreadIdentity.Operator.Name; int pkid = ShareConfigManager.InsertShareConfig(scs); scs.PKId = pkid; //写操作记录 ShareConfigLog scl = new ShareConfigLog() { ConfigId = scs.PKId, Operator = ThreadIdentity.Operator.Name, OperateType = 0, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now }; ShareConfigManager.InsertShareConfigLog(scl); } return(Json(scs.PKId)); }
public int InsertShareConfig(ShareConfigSource scs) { try { return(handler.InsertShareConfig(scs)); } catch (TuhuBizException) { throw; } catch (Exception ex) { var exception = new DownloadAppException(1, "InsertShareConfig", ex); Logger.Log(Level.Error, exception, "InsertShareConfig"); throw ex; } }
public static int InsertShareConfig(SqlConnection conn, ShareConfigSource scs) { string insertShareConfigText = @" INSERT INTO Configuration..ShareConfigSource(Location,Description,Status,CreateDateTime,UpdateDateTime,Creator,SpecialParam) OUTPUT Inserted.PKId VALUES (@location,@description,@status,@createdatetime,@updatedateTime,@creator,@SpecialParam)"; var sqlParam = new SqlParameter[] { new SqlParameter("@location", scs.Location), new SqlParameter("@description", scs.Description), new SqlParameter("@status", scs.Status), new SqlParameter("@createdatetime", scs.CreateDateTime), new SqlParameter("@updatedateTime", scs.UpdateDateTime), new SqlParameter("@creator", scs.Creator), new SqlParameter("@SpecialParam", scs.SpecialParam), }; return(Convert.ToInt32(SqlHelper.ExecuteScalar(conn, CommandType.Text, insertShareConfigText, sqlParam))); }
public static bool UpdateShareConfig(SqlConnection conn, ShareConfigSource scs) { string updateShareConfigText = @" UPDATE Configuration..ShareConfigSource SET Location=@location, Description=@description, Status=@status, UpdateDateTime=@updatedatetime, SpecialParam=@SpecialParam WHERE PKId=@pkid"; var sqlParam = new SqlParameter[] { new SqlParameter("@location", scs.Location), new SqlParameter("@description", scs.Description), new SqlParameter("@status", scs.Status), new SqlParameter("@updatedatetime", scs.UpdateDateTime), new SqlParameter("@pkid", scs.PKId), new SqlParameter("@SpecialParam", scs.SpecialParam), }; return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, updateShareConfigText, sqlParam) > 0 ? true : false); }
public ActionResult TemplateEdit(int id = 0) { if (id == 0) { ViewBag.Title = "新增"; ShareConfigSource scs = new ShareConfigSource() { PKId = 0, Location = null, Description = null, Status = 1, }; return(View(scs)); } else if (id > 0) { ViewBag.Title = "修改"; ShareConfigQuery query = new ShareConfigQuery { IdCriterion = id, PageIndex = 1, }; var datas = ShareConfigManager.SelectShareConfig(query); ShareConfigSource scs = datas.FirstOrDefault() ?? new ShareConfigSource(); return(View(scs)); } else { ViewBag.Title = "复制"; ShareConfigQuery query = new ShareConfigQuery { IdCriterion = -id, PageIndex = 1, }; var datas = ShareConfigManager.SelectShareConfig(query); ShareConfigSource scs = datas.FirstOrDefault() ?? new ShareConfigSource(); scs.PKId = id; return(View(scs)); } }
public int InsertShareConfig(ShareConfigSource scs) { Func <SqlConnection, int> action = (connection) => DalShareConfig.InsertShareConfig(connection, scs); return(dbManager.Execute(action)); }
public bool UpdateShareConfig(ShareConfigSource scs) { Func <SqlConnection, bool> action = (connection) => DalShareConfig.UpdateShareConfig(connection, scs); return(dbManager.Execute(action)); }