/// <summary> /// 增加一条数据 /// </summary> public int Add(SCZM.Model.System.sys_Process_BillSet model, out string message) { message = "新增成功!"; int rowId = dal.Add(model); if (rowId < 1) { message = "新增失败!"; } return(rowId); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(SCZM.Model.System.sys_Process_BillSet model, out string message) { message = "修改成功!"; int rows = dal.Update(model); if (rows == 0) { message = "对不起,该条数据已被其他人删除!"; return(false); } else { return(true); } }
/// <summary> /// 更新一条数据 /// </summary> public int Update(SCZM.Model.System.sys_Process_BillSet model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update sys_Process_BillSet set "); strSql.Append("BillSign=@BillSign,"); strSql.Append("TableName=@TableName,"); strSql.Append("BillName=@BillName,"); strSql.Append("ProcessId=@ProcessId,"); strSql.Append("SupId=@SupId,"); strSql.Append("SortId=@SortId,"); strSql.Append("FlagHistory=@FlagHistory,"); strSql.Append("FlagDel=@FlagDel,"); strSql.Append("OperaName=@OperaName,"); strSql.Append("OperaTime=@OperaTime"); strSql.Append(" where FlagDel=0 and ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@BillSign", SqlDbType.VarChar, 50), new SqlParameter("@TableName", SqlDbType.VarChar, 50), new SqlParameter("@BillName", SqlDbType.NVarChar, 50), new SqlParameter("@ProcessId", SqlDbType.Int, 4), new SqlParameter("@SupId", SqlDbType.Int, 4), new SqlParameter("@SortId", SqlDbType.Int, 4), new SqlParameter("@FlagHistory", SqlDbType.Bit, 1), new SqlParameter("@FlagDel", SqlDbType.Bit, 1), new SqlParameter("@OperaName", SqlDbType.NVarChar, 20), new SqlParameter("@OperaTime", SqlDbType.DateTime), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.BillSign; parameters[1].Value = model.TableName; parameters[2].Value = model.BillName; parameters[3].Value = model.ProcessId; parameters[4].Value = model.SupId; parameters[5].Value = model.SortId; parameters[6].Value = model.FlagHistory; parameters[7].Value = model.FlagDel; parameters[8].Value = model.OperaName; parameters[9].Value = model.OperaTime; parameters[10].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); return(rows); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(SCZM.Model.System.sys_Process_BillSet model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into sys_Process_BillSet("); strSql.Append("BillSign,TableName,BillName,ProcessId,SupId,SortId,FlagHistory,FlagDel,OperaName,OperaTime)"); strSql.Append(" values ("); strSql.Append("@BillSign,@TableName,@BillName,@ProcessId,@SupId,@SortId,@FlagHistory,@FlagDel,@OperaName,@OperaTime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@BillSign", SqlDbType.VarChar, 50), new SqlParameter("@TableName", SqlDbType.VarChar, 50), new SqlParameter("@BillName", SqlDbType.NVarChar, 50), new SqlParameter("@ProcessId", SqlDbType.Int, 4), new SqlParameter("@SupId", SqlDbType.Int, 4), new SqlParameter("@SortId", SqlDbType.Int, 4), new SqlParameter("@FlagHistory", SqlDbType.Bit, 1), new SqlParameter("@FlagDel", SqlDbType.Bit, 1), new SqlParameter("@OperaName", SqlDbType.NVarChar, 20), new SqlParameter("@OperaTime", SqlDbType.DateTime) }; parameters[0].Value = model.BillSign; parameters[1].Value = model.TableName; parameters[2].Value = model.BillName; parameters[3].Value = model.ProcessId; parameters[4].Value = model.SupId; parameters[5].Value = model.SortId; parameters[6].Value = model.FlagHistory; parameters[7].Value = model.FlagDel; parameters[8].Value = model.OperaName; parameters[9].Value = model.OperaTime; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public SCZM.Model.System.sys_Process_BillSet GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,BillSign,TableName,BillName,ProcessId,SupId,SortId,FlagHistory,FlagDel,OperaName,OperaTime from sys_Process_BillSet "); strSql.Append(" where FlagDel=0 and ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; SCZM.Model.System.sys_Process_BillSet model = new SCZM.Model.System.sys_Process_BillSet(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 子方法 从DataRow中 /// </summary> public SCZM.Model.System.sys_Process_BillSet DataRowToModel(DataRow row) { SCZM.Model.System.sys_Process_BillSet model = new SCZM.Model.System.sys_Process_BillSet(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["BillSign"] != null) { model.BillSign = row["BillSign"].ToString(); } if (row["TableName"] != null) { model.TableName = row["TableName"].ToString(); } if (row["BillName"] != null) { model.BillName = row["BillName"].ToString(); } if (row["ProcessId"] != null && row["ProcessId"].ToString() != "") { model.ProcessId = int.Parse(row["ProcessId"].ToString()); } if (row["SupId"] != null && row["SupId"].ToString() != "") { model.SupId = int.Parse(row["SupId"].ToString()); } if (row["SortId"] != null && row["SortId"].ToString() != "") { model.SortId = int.Parse(row["SortId"].ToString()); } if (row["FlagHistory"] != null && row["FlagHistory"].ToString() != "") { if ((row["FlagHistory"].ToString() == "1") || (row["FlagHistory"].ToString().ToLower() == "true")) { model.FlagHistory = true; } else { model.FlagHistory = false; } } if (row["FlagDel"] != null && row["FlagDel"].ToString() != "") { if ((row["FlagDel"].ToString() == "1") || (row["FlagDel"].ToString().ToLower() == "true")) { model.FlagDel = true; } else { model.FlagDel = false; } } if (row["OperaName"] != null) { model.OperaName = row["OperaName"].ToString(); } if (row["OperaTime"] != null && row["OperaTime"].ToString() != "") { model.OperaTime = DateTime.Parse(row["OperaTime"].ToString()); } } return(model); }