/// <summary> /// 查询所有 /// </summary> /// <returns></returns> public List <Model.HardInfo> GetList() { string strSql = ""; strSql = "Select * FROM HardInfo"; List <Model.HardInfo> List = new List <Model.HardInfo>(); SqlParameter[] parameters = { }; using (SqlDataReader DR = ExamSys.ExecuteReader(strSql.ToString(), parameters)) { while (DR.Read()) { Model.HardInfo model = new Model.HardInfo(); model.HostName = DR["HostName"].ToString(); model.CpuID = DR["CpuID"].ToString(); model.HardDiskID = DR["HardDiskID"].ToString(); model.NetCardMAC = DR["NetCardMAC"].ToString(); model.NetCardIP = DR["NetCardIP"].ToString(); model.VolOf = DR["VolOf"].ToString(); List.Add(model); } DR.Close(); DR.Dispose(); } return(List); }
protected void bt_Yes_Click(object sender, EventArgs e) { BLL.HardInfo bll = new BLL.HardInfo(); Model.HardInfo model = new Model.HardInfo(); model.CpuID = lb_CpuID.Text; model.HardDiskID = lb_HardDiskID.Text; model.HostName = lb_HostName.Text; model.NetCardIP = lb_NetCardIP.Text; model.NetCardMAC = lb_NetCardMAC.Text; model.VolOf = lb_VolOf.Text; bll.Add(model); }
/// <summary> /// 更新 /// </summary> /// <param name="model"></param> public void Updata(Model.HardInfo md) { Model.HardInfo model = new Model.HardInfo(); model.HostName = Common.Function.ToASCII(md.HostName); model.CpuID = Common.Function.ToASCII(md.CpuID); model.HardDiskID = Common.Function.ToASCII(md.HardDiskID); model.NetCardIP = Common.Function.ToASCII(md.NetCardIP); model.NetCardMAC = Common.Function.ToASCII(md.NetCardMAC); model.VolOf = Common.Function.ToASCII(md.VolOf); if (dal.Updata(model) > 0) { Common.Function.AlertRedirect("成功!", "/Aspx/Success.htm"); } else { Common.Function.AlertRedirect("失败!", "/Aspx/Failure.htm"); } }
/// <summary> /// 添加 /// </summary> public void Add(Model.HardInfo md) { Model.HardInfo model = new Model.HardInfo(); model.HostName = Common.Function.ToASCII(md.HostName); model.CpuID = Common.Function.ToASCII(md.CpuID); model.HardDiskID = Common.Function.ToASCII(md.HardDiskID); model.NetCardIP = Common.Function.ToASCII(md.NetCardIP); model.NetCardMAC = Common.Function.ToASCII(md.NetCardMAC); model.VolOf = Common.Function.ToASCII(md.VolOf); if (dal.Add(model) > 0) { Common.Function.Redirect("Setup2.aspx"); } else { Common.Function.AlertRedirect("添加失败!系统繁忙请稍后再试!", "/Aspx/Failure.htm"); } }
/// <summary> /// 更新 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Updata(Model.HardInfo model) { int rowsAffected; SqlParameter[] parameters = { new SqlParameter("@ReturnValue", SqlDbType.Int), new SqlParameter("@HostName", SqlDbType.NVarChar, 500), new SqlParameter("@CpuID", SqlDbType.NVarChar, 500), new SqlParameter("@HardDiskID", SqlDbType.NVarChar, 500), new SqlParameter("@NetCardMAC", SqlDbType.NVarChar, 500), new SqlParameter("@VolOf", SqlDbType.NVarChar, 500), new SqlParameter("@NetCardIP", SqlDbType.NVarChar, 500), }; parameters[0].Direction = ParameterDirection.Output; parameters[1].Value = model.HostName; parameters[2].Value = model.CpuID; parameters[3].Value = model.HardDiskID; parameters[4].Value = model.NetCardMAC; parameters[5].Value = model.VolOf; parameters[6].Value = model.NetCardIP; ExamSys.RunProcedure("HardInfo_Updata", parameters, out rowsAffected); return((int)parameters[0].Value); }