/// <summary> /// 查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSearch_Click(object sender, EventArgs e) { Model.T_SystemInfo_MDL model = new DigiPower.Onlinecol.Standard.Model.T_SystemInfo_MDL(); Search(this.tblSearch, model); this.BindGridView(); }
/// <summary> /// 绑定页面 /// </summary> /// <param name="ID"></param> private void BindPage(string ID) { if (!String.IsNullOrWhiteSpace(ID)) { Model.T_SystemInfo_MDL model = new DigiPower.Onlinecol.Standard.Model.T_SystemInfo_MDL(); BLL.T_SystemInfo_BLL bll = new DigiPower.Onlinecol.Standard.BLL.T_SystemInfo_BLL(); model = bll.GetModel(Convert.ToInt32(ID)); if (model != null) { ViewState["model"] = model; Comm.SetValueToPage(model, this.tbl); } } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(DigiPower.Onlinecol.Standard.Model.T_SystemInfo_MDL model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_SystemInfo("); strSql.Append("CurrentType,CurrentTypeCNName,SystemInfoCode,SystemInfoName,SubType,OrderIndex,ParentID,IsShow,IfEdit)"); strSql.Append(" values ("); strSql.Append("@CurrentType,@CurrentTypeCNName,@SystemInfoCode,@SystemInfoName,@SubType,@OrderIndex,@ParentID,@IsShow,@IfEdit)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CurrentType", SqlDbType.NVarChar, 50), new SqlParameter("@CurrentTypeCNName", SqlDbType.NVarChar, 50), new SqlParameter("@SystemInfoCode", SqlDbType.NVarChar, 50), new SqlParameter("@SystemInfoName", SqlDbType.NVarChar, 50), new SqlParameter("@SubType", SqlDbType.NVarChar, 10), new SqlParameter("@OrderIndex", SqlDbType.Int, 8), new SqlParameter("@ParentID", SqlDbType.Int, 8), new SqlParameter("@IsShow", SqlDbType.Bit, 1), new SqlParameter("@IfEdit", SqlDbType.Bit, 1) }; parameters[0].Value = model.CurrentType; parameters[1].Value = model.CurrentTypeCNName; parameters[2].Value = model.SystemInfoCode; parameters[3].Value = model.SystemInfoName; parameters[4].Value = model.SubType; parameters[5].Value = model.OrderIndex; parameters[6].Value = model.ParentID; parameters[7].Value = model.IsShow; parameters[8].Value = model.IfEdit; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(DigiPower.Onlinecol.Standard.Model.T_SystemInfo_MDL model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_SystemInfo set "); strSql.Append("CurrentType=@CurrentType,"); strSql.Append("CurrentTypeCNName=@CurrentTypeCNName,"); strSql.Append("SystemInfoCode=@SystemInfoCode,"); strSql.Append("SystemInfoName=@SystemInfoName,"); strSql.Append("SubType=@SubType,"); strSql.Append("OrderIndex=@OrderIndex,"); strSql.Append("ParentID=@ParentID,"); strSql.Append("IsShow=@IsShow,"); strSql.Append("IfEdit=@IfEdit"); strSql.Append(" where SystemInfoID=@SystemInfoID "); SqlParameter[] parameters = { new SqlParameter("@SystemInfoID", SqlDbType.Int, 8), new SqlParameter("@CurrentType", SqlDbType.NVarChar, 50), new SqlParameter("@CurrentTypeCNName", SqlDbType.NVarChar, 50), new SqlParameter("@SystemInfoCode", SqlDbType.NVarChar, 50), new SqlParameter("@SystemInfoName", SqlDbType.NVarChar, 50), new SqlParameter("@SubType", SqlDbType.NVarChar, 10), new SqlParameter("@OrderIndex", SqlDbType.Int, 8), new SqlParameter("@ParentID", SqlDbType.Int, 8), new SqlParameter("@IsShow", SqlDbType.Bit, 1), new SqlParameter("@IfEdit", SqlDbType.Bit, 1) }; parameters[0].Value = model.SystemInfoID; parameters[1].Value = model.CurrentType; parameters[2].Value = model.CurrentTypeCNName; parameters[3].Value = model.SystemInfoCode; parameters[4].Value = model.SystemInfoName; parameters[5].Value = model.SubType; parameters[6].Value = model.OrderIndex; parameters[7].Value = model.ParentID; parameters[8].Value = model.IsShow; parameters[9].Value = model.IfEdit; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { Model.T_SystemInfo_MDL model = new DigiPower.Onlinecol.Standard.Model.T_SystemInfo_MDL(); if (ViewState["model"] != null) { model = (Model.T_SystemInfo_MDL)ViewState["model"]; } BLL.T_SystemInfo_BLL bll = new DigiPower.Onlinecol.Standard.BLL.T_SystemInfo_BLL(); object obj = Comm.GetValueToObject(model, this.tbl); if (obj != null) { Model.T_SystemInfo_MDL Newmodel = (Model.T_SystemInfo_MDL)obj; switch ((CommonEnum.PageState)ViewState["ps"]) { case CommonEnum.PageState.ADD: int systemInfoID = bll.Add(Newmodel); PublicModel.writeLog(SystemSet.EumLogType.AddData.ToString(), string.Concat("T_SystemInfo;key=", systemInfoID, ";CurrentType=", Newmodel.CurrentType, ";SystemInfoCode=", Newmodel.SystemInfoCode, ";SystemInfoName=", Newmodel.SystemInfoName)); break; case CommonEnum.PageState.EDIT: { bll.Update(Newmodel); PublicModel.writeLog(SystemSet.EumLogType.UpdData.ToString(), string.Concat("T_SystemInfo;key=", Newmodel.SystemInfoID, ";CurrentType=", Newmodel.CurrentType, ";SystemInfoCode=", Newmodel.SystemInfoCode, ";SystemInfoName=", Newmodel.SystemInfoName)); } break; } } Common.MessageBox.CloseLayerOpenWeb(this.Page); }
/// <summary> /// 得到一个对象实体 /// </summary> public DigiPower.Onlinecol.Standard.Model.T_SystemInfo_MDL GetModel(int SystemInfoID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 SystemInfoID,CurrentType,CurrentTypeCNName,SystemInfoCode,SystemInfoName,SubType,OrderIndex,ParentID,IsShow,IfEdit from T_SystemInfo "); strSql.Append(" where SystemInfoID=@SystemInfoID "); SqlParameter[] parameters = { new SqlParameter("@SystemInfoID", SqlDbType.Int, 8) }; parameters[0].Value = SystemInfoID; DigiPower.Onlinecol.Standard.Model.T_SystemInfo_MDL model = new DigiPower.Onlinecol.Standard.Model.T_SystemInfo_MDL(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["SystemInfoID"].ToString() != "") { model.SystemInfoID = int.Parse(ds.Tables[0].Rows[0]["SystemInfoID"].ToString()); } model.CurrentType = ds.Tables[0].Rows[0]["CurrentType"].ToString(); model.CurrentTypeCNName = ds.Tables[0].Rows[0]["CurrentTypeCNName"].ToString(); model.SystemInfoCode = ds.Tables[0].Rows[0]["SystemInfoCode"].ToString(); model.SystemInfoName = ds.Tables[0].Rows[0]["SystemInfoName"].ToString(); model.SubType = ds.Tables[0].Rows[0]["SubType"].ToString(); if (ds.Tables[0].Rows[0]["OrderIndex"].ToString() != "") { model.OrderIndex = int.Parse(ds.Tables[0].Rows[0]["OrderIndex"].ToString()); } if (ds.Tables[0].Rows[0]["ParentID"].ToString() != "") { model.ParentID = int.Parse(ds.Tables[0].Rows[0]["ParentID"].ToString()); } if (ds.Tables[0].Rows[0]["IsShow"].ToString() != "") { if ((ds.Tables[0].Rows[0]["IsShow"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsShow"].ToString().ToLower() == "true")) { model.IsShow = true; } else { model.IsShow = false; } } if (ds.Tables[0].Rows[0]["IfEdit"].ToString() != "") { if ((ds.Tables[0].Rows[0]["IfEdit"].ToString() == "1") || (ds.Tables[0].Rows[0]["IfEdit"].ToString().ToLower() == "true")) { model.IfEdit = true; } else { model.IfEdit = false; } } return(model); } else { return(null); } }