Exemple #1
0
        public 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(txtMark.Text))
            {
                strErr += "Mark格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtClick.Text))
            {
                strErr += "Click格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      ID    = int.Parse(this.lblID.Text);
            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.lblNo.Text);
            int      Mark  = int.Parse(this.txtMark.Text);
            int      Click = int.Parse(this.txtClick.Text);


            Maticsoft.Model.WorksGroup model = new Maticsoft.Model.WorksGroup();
            model.ID    = ID;
            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.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Exemple #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            //保存文件
            string path = "";
            string filepath = "", filename = "";

            if (FileUpload1.HasFile)
            {
                if (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);
                    //生成缩略图
                }
                else
                {
                    label1.Text = "不支持该文件";
                    return;
                }
            }


            //保存数据到数据库
            Maticsoft.BLL.WorksGroup   bll = new Maticsoft.BLL.WorksGroup();
            Maticsoft.Model.WorksGroup model = new Maticsoft.Model.WorksGroup();
            model.ID    = int.Parse(label2.Text);
            model.Title = txtTitle.Text;
            model.Time  = DateTime.Parse(txtTime.Text);
            model.Info  = txtsum.Text;
            model.Mark  = int.Parse(txtMark.Text);
            model.No    = int.Parse(txtNo.Text);
            model.Click = int.Parse(txtClick.Text);
            if (path != "")
            {
                model.Atlas = path;//图片路径
            }
            else
            {
                model.Atlas = Image1.ImageUrl;
            }
            if (bll.Update(model))
            {
                label1.Text = "操作成功";
            }
            else
            {
                label1.Text = "操作失败";
            }
        }