Esempio n. 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     Hownet.Model.AccessList modAL;
     dtList.AcceptChanges();
     for (int i = 0; i < dtList.Rows.Count; i++)
     {
         if (Convert.ToBoolean(dtList.Rows[i]["IsSelect"]))
         {
             if (dtList.Rows[i]["ID"].ToString() == "")
             {
                 modAL                = new Hownet.Model.AccessList();
                 modAL.A              = 1;
                 modAL.AccessID       = _AccessID;
                 modAL.EmployeeID     = Convert.ToInt32(dtList.Rows[i]["EmployeeID"]);
                 modAL.ID             = 0;
                 modAL.Remark         = dtList.Rows[i]["Remark"].ToString();
                 modAL.PassWord       = dtList.Rows[i]["PassWord"].ToString();
                 dtList.Rows[i]["ID"] = bllAL.Add(modAL);
             }
         }
         else
         {
             if (dtList.Rows[i]["ID"].ToString() != "")
             {
                 bllAL.Delete(Convert.ToInt32(dtList.Rows[i]["ID"]));
             }
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Hownet.Model.AccessList model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into AccessList(");
            strSql.Append("AccessID,EmployeeID,PassWord,Remark)");
            strSql.Append(" values (");
            strSql.Append("@AccessID,@EmployeeID,@PassWord,@Remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AccessID",   SqlDbType.Int,       4),
                new SqlParameter("@EmployeeID", SqlDbType.Int,       4),
                new SqlParameter("@PassWord",   SqlDbType.NVarChar, 50),
                new SqlParameter("@Remark",     SqlDbType.NVarChar, 4000)
            };
            parameters[0].Value = model.AccessID;
            parameters[1].Value = model.EmployeeID;
            parameters[2].Value = model.PassWord;
            parameters[3].Value = model.Remark;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Hownet.Model.AccessList model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update AccessList set ");
            strSql.Append("AccessID=@AccessID,");
            strSql.Append("EmployeeID=@EmployeeID,");
            strSql.Append("PassWord=@PassWord,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",         SqlDbType.Int,       4),
                new SqlParameter("@AccessID",   SqlDbType.Int,       4),
                new SqlParameter("@EmployeeID", SqlDbType.Int,       4),
                new SqlParameter("@PassWord",   SqlDbType.NVarChar, 50),
                new SqlParameter("@Remark",     SqlDbType.NVarChar, 4000)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.AccessID;
            parameters[2].Value = model.EmployeeID;
            parameters[3].Value = model.PassWord;
            parameters[4].Value = model.Remark;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Hownet.Model.AccessList GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,AccessID,EmployeeID,PassWord,Remark from AccessList ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            Hownet.Model.AccessList model = new Hownet.Model.AccessList();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AccessID"].ToString() != "")
                {
                    model.AccessID = int.Parse(ds.Tables[0].Rows[0]["AccessID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["EmployeeID"].ToString() != "")
                {
                    model.EmployeeID = int.Parse(ds.Tables[0].Rows[0]["EmployeeID"].ToString());
                }
                model.PassWord = ds.Tables[0].Rows[0]["PassWord"].ToString();
                model.Remark   = ds.Tables[0].Rows[0]["Remark"].ToString();
                model.A        = 1;
                return(model);
            }
            else
            {
                return(null);
            }
        }