示例#1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(zs.Model.Sys_Function model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Sys_Function(");
            strSql.Append("FunctionName,FunctionDescription,Type,Assembly,ValidateDate)");
            strSql.Append(" values (");
            strSql.Append("@FunctionName,@FunctionDescription,@Type,@Assembly,@ValidateDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FunctionName",        SqlDbType.VarChar,  20),
                new SqlParameter("@FunctionDescription", SqlDbType.VarChar, 100),
                new SqlParameter("@Type",                SqlDbType.VarChar,  10),
                new SqlParameter("@Assembly",            SqlDbType.VarChar,  50),
                new SqlParameter("@ValidateDate",        SqlDbType.DateTime)
            };
            parameters[0].Value = model.FunctionName;
            parameters[1].Value = model.FunctionDescription;
            parameters[2].Value = model.Type;
            parameters[3].Value = model.Assembly;
            parameters[4].Value = model.ValidateDate;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#2
0
 private void ShowInfo(int ID)
 {
     zs.BLL.Sys_Function   bll   = new zs.BLL.Sys_Function();
     zs.Model.Sys_Function model = bll.GetModel(ID);
     this.lblID.Text                  = model.ID.ToString();
     this.lblFunctionName.Text        = model.FunctionName;
     this.lblFunctionDescription.Text = model.FunctionDescription;
     this.lblType.Text                = model.Type;
     this.lblAssembly.Text            = model.Assembly;
     this.lblValidateDate.Text        = model.ValidateDate.ToString();
 }
示例#3
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtFunctionName.Text.Trim().Length == 0)
            {
                strErr += "FunctionName不能为空!\\n";
            }
            if (this.txtFunctionDescription.Text.Trim().Length == 0)
            {
                strErr += "FunctionDescription不能为空!\\n";
            }
            if (this.txtType.Text.Trim().Length == 0)
            {
                strErr += "Type不能为空!\\n";
            }
            if (this.txtAssembly.Text.Trim().Length == 0)
            {
                strErr += "Assembly不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtValidateDate.Text))
            {
                strErr += "ValidateDate格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      ID                  = int.Parse(this.lblID.Text);
            string   FunctionName        = this.txtFunctionName.Text;
            string   FunctionDescription = this.txtFunctionDescription.Text;
            string   Type                = this.txtType.Text;
            string   Assembly            = this.txtAssembly.Text;
            DateTime ValidateDate        = DateTime.Parse(this.txtValidateDate.Text);


            zs.Model.Sys_Function model = new zs.Model.Sys_Function();
            model.ID                  = ID;
            model.FunctionName        = FunctionName;
            model.FunctionDescription = FunctionDescription;
            model.Type                = Type;
            model.Assembly            = Assembly;
            model.ValidateDate        = ValidateDate;

            zs.BLL.Sys_Function bll = new zs.BLL.Sys_Function();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public zs.Model.Sys_Function GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,FunctionName,FunctionDescription,Type,Assembly,ValidateDate from Sys_Function ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            zs.Model.Sys_Function model = new zs.Model.Sys_Function();
            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]["FunctionName"] != null && ds.Tables[0].Rows[0]["FunctionName"].ToString() != "")
                {
                    model.FunctionName = ds.Tables[0].Rows[0]["FunctionName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FunctionDescription"] != null && ds.Tables[0].Rows[0]["FunctionDescription"].ToString() != "")
                {
                    model.FunctionDescription = ds.Tables[0].Rows[0]["FunctionDescription"].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]["Assembly"] != null && ds.Tables[0].Rows[0]["Assembly"].ToString() != "")
                {
                    model.Assembly = ds.Tables[0].Rows[0]["Assembly"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ValidateDate"] != null && ds.Tables[0].Rows[0]["ValidateDate"].ToString() != "")
                {
                    model.ValidateDate = DateTime.Parse(ds.Tables[0].Rows[0]["ValidateDate"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(zs.Model.Sys_Function model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Sys_Function set ");
            strSql.Append("FunctionName=@FunctionName,");
            strSql.Append("FunctionDescription=@FunctionDescription,");
            strSql.Append("Type=@Type,");
            strSql.Append("Assembly=@Assembly,");
            strSql.Append("ValidateDate=@ValidateDate");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FunctionName",        SqlDbType.VarChar,    20),
                new SqlParameter("@FunctionDescription", SqlDbType.VarChar,   100),
                new SqlParameter("@Type",                SqlDbType.VarChar,    10),
                new SqlParameter("@Assembly",            SqlDbType.VarChar,    50),
                new SqlParameter("@ValidateDate",        SqlDbType.DateTime),
                new SqlParameter("@ID",                  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.FunctionName;
            parameters[1].Value = model.FunctionDescription;
            parameters[2].Value = model.Type;
            parameters[3].Value = model.Assembly;
            parameters[4].Value = model.ValidateDate;
            parameters[5].Value = model.ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }