Пример #1
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     DLL.Model.computer computer = new DLL.Model.computer();
      computer.defineId = TextBoxdefine.Text.Trim();
      computer.brand = TextBoxbrand.Text.Trim();
      computer.version = TextBoxversion.Text.Trim();
      computer.username = TextBoxuser.Text.Trim();
      computer.type = Enum.GetName(typeof(DLL.BaseCode.BaseCode.type), DropDownListtype.SelectedIndex);
      computer.nettype = TextBoxnet.Text.Trim();
      computer.department = TextBoxdepart.Text.Trim();
      computer.roomNum = TextBoxroom.Text.Trim();
 }
Пример #2
0
 protected void ImageButtonsave_Click(object sender, EventArgs e)
 {
     DLL.Model.computer computer2 = new DLL.Model.computer();
     computer2.defineId = TextBoxdefineId.Text.Trim().ToString();
     computer2.type = Enum.GetName(typeof(DLL.BaseCode.BaseCode.type), DropDownListtype.SelectedIndex);
     computer2.brand = TextBoxbrand.Text.ToString();
     computer2.version = TextBoxversion.Text.ToString();
     computer2.nettype = Enum.GetName(typeof(DLL.BaseCode.BaseCode.nettype), DropDownListnet.SelectedIndex);
     computer2.innerIP = TextBoxiIP.Text.ToString();
     computer2.outerIP = TextBoxoIP.Text.ToString();
     computer2.screenInfo = TextBoxsInfo.Text.ToString();
     computer2.printerInfo = TextBoxpInfo.Text.ToString();
     computer2.scannerInfo = TextBoxscInfo.Text.ToString();
     computer2.roomNum = TextBoxroom.Text;
     computer2.department = Enum.GetName(typeof(DLL.BaseCode.BaseCode.department), DropDownListdepartment.SelectedIndex);
     computer2.username = TextBoxuser.Text.ToString();
     computer2.description = TextBoxdescri.Text.ToString();
     computer2.flag = int.Parse(DropDownListflag.SelectedValue);
     computer2.mac = TextBoxMac.Text;
     computer2.addId = int.Parse(Session["Userid"].ToString());
     computer2.updateId = int.Parse(Session["Userid"].ToString());
     try
     {
         computer2.buyTime = Convert.ToDateTime(TextBox1.Text);
     }
     catch
     {
         computer2.buyTime = null;
     }
     try
     {
         computer2.giveTime = Convert.ToDateTime(TextBox2.Text);
     }
     catch
     {
         computer2.giveTime = null;
     }
     new DLL.BLL.computer().Add(computer2);
     Response.Redirect("List_equipment.aspx");
 }
