コード例 #1
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public bool Update(zlzw.Model.AdminListModel model)
        {
            int rowsAffected = 0;

            SqlParameter[] parameters =
            {
                new SqlParameter("@AdminID",       SqlDbType.Int,               4),
                new SqlParameter("@AdminGUID",     SqlDbType.UniqueIdentifier, 16),
                new SqlParameter("@AdminName",     SqlDbType.NVarChar,         50),
                new SqlParameter("@AdminPassword", SqlDbType.NVarChar,         50),
                new SqlParameter("@IsEnable",      SqlDbType.Int,               4),
                new SqlParameter("@PublishDate",   SqlDbType.DateTime),
                new SqlParameter("@Other01",       SqlDbType.NVarChar,         50),
                new SqlParameter("@Other02",       SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.AdminID;
            parameters[1].Value = model.AdminGUID;
            parameters[2].Value = model.AdminName;
            parameters[3].Value = model.AdminPassword;
            parameters[4].Value = model.IsEnable;
            parameters[5].Value = model.PublishDate;
            parameters[6].Value = model.Other01;
            parameters[7].Value = model.Other02;

            DbHelperSQL.RunProcedure("AdminList_Update", parameters, out rowsAffected);
            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public int Add(zlzw.Model.AdminListModel model)
        {
            int rowsAffected;

            SqlParameter[] parameters =
            {
                new SqlParameter("@AdminID",       SqlDbType.Int,               4),
                new SqlParameter("@AdminGUID",     SqlDbType.UniqueIdentifier, 16),
                new SqlParameter("@AdminName",     SqlDbType.NVarChar,         50),
                new SqlParameter("@AdminPassword", SqlDbType.NVarChar,         50),
                new SqlParameter("@IsEnable",      SqlDbType.Int,               4),
                new SqlParameter("@PublishDate",   SqlDbType.DateTime),
                new SqlParameter("@Other01",       SqlDbType.NVarChar,         50),
                new SqlParameter("@Other02",       SqlDbType.NVarChar, 50)
            };
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value     = Guid.NewGuid();
            parameters[2].Value     = model.AdminName;
            parameters[3].Value     = model.AdminPassword;
            parameters[4].Value     = model.IsEnable;
            parameters[5].Value     = model.PublishDate;
            parameters[6].Value     = model.Other01;
            parameters[7].Value     = model.Other02;

            DbHelperSQL.RunProcedure("AdminList_ADD", parameters, out rowsAffected);
            return((int)parameters[0].Value);
        }
コード例 #3
0
        protected void btnDel_Click(object sender, EventArgs e)
        {
            if (grid1.SelectedRowIndexArray != null && grid1.SelectedRowIndexArray.Length > 0)
            {
                string strSelectID = "0";
                for (int i = 0, count = grid1.SelectedRowIndexArray.Length; i < count; i++)
                {
                    int rowIndex = grid1.SelectedRowIndexArray[i];
                    foreach (object key in grid1.DataKeys[rowIndex])
                    {
                        strSelectID = key.ToString();
                    }
                }
                #region  除逻辑

                zlzw.BLL.AdminListBLL     adminListBLL   = new zlzw.BLL.AdminListBLL();
                zlzw.Model.AdminListModel adminListModel = adminListBLL.GetModel(int.Parse(strSelectID));
                adminListModel.IsEnable = 0;
                adminListBLL.Update(adminListModel);
                AdminList_BindGrid();

                #endregion
            }
            else
            {
                return;
            }
        }
コード例 #4
0
        protected void btnSaveRefresh_Click(object sender, EventArgs e)
        {
            if (Request.QueryString["Type"] == "1")
            {
                //编辑保存
                zlzw.Model.AdminListModel adminListModel = new zlzw.Model.AdminListModel();
                adminListModel.AdminName     = txbAdminName.Text;
                adminListModel.AdminPassword = txbAdminPassword.Text;
                adminListModel.IsEnable      = 1;
                adminListModel.PublishDate   = DateTime.Parse(ViewState["PublishDate"].ToString());
                adminListModel.AdminGUID     = new Guid(ViewState["AdminGUID"].ToString());
                adminListModel.AdminID       = int.Parse(Request.QueryString["value"]);
                zlzw.BLL.AdminListBLL adminListBLL = new zlzw.BLL.AdminListBLL();
                adminListBLL.Update(adminListModel);
            }
            else
            {
                //添加保存

                zlzw.Model.AdminListModel adminListModel = new zlzw.Model.AdminListModel();
                adminListModel.AdminName     = txbAdminName.Text;
                adminListModel.AdminPassword = txbAdminPassword.Text;
                adminListModel.IsEnable      = 1;
                adminListModel.PublishDate   = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
                adminListModel.AdminGUID     = System.Guid.NewGuid();
                zlzw.BLL.AdminListBLL adminListBLL = new zlzw.BLL.AdminListBLL();
                adminListBLL.Add(adminListModel);
            }

            // 2. Close this window and Refresh parent window
            PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
        }
コード例 #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public zlzw.Model.AdminListModel GetModel(int AdminID)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@AdminID", SqlDbType.Int, 4)
            };
            parameters[0].Value = AdminID;

            zlzw.Model.AdminListModel model = new zlzw.Model.AdminListModel();
            DataSet ds = DbHelperSQL.RunProcedure("AdminList_GetModel", parameters, "ds");

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["AdminID"] != null && ds.Tables[0].Rows[0]["AdminID"].ToString() != "")
                {
                    model.AdminID = int.Parse(ds.Tables[0].Rows[0]["AdminID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AdminGUID"] != null && ds.Tables[0].Rows[0]["AdminGUID"].ToString() != "")
                {
                    model.AdminGUID = new Guid(ds.Tables[0].Rows[0]["AdminGUID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AdminName"] != null && ds.Tables[0].Rows[0]["AdminName"].ToString() != "")
                {
                    model.AdminName = ds.Tables[0].Rows[0]["AdminName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["AdminPassword"] != null && ds.Tables[0].Rows[0]["AdminPassword"].ToString() != "")
                {
                    model.AdminPassword = ds.Tables[0].Rows[0]["AdminPassword"].ToString();
                }
                if (ds.Tables[0].Rows[0]["IsEnable"] != null && ds.Tables[0].Rows[0]["IsEnable"].ToString() != "")
                {
                    model.IsEnable = int.Parse(ds.Tables[0].Rows[0]["IsEnable"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PublishDate"] != null && ds.Tables[0].Rows[0]["PublishDate"].ToString() != "")
                {
                    model.PublishDate = DateTime.Parse(ds.Tables[0].Rows[0]["PublishDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Other01"] != null && ds.Tables[0].Rows[0]["Other01"].ToString() != "")
                {
                    model.Other01 = ds.Tables[0].Rows[0]["Other01"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Other02"] != null && ds.Tables[0].Rows[0]["Other02"].ToString() != "")
                {
                    model.Other02 = ds.Tables[0].Rows[0]["Other02"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #6
0
 private void LoadData(string strType)
 {
     if (strType == "1")
     {
         string strID = Request.QueryString["value"];//操作ID
         zlzw.BLL.AdminListBLL     adminListBLL   = new zlzw.BLL.AdminListBLL();
         zlzw.Model.AdminListModel adminListModel = adminListBLL.GetModel(int.Parse(strID));
         txbAdminName.Text        = adminListModel.AdminName;     //用户名称
         txbAdminPassword.Text    = adminListModel.AdminPassword; //用户密码
         ViewState["PublishDate"] = adminListModel.PublishDate.ToString();
         ViewState["AdminGUID"]   = adminListModel.AdminGUID.ToString();
         ToolbarText2.Text        = "编辑一个管理员账号";
     }
     btnClose.OnClientClick = ActiveWindow.GetConfirmHideReference();
 }