Exemple #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtTitle.Text.Trim().Length == 0)
            {
                strErr += "组名不能为空!\\n";
            }
            if (this.txtAtlas.Text.Trim().Length == 0)
            {
                strErr += "Atlas不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtTime.Text))
            {
                strErr += "Time格式错误!\\n";
            }
            if (this.txtInfo.Text.Trim().Length == 0)
            {
                strErr += "Info不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtNo.Text))
            {
                strErr += "No格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtMark.Text))
            {
                strErr += "Mark格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtClick.Text))
            {
                strErr += "Click格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string   Title = this.txtTitle.Text;
            string   Atlas = this.txtAtlas.Text;
            DateTime Time  = DateTime.Parse(this.txtTime.Text);
            string   Info  = this.txtInfo.Text;
            int      No    = int.Parse(this.txtNo.Text);
            int      Mark  = int.Parse(this.txtMark.Text);
            int      Click = int.Parse(this.txtClick.Text);

            Maticsoft.Model.WorksGroup model = new Maticsoft.Model.WorksGroup();
            model.Title = Title;
            model.Atlas = Atlas;
            model.Time  = Time;
            model.Info  = Info;
            model.No    = No;
            model.Mark  = Mark;
            model.Click = Click;

            Maticsoft.BLL.WorksGroup bll = new Maticsoft.BLL.WorksGroup();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Exemple #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            //保存文件
            string path = "";
            string filepath = "", filename = "";

            if (FileUpload1.HasFile || Maticsoft.Common.FileUp.IsImg(FileUpload1.FileName))
            {
                filepath = Maticsoft.Common.FileUp.GetUploadPath("/Upload/Works");
                filename = Maticsoft.Common.FileUp.GetRandomName();
                path     = Maticsoft.Common.FileUp.uploadfile(FileUpload1.PostedFile, filepath, filename);
                // 生成缩略图
                string bigPath = Server.MapPath("~/") + filepath + "big_" + filename + System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
                Maticsoft.Common.CutImage.CutImg(Server.MapPath("~/") + path, bigPath, 896, 650, "h");
                string miniPath = Server.MapPath("~/") + filepath + "mini_" + filename + System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
                Maticsoft.Common.CutImage.CutImg(Server.MapPath("~/") + path, miniPath, 100, 75, "h");
                string wPath = Server.MapPath("~/") + filepath + "w_" + filename + System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
                Maticsoft.Common.CutImage.CutImg(Server.MapPath("~/") + path, wPath, 100, 86, "CUT");
            }
            else
            {
                label1.Text = "没有文件,或不支持文件";
                return;
            }
            //保存数据到数据库
            Maticsoft.BLL.WorksGroup   bll = new Maticsoft.BLL.WorksGroup();
            Maticsoft.Model.WorksGroup model = new Maticsoft.Model.WorksGroup();
            model.Title = txtTitle.Text;
            model.Info  = txtsum.Text;
            model.Mark  = int.Parse(txtMark.Text);
            model.No    = bll.GetMaxId();
            model.Atlas = path;//图片路径


            if (bll.Add(model) == 0)
            {
                label1.Text = "插入失败";
            }
            label1.Text = "操作成功";
        }