Пример #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DLL.Model.computer GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,defineId,type,brand,version,mac,nettype,innerIP,outerIP,screenInfo,printerInfo,scannerInfo,roomNum,department,username,addId,addtime,updateId,updateTime,description,flag,buyTime,giveTime from computer ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)
            };
            parameters[0].Value = id;

            DLL.Model.computer model = new DLL.Model.computer();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["defineId"] != null && ds.Tables[0].Rows[0]["defineId"].ToString() != "")
                {
                    model.defineId = ds.Tables[0].Rows[0]["defineId"].ToString();
                }
                if (ds.Tables[0].Rows[0]["type"] != null && ds.Tables[0].Rows[0]["type"].ToString() != "")
                {
                    model.type = ds.Tables[0].Rows[0]["type"].ToString();
                }
                if (ds.Tables[0].Rows[0]["brand"] != null && ds.Tables[0].Rows[0]["brand"].ToString() != "")
                {
                    model.brand = ds.Tables[0].Rows[0]["brand"].ToString();
                }
                if (ds.Tables[0].Rows[0]["version"] != null && ds.Tables[0].Rows[0]["version"].ToString() != "")
                {
                    model.version = ds.Tables[0].Rows[0]["version"].ToString();
                }
                if (ds.Tables[0].Rows[0]["mac"] != null && ds.Tables[0].Rows[0]["mac"].ToString() != "")
                {
                    model.mac = ds.Tables[0].Rows[0]["mac"].ToString();
                }
                if (ds.Tables[0].Rows[0]["nettype"] != null && ds.Tables[0].Rows[0]["nettype"].ToString() != "")
                {
                    model.nettype = ds.Tables[0].Rows[0]["nettype"].ToString();
                }
                if (ds.Tables[0].Rows[0]["innerIP"] != null && ds.Tables[0].Rows[0]["innerIP"].ToString() != "")
                {
                    model.innerIP = ds.Tables[0].Rows[0]["innerIP"].ToString();
                }
                if (ds.Tables[0].Rows[0]["outerIP"] != null && ds.Tables[0].Rows[0]["outerIP"].ToString() != "")
                {
                    model.outerIP = ds.Tables[0].Rows[0]["outerIP"].ToString();
                }
                if (ds.Tables[0].Rows[0]["screenInfo"] != null && ds.Tables[0].Rows[0]["screenInfo"].ToString() != "")
                {
                    model.screenInfo = ds.Tables[0].Rows[0]["screenInfo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["printerInfo"] != null && ds.Tables[0].Rows[0]["printerInfo"].ToString() != "")
                {
                    model.printerInfo = ds.Tables[0].Rows[0]["printerInfo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["scannerInfo"] != null && ds.Tables[0].Rows[0]["scannerInfo"].ToString() != "")
                {
                    model.scannerInfo = ds.Tables[0].Rows[0]["scannerInfo"].ToString();
                }
                if (ds.Tables[0].Rows[0]["roomNum"] != null && ds.Tables[0].Rows[0]["roomNum"].ToString() != "")
                {
                    model.roomNum = ds.Tables[0].Rows[0]["roomNum"].ToString();
                }
                if (ds.Tables[0].Rows[0]["department"] != null && ds.Tables[0].Rows[0]["department"].ToString() != "")
                {
                    model.department = ds.Tables[0].Rows[0]["department"].ToString();
                }
                if (ds.Tables[0].Rows[0]["username"] != null && ds.Tables[0].Rows[0]["username"].ToString() != "")
                {
                    model.username = ds.Tables[0].Rows[0]["username"].ToString();
                }
                if (ds.Tables[0].Rows[0]["addId"] != null && ds.Tables[0].Rows[0]["addId"].ToString() != "")
                {
                    model.addId = int.Parse(ds.Tables[0].Rows[0]["addId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["addtime"] != null && ds.Tables[0].Rows[0]["addtime"].ToString() != "")
                {
                    model.addtime = DateTime.Parse(ds.Tables[0].Rows[0]["addtime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["updateId"] != null && ds.Tables[0].Rows[0]["updateId"].ToString() != "")
                {
                    model.updateId = int.Parse(ds.Tables[0].Rows[0]["updateId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["updateTime"] != null && ds.Tables[0].Rows[0]["updateTime"].ToString() != "")
                {
                    model.updateTime = DateTime.Parse(ds.Tables[0].Rows[0]["updateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["description"] != null && ds.Tables[0].Rows[0]["description"].ToString() != "")
                {
                    model.description = ds.Tables[0].Rows[0]["description"].ToString();
                }
                if (ds.Tables[0].Rows[0]["flag"] != null && ds.Tables[0].Rows[0]["flag"].ToString() != "")
                {
                    model.flag = int.Parse(ds.Tables[0].Rows[0]["flag"].ToString());
                }
                if (ds.Tables[0].Rows[0]["buyTime"] != null && ds.Tables[0].Rows[0]["buyTime"].ToString() != "")
                {
                    model.buyTime = DateTime.Parse(ds.Tables[0].Rows[0]["buyTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["giveTime"] != null && ds.Tables[0].Rows[0]["giveTime"].ToString() != "")
                {
                    model.giveTime = DateTime.Parse(ds.Tables[0].Rows[0]["giveTime"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Пример #4
0
 protected void saveButton_Click(object sender, EventArgs e)
 {
     String type = Enum.GetName(typeof(DLL.BaseCode.BaseCode.type), DropDownListtype.SelectedIndex);
     String brand = brandTextBox.Text;
     String version = versionTextBox.Text;
     String description = descTextBox.Text;
     DLL.Model.computer computer = new DLL.Model.computer();
     computer.defineId = "待定";
     computer.type = type;
     computer.brand = brand;
     computer.version = version;
     computer.description = description;
     computer.addId = int.Parse(Session["Userid"].ToString());
     int num = int.Parse(TextBoxnum.Text);
     if (computer.defineId == "")
     {
         computer.defineId = "待定";
     }
     if (computer.nettype == "")
     {
         computer.nettype = "待定";
     }
     if (computer.innerIP == "")
     {
         computer.innerIP = "待定";
     }
     if (computer.outerIP == "")
     {
         computer.outerIP = "待定";
     }
     if (computer.brand == "")
     {
         computer.brand = "待定";
     }
     if (computer.version == "")
     {
         computer.version = "待定";
     }
     if (computer.screenInfo == "")
     {
         computer.screenInfo = "待定";
     }
     if (computer.printerInfo == "")
     {
         computer.printerInfo = "待定";
     }
     if (computer.scannerInfo == "")
     {
         computer.scannerInfo = "待定";
     }
     if (computer.roomNum == "")
     {
         computer.roomNum = "待定";
     }
     if (computer.username == "")
     {
         computer.username = "******";
     }
     if (computer.description == "")
     {
         computer.description = "待定";
     }
     if (computer.mac == "")
     {
         computer.mac = "待定";
     }
     new DLL.BLL.computer().addcomputers(computer,num);
     Response.Redirect("List_equipment.aspx");
 }