Ejemplo n.º 1
0
        /// <summary>
        /// 按钮事件:提交信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //验证重复
            if (id <= 0 && DB.getDataTable("select * from FenLei where FenLeiName='" + FenLeiName.Text.Trim() + "'").Rows.Count > 0)
            {
                JavaScriptHelper.Error(this, "已存在");
                return;
            }

            StringBuilder strSql = new StringBuilder();

            if (id <= 0)//添加
            {
                strSql.Append("insert into FenLei(");
                strSql.Append("FenLeiName");
                strSql.Append(") values (");
                strSql.Append("'" + FenLeiName.Text + "'");
                strSql.Append(") ");
            }
            else//修改
            {
                strSql.Append("update FenLei set ");

                strSql.Append(" FenLeiName = '" + FenLeiName.Text.Trim() + "'");
                strSql.Append(" where Id= " + id);
            }
            DB.ExecuteSql(strSql.ToString());


            JavaScriptHelper.Success(this, "保存成功", "FenLeiManage.aspx");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 按钮事件:提交信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(Server.MapPath(folder)))
            {
                Directory.CreateDirectory(Server.MapPath(folder));
            }

            string bakpath = folder + "db_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".bak";

            DB.ExecuteSql("backup database " + dbname + " to disk='" + Server.MapPath(bakpath) + "'");


            JavaScriptHelper.Success(this, "备份成功", Request.Url.AbsoluteUri);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 按钮事件:提交信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //验证重复
            if (id <= 0 && DB.getDataTable("select * from News where Title='" + Title.Text.Trim() + "'").Rows.Count > 0)
            {
                JavaScriptHelper.Error(this, "已存在");
                return;
            }

            StringBuilder strSql = new StringBuilder();
            string simg = string.Empty;

            if (id <= 0)//添加
            {
                if (FileUpload1.HasFile)
                {
                    simg = Common.UploadImg(FileUpload1, this.Page, "false");
                    if (simg == "false")
                        return;
                }

                strSql.Append("insert into News(");
                strSql.Append("Title,TypeId,TypeName,Content,AddTime,Hits,simg");
                strSql.Append(") values (");
                strSql.Append("'" + Title.Text + "','" + NewsType.SelectedValue + "','" + NewsType.SelectedItem.Text + "','" + Common.ConvertHtmlToString(Content.Text) + "',getdate(),123,'" + simg + "'");
                strSql.Append(") ");
            }
            else//修改
            {
                if (FileUpload1.HasFile)
                    simg = Common.UploadImg(FileUpload1, this.Page, "false");
                else
                    simg = Image1.ImageUrl;

                strSql.Append("update News set ");

                strSql.Append(" Title = '" + Title.Text.Trim() + "'");
                strSql.Append(" ,TypeId = '" + NewsType.SelectedValue + "'");
                strSql.Append(" ,TypeName = '" + NewsType.SelectedItem.Text + "'");
                strSql.Append(" ,Content = '" + Common.ConvertHtmlToString(Content.Text) + "'");
                strSql.Append(" ,simg = '" + simg + "'");

                strSql.Append(" where Id= " + id);
            }
            DB.ExecuteSql(strSql.ToString());

            JavaScriptHelper.Success(this, "保存成功", "NewsManage.aspx");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 按钮事件:提交信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Manager set ");

            strSql.Append(" Tel = '" + Tel.Text.Trim() + "',");
            strSql.Append(" ManagerName = '" + ManagerName.Text.Trim() + "',");
            strSql.Append(" Email = '" + Email.Text.Trim() + "',");
            strSql.Append(" Title = '" + Title.Text.Trim() + "'");

            strSql.Append(" where Id= " + id);
            DB.ExecuteSql(strSql.ToString());


            JavaScriptHelper.Success(this, "保存成功");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 按钮事件:提交信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //验证重复
            if (id <= 0 && DB.getDataTable("select * from Manager where ManagerName='" + ManagerName.Text.Trim() + "'").Rows.Count > 0)
            {
                JavaScriptHelper.Error(this, "此 帐号 已存在");
                return;
            }

            StringBuilder strSql = new StringBuilder();

            if (id <= 0)//添加
            {
                strSql.Append("insert into Manager(");
                strSql.Append("Tel,ManagerPwd,ManagerName,Email,Title,RegTime,LoginCount,Grade");
                strSql.Append(") values (");
                strSql.Append("'" + Tel.Text + "','" + ManagerPwd.Text + "','" + ManagerName.Text + "','" + Email.Text + "','" + Title.Text + "',getdate(),0,2");
                strSql.Append(") ");
            }
            else//修改
            {
                strSql.Append("update Manager set ");

                strSql.Append(" Tel = '" + Tel.Text.Trim() + "',");
                strSql.Append(" ManagerPwd = '" + ManagerPwd.Text.Trim() + "',");
                strSql.Append(" ManagerName = '" + ManagerName.Text.Trim() + "',");
                strSql.Append(" Email = '" + Email.Text.Trim() + "',");
                strSql.Append(" Title = '" + Title.Text.Trim() + "'");

                strSql.Append(" where Id= " + id);
            }
            DB.ExecuteSql(strSql.ToString());


            JavaScriptHelper.Success(this, "保存成功", "ManagerManage.aspx");
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 按钮事件:提交信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string fileSize = reName.Text;

            Regex reg  = new Regex("^(-?[0-9]+)(.[0-9]{1,10})?$", RegexOptions.IgnoreCase);
            var   size = fileSize.ToUpper().Remove(fileSize.Length - 2);


            if (!(fileSize.ToUpper().EndsWith("KB") ||
                  fileSize.ToUpper().EndsWith("MB") ||
                  fileSize.ToUpper().EndsWith("GB")) ||
                !reg.IsMatch(size))
            {
                reName.Focus();
                JavaScriptHelper.Error(this, "文件大小的格式应为:KB/MB/GB");
                return;
            }

            //验证重复
            if (id <= 0 && DB.getDataTable("select * from Product where ProductName='" + ProductName.Text.Trim() + "'").Rows.Count > 0)
            {
                ProductName.Focus();
                JavaScriptHelper.Error(this, "已存在");
                return;
            }

            StringBuilder strSql = new StringBuilder();
            string        simg   = string.Empty;

            if (id <= 0)//添加
            {
                simg = Common.UploadFile(FileUpload1, this.Page, "false");
                if (simg == "false")
                {
                    return;
                }

                strSql.Append("insert into Product(");
                strSql.Append("ProductName,FenLeiId,FenLeiName,Content,AddTime,Hits,reName,FileType,sImg,State,UserId,UserName,zanNum,IsTJ");
                strSql.Append(") values (");
                strSql.Append("'" + ProductName.Text + "','" + FenLei.SelectedValue + "','" + FenLei.SelectedItem.Text + "','" + Common.ConvertHtmlToString(Content.Text) + "',getdate(),0");
                strSql.Append(",'" + reName.Text + "','" + FileType.SelectedValue + "','" + simg + "','" + State.SelectedValue + "','" + mbId + "','" + mbTrueName + "',0,'" + IsTJ.SelectedValue + "') ");
            }
            else//修改
            {
                if (FileUpload1.HasFile)
                {
                    simg = Common.UploadFile(FileUpload1, this.Page, "false");
                }
                else
                {
                    simg = ltlPath.Text;
                }

                strSql.Append("update Product set ");

                strSql.Append(" ProductName = '" + ProductName.Text.Trim() + "'");
                strSql.Append(" ,FenLeiId = '" + FenLei.SelectedValue + "'");
                strSql.Append(" ,FenLeiName = '" + FenLei.SelectedItem.Text + "'");
                strSql.Append(" ,Content = '" + Common.ConvertHtmlToString(Content.Text) + "'");
                strSql.Append(" ,reName = '" + reName.Text + "'");
                strSql.Append(" ,FileType = '" + FileType.SelectedValue + "'");
                strSql.Append(" ,simg = '" + simg + "'");
                strSql.Append(" ,State = '" + State.SelectedValue + "'");
                strSql.Append(" ,IsTJ = '" + IsTJ.SelectedValue + "'");

                strSql.Append(" where Id= " + id);
            }
            DB.ExecuteSql(strSql.ToString());

            JavaScriptHelper.Success(this, "保存成功", "ProductManage.aspx");
        }