public static Model.SoftWare GetModel(int ID) { string strSql = "select * from SoftWare where ID = '" + ID + "'"; Model.SoftWare model = new Model.SoftWare(); DataSet ds = DBHelperSQL.GetDataSet(strSql, connectionString); model.ID = ID; if (ds.Tables[0].Rows.Count > 0) { model.SoftWareName = Convert.ToString(ds.Tables[0].Rows[0]["SoftWareName"]); model.SoftWareType = Convert.ToString(ds.Tables[0].Rows[0]["SoftWareType"]); model.Type = Convert.ToString(ds.Tables[0].Rows[0]["Type"]); model.Config = Convert.ToString(ds.Tables[0].Rows[0]["Config"]); model.Maintenance = Convert.ToString(ds.Tables[0].Rows[0]["Maintenance"]); model.Num = Convert.ToString(ds.Tables[0].Rows[0]["Num"]); model.IP = Convert.ToString(ds.Tables[0].Rows[0]["IP"]); model.IsShow = Convert.ToString(ds.Tables[0].Rows[0]["IsShow"]); model.Time = Convert.ToDateTime(ds.Tables[0].Rows[0]["Time"]); return(model); } else { return(null); } }
private void AddEquip() { var cont = Request["equip"].ToString(); Content content = CORSV2.cs.JSONHelper.JSONToObject <Content>(cont); Model.SoftWare md = new Model.SoftWare(); md.SoftWareType = content.SoftWareType; md.Type = content.dType; md.Config = content.Config; md.Maintenance = content.Maintenance; md.SoftWareName = content.SoftWareName; md.Num = content.Num; md.IP = content.IP; md.Time = DateTime.Now; md.IsShow = "1"; bool r = DAL.SoftWare.Add(md); if (r) { Response.Clear(); Response.Write("1"); Response.End(); } else { Response.Clear(); Response.Write("2"); Response.End(); } }
private void DeleteEquips() { int[] ids; string a = Request["id[]"]; string[] temp = a.Split(','); ids = new int[temp.Length]; try { for (int m = 0; m < temp.Length; m++) { ids[m] = Convert.ToInt32(temp[m]); Model.SoftWare md = DAL.SoftWare.GetModel(ids[m]); bool resultd = DAL.SoftWare.Delete(md.ID); Model.SysLog mSysLog = new Model.SysLog(); mSysLog.LogTime = DateTime.Now; mSysLog.LogType = 0; mSysLog.UserName = Session["UserName"].ToString(); mSysLog.Remark = "管理员删除了软件:" + md.SoftWareType; DAL.SysLog.Add(mSysLog); } Response.Clear(); Response.Write("1"); Response.End(); } catch (Exception) { } }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserName"] == null) { Response.Write("<script>alert(\"请登录\");location.href = location.origin+\"/Index.aspx\";</script>"); Response.End(); } if (Session["UserType"] == null || (Convert.ToInt32(Session["UserType"]) != 2 && Convert.ToInt32(Session["UserType"]) != 3)) { Response.Write("<script>alert(\"登录账户类型有误\");location.href = location.origin+\"/Index.aspx\";</script>"); Response.End(); } if (!IsPostBack) { string id = Request["id"].ToString(); Model.SoftWare md = DAL.SoftWare.GetModel(int.Parse(id)); IDS.Value = md.ID.ToString();; SoftWareName.Value = md.SoftWareName; dType.Value = md.Type; SoftWareType.Value = md.SoftWareType; IP.Value = md.IP; Num.Value = md.Num; Maintenance.Value = md.Maintenance; Config.Value = md.Config; } else { if (Request["action"] == "save") { Model.SoftWare ms = new Model.SoftWare(); ms.Config = Request.Form["Config"].ToString(); ms.IP = Request.Form["IP"].ToString(); ms.Maintenance = Request.Form["Maintenance"].ToString(); ms.Num = Request.Form["Num"].ToString(); ms.SoftWareName = Request.Form["SoftWareName"].ToString(); ms.SoftWareType = Request.Form["SoftWareType"].ToString(); ms.Time = DateTime.Now; ms.Type = Request.Form["dType"].ToString(); ms.IsShow = "1"; Model.SoftWare msold = DAL.SoftWare.GetModel(int.Parse(Request.Form["IDS"].ToString())); msold.IsShow = "0"; if (DAL.SoftWare.Add(ms) && DAL.SoftWare.Update(msold)) { Response.Clear(); Response.Write("1"); Response.End(); } else { Response.Clear(); Response.Write("0"); Response.End(); } } } }
/// <summary> /// 更新一条数据,根据ID /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool Update(Model.SoftWare model) { string strSql = "update SoftWare set IsShow=@IsShow, SoftWareName=@SoftWareName, SoftWareType=@SoftWareType, Type=@Type, Config=@Config, Maintenance=@Maintenance, Num=@Num, IP=@IP, Time=@Time where ID = " + model.ID.ToString(); SqlParameter SoftWareType = new SqlParameter("SoftWareType", SqlDbType.NVarChar); SoftWareType.Value = model.SoftWareType; SqlParameter Type = new SqlParameter("Type", SqlDbType.NVarChar); Type.Value = model.Type; SqlParameter Config = new SqlParameter("Config", SqlDbType.NVarChar); Config.Value = model.Config; SqlParameter Maintenance = new SqlParameter("Maintenance", SqlDbType.NVarChar); Maintenance.Value = model.Maintenance; SqlParameter SoftWareName = new SqlParameter("SoftWareName", SqlDbType.NVarChar); SoftWareName.Value = model.SoftWareName; SqlParameter Num = new SqlParameter("Num", SqlDbType.NVarChar); Num.Value = model.Num; SqlParameter IP = new SqlParameter("IP", SqlDbType.NVarChar); IP.Value = model.IP; SqlParameter Time = new SqlParameter("Time", SqlDbType.DateTime); Time.Value = model.Time; SqlParameter IsShow = new SqlParameter("IsShow", SqlDbType.NVarChar); IsShow.Value = model.IsShow; return(DBHelperSQL.GetNums(strSql, new SqlParameter[] { SoftWareName, SoftWareType, Type, Config, Maintenance, Num, IP, Time, IsShow }, connectionString) == 1 ? true : false); }
/// <summary> /// 增加一个设备 /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool Add(Model.SoftWare model) { string strSql = "insert into SoftWare(SoftWareName,SoftWareType, Type, Config, Maintenance,Num,IP,Time,IsShow) values(@SoftWareName,@SoftWareType, @Type, @Config, @Maintenance,@Num,@IP,@Time,@IsShow)"; SqlParameter SoftWareType = new SqlParameter("SoftWareType", SqlDbType.NVarChar); SoftWareType.Value = model.SoftWareType; SqlParameter Type = new SqlParameter("Type", SqlDbType.NVarChar); Type.Value = model.Type; SqlParameter Config = new SqlParameter("Config", SqlDbType.NVarChar); Config.Value = model.Config; SqlParameter Maintenance = new SqlParameter("Maintenance", SqlDbType.NVarChar); Maintenance.Value = model.Maintenance; SqlParameter SoftWareName = new SqlParameter("SoftWareName", SqlDbType.NVarChar); SoftWareName.Value = model.SoftWareName; SqlParameter Num = new SqlParameter("Num", SqlDbType.NVarChar); Num.Value = model.Num; SqlParameter IP = new SqlParameter("IP", SqlDbType.NVarChar); IP.Value = model.IP; SqlParameter Time = new SqlParameter("Time", SqlDbType.DateTime); Time.Value = model.Time; SqlParameter IsShow = new SqlParameter("IsShow", SqlDbType.NVarChar); IsShow.Value = model.IsShow; return(DBHelperSQL.GetNums(strSql, new SqlParameter[] { SoftWareName, SoftWareType, Type, Config, Maintenance, Num, IP, Time, IsShow }, connectionString) == 1 ? true : false); }