Exemplo n.º 1
0
 protected void Button1_Click1(object sender, EventArgs e)
 {
     string carid = a_carID.Value;
     string opname = a_opanme.Value;
     string fs = a_fname.Value;
     string resovle = a_resovle.Value;
     string runre = a_runresovle.Value;
     string dt = Calendar1.Value;
     string[] sy;
     DateTime sd = new DateTime(1900, 1, 1);
     if (!"".Equals(dt))
     {
         sy = dt.Split('-');
         sd = new DateTime(Convert.ToInt32(sy[0]), Convert.ToInt32(sy[1]), Convert.ToInt32(sy[2]));
     }
     DateTime t = sd;
     Busiiness bus = new Busiiness();
     int res= bus.AddRecord(t, carid, opname, fs, resovle, runre);
     Response.Redirect("result.aspx?res"+res);
 }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string cid = carID.Value;
            string s = start.Value;
            string te = tend.Value;
            string k = keyword.Value;
            string p = parts.Value;

            Busiiness bus = new Busiiness();
            List<Operator> op = bus.find(cid, s, te, k, p);

            DataTable ds = listToTable(op);

            NewListView.DataSource = ds;
            NewListView.DataBind();
            //NewListView.ItemCommand += new EventHandler<ListViewCommandEventArgs>(NewListView_ItemCommand);
            //GridView1.DataSource = ds;
            //GridView1.DataBind();
        }
Exemplo n.º 3
0
        protected void btnUpload1_Click(object sender, EventArgs e)
        {
            Label2.Text = "";
            Label2.Visible = false;
            System.Web.HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
            System.Text.StringBuilder strmsg = new System.Text.StringBuilder("");
            //string[] rd = Request.Form[1].Split(',');  //获得图片描述的文本框字符串数组,为对应的图片的描述
            //string albumid = ddlAlbum.SelectedValue.Trim();
            int ifile;
            for (ifile = 0; ifile < files.Count; ifile++)
            {
                if (files[ifile].FileName.Length > 0)
                {
                    System.Web.HttpPostedFile postedfile = files[ifile];
                    if (postedfile.ContentLength / 1024 > 1024)//单个文件不能大于1024k
                    {
                        strmsg.Append(Path.GetFileName(postedfile.FileName) + "---不能大于1024k<br>");
                        break;
                    }
                    string fex = Path.GetExtension(postedfile.FileName);
                    if (fex != ".jpg" && fex != ".JPG" && fex != ".gif" && fex != ".GIF")
                    {
                        strmsg.Append(Path.GetFileName(postedfile.FileName) + "---图片格式不对,只能是jpg或gif<br>");
                        break;
                    }
                }
            }
            if (strmsg.Length <= 0)//说明图片大小和格式都没问题
            {
                //以下为创建图库目录
                string dirname = "pic00";
                string dirpath = Server.MapPath("PicBase");
                dirpath = dirpath + "/" + dirname;
                if (Directory.Exists(dirpath) == false)
                {
                    Directory.CreateDirectory(dirpath);
                }
                Random ro = new Random();
                int name = 1;
                for (int i = 0; i < files.Count; i++)
                {
                    System.Web.HttpPostedFile myFile = files[i];
                    string FileName = "";
                    string FileExtention = "";
                    string PicPath = "";
                    FileName = System.IO.Path.GetFileName(myFile.FileName);
                    string stro = ro.Next(100, 100000000).ToString() + name.ToString();//产生一个随机数用于新命名的图片
                    string NewName = DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + stro;
                    if (FileName.Length > 0)//有文件才执行上传操作再保存到数据库
                    {
                        FileExtention = System.IO.Path.GetExtension(myFile.FileName);

                        string ppath = dirpath + "/" + NewName + FileExtention;
                        myFile.SaveAs(ppath);  //保存到电脑里面将图片
                        string FJname = FileName;
                        PicPath = "PicBase" + "/" + dirname + "/" + NewName + FileExtention;

                        //保存路径到数据库中
                        src = PicPath;
                        sname = FileName;
                        mtype = Request.Params["name"];
                        Busiiness bus = new Busiiness();
                        if (mtype.Equals("EP"))
                        {
                            EP ep = new EP();
                            ep.name = sname;
                            ep.src = src;
                            Busiiness.EP.Add(ep);

                            // bus.InsertImg(src, sname, Const.EP);
                        } if (mtype.Equals("PP"))
                        {
                            //bus.InsertImg(src, sname, Const.PP);
                            PP pp = new PP();
                            pp.name = sname;
                            pp.src = src;
                            Busiiness.PP.Add(pp);
                        } if (mtype.Equals("NP"))
                        {
                            NP np = new NP();
                            np.name = sname;
                            np.src = src;
                            Busiiness.NP.Add(np);
                            //bus.InsertImg(src, sname, Const.NP);
                        }

                    }

                    Response.Write ("成功");

                    //AddPicture(PicPath, rd[i], albumid);//将图片信息保存到数据库
                    //if (name == 1)//如果为每次更新的第一张图片,则将它更新为象册的封面
                    //{
                    //    upFirstimg(albumid, PicPath);
                    //}
                    //name = name + 1;//用来重命名规则的变量

                }

            }
            else
            {
                Label2.Text = strmsg.ToString();
                Label2.Visible = true;

            }
        }