public bool Update(Model_Common_Dict model) { StringBuilder builder = new StringBuilder(); builder.Append("update Common_Dict set "); builder.Append("Common_Dict_ID=@Common_Dict_ID,"); builder.Append("D_Name=@D_Name,"); builder.Append("D_ParentID=@D_ParentID,"); builder.Append("D_Value=@D_Value,"); builder.Append("D_Code=@D_Code,"); builder.Append("D_Level=@D_Level,"); builder.Append("D_Order=@D_Order,"); builder.Append("D_Type=@D_Type,"); builder.Append("D_Remark=@D_Remark,"); builder.Append("D_CreateUser=@D_CreateUser,"); builder.Append("D_CreateTime=@D_CreateTime,"); builder.Append("D_ModifyUser=@D_ModifyUser,"); builder.Append("D_ModifyTime=@D_ModifyTime"); builder.Append(" where "); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@Common_Dict_ID", SqlDbType.Char, 0x24), new SqlParameter("@D_Name", SqlDbType.NVarChar, 250), new SqlParameter("@D_ParentID", SqlDbType.Char, 0x24), new SqlParameter("@D_Value", SqlDbType.Int, 4), new SqlParameter("@D_Code", SqlDbType.VarChar, 300), new SqlParameter("@D_Level", SqlDbType.Int, 4), new SqlParameter("@D_Order", SqlDbType.Int, 4), new SqlParameter("@D_Type", SqlDbType.Int, 4), new SqlParameter("@D_Remark", SqlDbType.NVarChar, 0x7d0), new SqlParameter("@D_CreateUser", SqlDbType.Char, 0x24), new SqlParameter("@D_CreateTime", SqlDbType.DateTime), new SqlParameter("@D_ModifyUser", SqlDbType.Char, 0x24), new SqlParameter("@D_ModifyTime", SqlDbType.DateTime) }; cmdParms[0].Value = model.Common_Dict_ID; cmdParms[1].Value = model.D_Name; cmdParms[2].Value = model.D_ParentID; cmdParms[3].Value = model.D_Value; cmdParms[4].Value = model.D_Code; cmdParms[5].Value = model.D_Level; cmdParms[6].Value = model.D_Order; cmdParms[7].Value = model.D_Type; cmdParms[8].Value = model.D_Remark; cmdParms[9].Value = model.D_CreateUser; cmdParms[10].Value = model.D_CreateTime; cmdParms[11].Value = model.D_ModifyUser; cmdParms[12].Value = model.D_ModifyTime; return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0); }
private Model_Common_Dict GetD_OrderNext(Model_Common_Dict samplingTemp) { int type = Convert.ToInt32(samplingTemp.D_Type); samplingTemp.D_Order = BLL.GetTheTypeMaxOrder(type); return(samplingTemp); }
//新增 private void Add() { if (!CheckInput()) { return; } try { //从页面上取值 Model_Common_Dict samplingTemp = GetSysCodeFromPage(1); samplingTemp = GetD_OrderNext(samplingTemp); if (!SysCommon_DictExists(samplingTemp)) { var res = BLL.Add(samplingTemp); string strContent = string.Empty; ShowMsg(res > 0, "保存成功"); } else { ShowMsg(false, "此名称已存在"); } } catch (Exception ex) { ////MS.Authority.clsAuth.AddLogErrorFromBS(Module_Id, string.Format("类:{0},方法:{1},错误信息:{2}, 详细:{3}", ex.TargetSite.DeclaringType.ToString(), ex.TargetSite.Name.ToString(), ex.Message, ex.StackTrace)); throw ex; } }
public bool Exists(Model_Common_Dict model) { StringBuilder builder = new StringBuilder(); builder.Append("select count(1) from Common_Dict"); builder.AppendFormat(" where Common_Dict_ID<>'{0}'and D_Name='{1}' and D_Type='{2}' ", model.Common_Dict_ID, model.D_Name, model.D_Type); return(int.Parse(DbHelperSQL.GetSingle(builder.ToString()).ToString()) > 0); }
private int Update(DbTransaction tran, Model_Common_Dict model) { StringBuilder builder = new StringBuilder(); builder.Append(" UPDATE "); builder.Append(" Common_Dict "); builder.Append(" SET "); builder.Append(" Common_Dict_ID=@Common_Dict_ID,D_Name=@D_Name,D_PartentID=@D_PartentID,D_Value=@D_Value,D_Code=@D_Code,D_Level=@D_Level,D_Order=@D_Order,D_Type=@D_Type,D_Remark=@D_Remark,D_CreateUser=@D_CreateUser,D_CreateTime=@D_CreateTime,D_UpdateUser=@D_UpdateUser,D_UpdateTime=@D_UpdateTime "); builder.Append(" WHERE "); builder.Append(" Common_Dict_ID=@Common_Dict_ID "); return(this.CurrDB.ExecuteNonQuery(builder.ToString(), tran, new object[] { model.Common_Dict_ID, model.D_Name, model.D_PartentID, model.D_Value, model.D_Code, model.D_Level, model.D_Order, model.D_Type, model.D_Remark, model.D_CreateUser, model.D_CreateTime, model.D_UpdateUser, model.D_UpdateTime })); }
private int Add(DbTransaction tran, Model_Common_Dict model) { StringBuilder builder = new StringBuilder(); builder.Append(" INSERT INTO "); builder.Append(" Common_Dict( "); builder.Append(" Common_Dict_ID,D_Name,D_PartentID,D_Value,D_Code,D_Level,D_Order,D_Type,D_Remark,D_CreateUser,D_CreateTime,D_UpdateUser,D_UpdateTime "); builder.Append(" ) "); builder.Append(" values( "); builder.Append(" @Common_Dict_ID,@D_Name,@D_PartentID,@D_Value,@D_Code,@D_Level,@D_Order,@D_Type,@D_Remark,@D_CreateUser,@D_CreateTime,@D_UpdateUser,@D_UpdateTime "); builder.Append(" ) "); return(this.CurrDB.ExecuteNonQuery(builder.ToString(), tran, new object[] { model.Common_Dict_ID, model.D_Name, model.D_PartentID, model.D_Value, model.D_Code, model.D_Level, model.D_Order, model.D_Type, model.D_Remark, model.D_CreateUser, model.D_CreateTime, model.D_UpdateUser, model.D_UpdateTime })); }
public List <Model_Common_Dict> DataTableToList(DataTable dt) { List <Model_Common_Dict> list = new List <Model_Common_Dict>(); int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { Model_Common_Dict item = this.dal.DataRowToModel(dt.Rows[i]); if (item != null) { list.Add(item); } } } return(list); }
//从页面上获取模板数据 private Model_Common_Dict GetSysCodeFromPage(int i) { Model_Common_Dict Common_DictTemp = null; if (i == 1) { Common_DictTemp = new Model_Common_Dict(); Common_DictTemp.Common_Dict_ID = Guid.NewGuid().ToString(); Common_DictTemp.D_CreateUser = loginUser.SysUser_ID; Common_DictTemp.D_CreateTime = DateTime.Now; } else { Common_DictTemp = GetSysCommon_Dict(); Common_DictTemp.D_UpdateUser = loginUser.SysUser_ID; Common_DictTemp.D_UpdateTime = DateTime.Now; } Common_DictTemp.D_Name = txtD_Name.Text.Trim(); if (!string.IsNullOrEmpty(txtD_Value.Text.Trim())) { Common_DictTemp.D_Value = int.Parse(txtD_Value.Text.Trim()); } //Common_DictTemp.D_Code = txtD_Code.Text.Trim(); //yyk自己增加 //if (!string.IsNullOrEmpty(txtD_Order.Text.Trim())) //{ // Common_DictTemp.D_Order = int.Parse(txtD_Order.Text.Trim()); //} if (!string.IsNullOrEmpty(ddlD_Type.SelectedValue.Trim())) { Common_DictTemp.D_Type = int.Parse(ddlD_Type.SelectedValue.Trim()); } Common_DictTemp.D_Remark = txtRemark.Text.Trim(); return(Common_DictTemp); }
public Model_Common_Dict DataRowToModel(DataRow row) { Model_Common_Dict dict = new Model_Common_Dict(); if (row != null) { if (row["Common_Dict_ID"] != null) { dict.Common_Dict_ID = row["Common_Dict_ID"].ToString(); } if (row["D_Name"] != null) { dict.D_Name = row["D_Name"].ToString(); } if (row["D_ParentID"] != null) { dict.D_ParentID = row["D_ParentID"].ToString(); } if ((row["D_Value"] != null) && (row["D_Value"].ToString() != "")) { dict.D_Value = new int?(int.Parse(row["D_Value"].ToString())); } if (row["D_Code"] != null) { dict.D_Code = row["D_Code"].ToString(); } if ((row["D_Level"] != null) && (row["D_Level"].ToString() != "")) { dict.D_Level = new int?(int.Parse(row["D_Level"].ToString())); } if ((row["D_Order"] != null) && (row["D_Order"].ToString() != "")) { dict.D_Order = new int?(int.Parse(row["D_Order"].ToString())); } if ((row["D_Type"] != null) && (row["D_Type"].ToString() != "")) { dict.D_Type = new int?(int.Parse(row["D_Type"].ToString())); } if (row["D_Remark"] != null) { dict.D_Remark = row["D_Remark"].ToString(); } if (row["D_CreateUser"] != null) { dict.D_CreateUser = row["D_CreateUser"].ToString(); } if ((row["D_CreateTime"] != null) && (row["D_CreateTime"].ToString() != "")) { dict.D_CreateTime = new DateTime?(DateTime.Parse(row["D_CreateTime"].ToString())); } if (row["D_ModifyUser"] != null) { dict.D_ModifyUser = row["D_ModifyUser"].ToString(); } if ((row["D_ModifyTime"] != null) && (row["D_ModifyTime"].ToString() != "")) { dict.D_ModifyTime = new DateTime?(DateTime.Parse(row["D_ModifyTime"].ToString())); } } return(dict); }
public bool Exists(Model_Common_Dict model) { return(this.DAL.Exists(model)); }
//验证编辑是否存在 private bool Exists(Model_Common_Dict model) { return(BLL.Exists(model)); }
public int Update(Model_Common_Dict model) { return(this.DAL.Update(model)); }
public int Add(Model_Common_Dict model) { return(this.DAL.Add(model)); }
public bool Add(Model_Common_Dict model) { return(this.dal.Add(model)); }
private Model_Common_Dict GetCommon_DictModelByPK(DbTransaction tran, string common_dict_id) { StringBuilder builder = new StringBuilder(); builder.Append(" SELECT "); builder.Append(" TOP 1 * "); builder.Append(" FROM "); builder.Append(" Common_Dict "); builder.Append(" WHERE "); builder.Append(" Common_Dict_ID=@Common_Dict_ID "); DataSet set = this.CurrDB.ExecuteDataSet(builder.ToString(), tran, new object[] { common_dict_id }); Model_Common_Dict dict = null; if (set.Tables[0].Rows.Count > 0) { DataRow row = set.Tables[0].Rows[0]; dict = new Model_Common_Dict(); if (row["Common_Dict_ID"] != null) { dict.Common_Dict_ID = row["Common_Dict_ID"].ToString(); } if (row["D_Name"] != null) { dict.D_Name = row["D_Name"].ToString(); } if (row["D_PartentID"] != null) { dict.D_PartentID = row["D_PartentID"].ToString(); } if (row["D_Value"] != null) { if (string.IsNullOrWhiteSpace(row["D_Value"].ToString())) { dict.D_Value = null; } else { dict.D_Value = new int?(int.Parse(row["D_Value"].ToString())); } } if (row["D_Code"] != null) { dict.D_Code = row["D_Code"].ToString(); } if (row["D_Level"] != null) { if (string.IsNullOrWhiteSpace(row["D_Level"].ToString())) { dict.D_Level = null; } else { dict.D_Level = new int?(int.Parse(row["D_Level"].ToString())); } } if (row["D_Order"] != null) { if (string.IsNullOrWhiteSpace(row["D_Order"].ToString())) { dict.D_Order = null; } else { dict.D_Order = new int?(int.Parse(row["D_Order"].ToString())); } } if (row["D_Type"] != null) { if (string.IsNullOrWhiteSpace(row["D_Type"].ToString())) { dict.D_Type = null; } else { dict.D_Type = new int?(int.Parse(row["D_Type"].ToString())); } } if (row["D_Remark"] != null) { dict.D_Remark = row["D_Remark"].ToString(); } if (row["D_CreateUser"] != null) { dict.D_CreateUser = row["D_CreateUser"].ToString(); } if (row["D_CreateTime"] != null) { if (string.IsNullOrWhiteSpace(row["D_CreateTime"].ToString())) { dict.D_CreateTime = null; } else { dict.D_CreateTime = new DateTime?(DateTime.Parse(row["D_CreateTime"].ToString())); } } if (row["D_UpdateUser"] != null) { dict.D_UpdateUser = row["D_UpdateUser"].ToString(); } if (row["D_UpdateTime"] == null) { return(dict); } if (string.IsNullOrWhiteSpace(row["D_UpdateTime"].ToString())) { dict.D_UpdateTime = null; return(dict); } dict.D_UpdateTime = new DateTime?(DateTime.Parse(row["D_UpdateTime"].ToString())); } return(dict); }
public bool Update(Model_Common_Dict model) { return(this.dal.Update(model)); }
public int Add(Model_Common_Dict model) { return(this.Add(null, model)); }
private List <Model_Common_Dict> GetCommon_DictModelList(DbTransaction tran, int recordNum, string orderColumn, string orderType, string strCondition, params object[] param) { StringBuilder builder = new StringBuilder(); builder.Append(" SELECT "); if (recordNum > 0) { builder.Append(" TOP " + recordNum); } builder.Append(" * "); builder.Append(" FROM "); builder.Append(" Common_Dict "); if (!string.IsNullOrEmpty(strCondition)) { builder.Append(" WHERE "); builder.Append(strCondition); } if (!string.IsNullOrEmpty(orderColumn)) { builder.Append(" ORDER BY "); builder.Append(orderColumn); if (!string.IsNullOrEmpty(orderType)) { builder.Append(" " + orderType); } } DataSet set = this.CurrDB.ExecuteDataSet(builder.ToString(), tran, param); List <Model_Common_Dict> list = new List <Model_Common_Dict>(); Model_Common_Dict item = null; foreach (DataRow row in set.Tables[0].Rows) { item = new Model_Common_Dict(); if (row["Common_Dict_ID"] != null) { item.Common_Dict_ID = row["Common_Dict_ID"].ToString(); } if (row["D_Name"] != null) { item.D_Name = row["D_Name"].ToString(); } if (row["D_PartentID"] != null) { item.D_PartentID = row["D_PartentID"].ToString(); } if (row["D_Value"] != null) { if (string.IsNullOrWhiteSpace(row["D_Value"].ToString())) { item.D_Value = null; } else { item.D_Value = new int?(int.Parse(row["D_Value"].ToString())); } } if (row["D_Code"] != null) { item.D_Code = row["D_Code"].ToString(); } if (row["D_Level"] != null) { if (string.IsNullOrWhiteSpace(row["D_Level"].ToString())) { item.D_Level = null; } else { item.D_Level = new int?(int.Parse(row["D_Level"].ToString())); } } if (row["D_Order"] != null) { if (string.IsNullOrWhiteSpace(row["D_Order"].ToString())) { item.D_Order = null; } else { item.D_Order = new int?(int.Parse(row["D_Order"].ToString())); } } if (row["D_Type"] != null) { if (string.IsNullOrWhiteSpace(row["D_Type"].ToString())) { item.D_Type = null; } else { item.D_Type = new int?(int.Parse(row["D_Type"].ToString())); } } if (row["D_Remark"] != null) { item.D_Remark = row["D_Remark"].ToString(); } if (row["D_CreateUser"] != null) { item.D_CreateUser = row["D_CreateUser"].ToString(); } if (row["D_CreateTime"] != null) { if (string.IsNullOrWhiteSpace(row["D_CreateTime"].ToString())) { item.D_CreateTime = null; } else { item.D_CreateTime = new DateTime?(DateTime.Parse(row["D_CreateTime"].ToString())); } } if (row["D_UpdateUser"] != null) { item.D_UpdateUser = row["D_UpdateUser"].ToString(); } if (row["D_UpdateTime"] != null) { if (string.IsNullOrWhiteSpace(row["D_UpdateTime"].ToString())) { item.D_UpdateTime = null; } else { item.D_UpdateTime = new DateTime?(DateTime.Parse(row["D_UpdateTime"].ToString())); } } list.Add(item); } return(list); }
public int Update(Model_Common_Dict model) { return(this.Update(null, model)); }
private List <Model_Common_Dict> GetCommon_DictModelListByPage(DbTransaction tran, int pageSize, int pageIndex, string orderColumn, string orderType, string strCondition, params object[] param) { if ((pageSize <= 0) || (pageIndex <= 0)) { throw new Exception("分页参数错误,必须大于零"); } if (string.IsNullOrEmpty(orderColumn)) { throw new Exception("排序字段必须填写"); } int num = ((pageIndex - 1) * pageSize) + 1; int num2 = pageIndex * pageSize; StringBuilder builder = new StringBuilder(); builder.Append(" SELECT * FROM ("); builder.Append(string.Format(" SELECT (ROW_NUMBER() OVER(ORDER BY {0} {1})) as rownum,* FROM Common_Dict", orderColumn, orderType)); if (!string.IsNullOrWhiteSpace(strCondition)) { builder.Append(" WHERE "); builder.Append(strCondition); } builder.Append(" ) t "); builder.Append(" WHERE rownum between "); builder.Append(string.Format(" {0} ", num)); builder.Append(" AND "); builder.Append(string.Format(" {0} ", num2)); DataSet set = this.CurrDB.ExecuteDataSet(builder.ToString(), tran, param); List <Model_Common_Dict> list = new List <Model_Common_Dict>(); Model_Common_Dict item = null; foreach (DataRow row in set.Tables[0].Rows) { item = new Model_Common_Dict(); if (row["Common_Dict_ID"] != null) { item.Common_Dict_ID = row["Common_Dict_ID"].ToString(); } if (row["D_Name"] != null) { item.D_Name = row["D_Name"].ToString(); } if (row["D_PartentID"] != null) { item.D_PartentID = row["D_PartentID"].ToString(); } if (row["D_Value"] != null) { if (string.IsNullOrWhiteSpace(row["D_Value"].ToString())) { item.D_Value = null; } else { item.D_Value = new int?(int.Parse(row["D_Value"].ToString())); } } if (row["D_Code"] != null) { item.D_Code = row["D_Code"].ToString(); } if (row["D_Level"] != null) { if (string.IsNullOrWhiteSpace(row["D_Level"].ToString())) { item.D_Level = null; } else { item.D_Level = new int?(int.Parse(row["D_Level"].ToString())); } } if (row["D_Order"] != null) { if (string.IsNullOrWhiteSpace(row["D_Order"].ToString())) { item.D_Order = null; } else { item.D_Order = new int?(int.Parse(row["D_Order"].ToString())); } } if (row["D_Type"] != null) { if (string.IsNullOrWhiteSpace(row["D_Type"].ToString())) { item.D_Type = null; } else { item.D_Type = new int?(int.Parse(row["D_Type"].ToString())); } } if (row["D_Remark"] != null) { item.D_Remark = row["D_Remark"].ToString(); } if (row["D_CreateUser"] != null) { item.D_CreateUser = row["D_CreateUser"].ToString(); } if (row["D_CreateTime"] != null) { if (string.IsNullOrWhiteSpace(row["D_CreateTime"].ToString())) { item.D_CreateTime = null; } else { item.D_CreateTime = new DateTime?(DateTime.Parse(row["D_CreateTime"].ToString())); } } if (row["D_UpdateUser"] != null) { item.D_UpdateUser = row["D_UpdateUser"].ToString(); } if (row["D_UpdateTime"] != null) { if (string.IsNullOrWhiteSpace(row["D_UpdateTime"].ToString())) { item.D_UpdateTime = null; } else { item.D_UpdateTime = new DateTime?(DateTime.Parse(row["D_UpdateTime"].ToString())); } } list.Add(item); } return(list); }