Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //���ؿؼ�
            SSystemConfigBB systemConfigBB = new SSystemConfigBB();
            SSystemConfigData systemConfigData = new SSystemConfigData();
            try
            {
                systemConfigData = systemConfigBB.GetModel();

                if (systemConfigData != null)
                {
                    this.State = "2";
                    this.ShowInfo(systemConfigData);
                }
                else
                {
                    this.State = "1";
                }
            }
            finally
            {
                systemConfigBB.Dispose();
            }
        }
    }
Exemplo n.º 2
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     SSystemConfigData model = new SSystemConfigData();
     SSystemConfigBB systemConfigBB = new SSystemConfigBB();
     try
     {
         if (this.State == "1")
         {
             this.SetModel(ref model);
             model.updtDt = DateTime.Now.ToString();
             model.updtEmpId = this.currentUser.empId;
             systemConfigBB.AddRecord(model);
             this.State = "2";
         }
         else if (this.State == "2")
         {
             model = systemConfigBB.GetModel();
             this.SetModel(ref model);
             model.updtDt = DateTime.Now.ToString();
             model.updtEmpId = this.currentUser.empId;
             systemConfigBB.ModifyRecord(model);
         }
     }
     catch (Exception ex)
     {
         this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
         return;
     }
     finally
     {
         systemConfigBB.Dispose();
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(SSystemConfigData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into SSystemConfig(");
            strSql.Append("maxUpFileSize,pageRefreshMinites,updtEmpId,updtDt)");
            strSql.Append(" values (");
            strSql.Append("@maxUpFileSize,@pageRefreshMinites,@updtEmpId,@updtDt)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@maxUpFileSize", SqlDbType.Int),
                    new SqlParameter("@pageRefreshMinites", SqlDbType.Float),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime)
                };
            parameters[0].Value = model.maxUpFileSize;
            parameters[1].Value = model.pageRefreshMinites;
            parameters[2].Value = model.updtEmpId;
            parameters[3].Value = model.updtDt == string.Empty ? null : model.updtDt;

            int id = 0;
            try
            {
                object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

                if (ret != null && ret != DBNull.Value)
                {
                    id = Convert.ToInt32(ret);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return id;
        }
Exemplo n.º 4
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(SSystemConfigData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update SSystemConfig set ");
            strSql.Append("maxUpFileSize=@maxUpFileSize,");
            strSql.Append("pageRefreshMinites=@pageRefreshMinites,");
            strSql.Append("updtEmpId=@updtEmpId,");
            strSql.Append("updtDt=@updtDt");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@maxUpFileSize", SqlDbType.Int),
                    new SqlParameter("@pageRefreshMinites", SqlDbType.Float),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.maxUpFileSize;
            parameters[2].Value = model.pageRefreshMinites;
            parameters[3].Value = model.updtEmpId;
            parameters[4].Value = model.updtDt == string.Empty ? null : model.updtDt;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
Exemplo n.º 5
0
        /// <summary>
        /// �õ�һ��model
        /// </summary>
        /// <param name="id">����ֵ</param>
        /// <returns>model</returns>
        public SSystemConfigData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from SSystemConfig");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            SSystemConfigData model = new SSystemConfigData();
            DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (row["id"] != DBNull.Value)
                {
                    model.id = Convert.ToInt32(row["id"]);
                }
                if (row["maxUpFileSize"] != DBNull.Value)
                {
                    model.maxUpFileSize = Convert.ToInt32(row["maxUpFileSize"]);
                }
                if (row["pageRefreshMinites"] != DBNull.Value)
                {
                    model.pageRefreshMinites = Convert.ToDouble(row["pageRefreshMinites"]);
                }
                if (row["updtEmpId"] != DBNull.Value)
                {
                    model.updtEmpId = Convert.ToInt32(row["updtEmpId"]);
                }
                if (row["updtDt"] != DBNull.Value)
                {
                    model.updtDt = Convert.ToString(row["updtDt"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(SSystemConfigData model)
 {
     return this.systemConfigDB.ModifyRecord(model);
 }
Exemplo n.º 7
0
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(SSystemConfigData model)
 {
     return this.systemConfigDB.AddRecord(model);
 }
Exemplo n.º 8
0
 private void SetModel(ref SSystemConfigData model)
 {
     if (this.maxUpFileSize.Text != "")
     {
         model.maxUpFileSize = Convert.ToInt32(this.maxUpFileSize.Text);
     }
     else
     {
         model.maxUpFileSize = 0;
     }
     if (this.pageRefreshMinites.Text != "")
     {
         model.pageRefreshMinites = Convert.ToDouble(this.pageRefreshMinites.Text);
     }
     else
     {
         model.pageRefreshMinites = 0;
     }
 }
Exemplo n.º 9
0
 private void ShowInfo(SSystemConfigData model)
 {
     this.maxUpFileSize.Text = model.maxUpFileSize.ToString();
     this.pageRefreshMinites.Text = model.pageRefreshMinites.ToString();
 }