コード例 #1
0
        private bool UploadArquivo()
        {
            var q = Request.QueryString["id"];

            if (FileUploadDoc.FileName != "")
            {
                if (!Directory.Exists(@"C:\Users\lcosta\Documents\ArquivosImportados\" + q))
                {
                    Directory.CreateDirectory(@"C:\Users\lcosta\Documents\ArquivosImportados\" + q);
                }

                FileUploadDoc.SaveAs((@"C:\Users\lcosta\Documents\ArquivosImportados\" +
                                      q + @"\" + FileUploadDoc.FileName).ToString());

                Documento doc = new Documento();
                doc.Caminho = @"C:\Users\lcosta\Documents\ArquivosImportados\" +
                              q + @"\" + FileUploadDoc.FileName;
                doc.Tipo        = Tipos_de_arquivo.SelectedItem.ToString();
                doc.IDJogador   = Request.QueryString["id"];
                doc.IDDocumento = Guid.NewGuid().ToString();

                using (var db = new ConexaoDB())
                {
                    db.Documentos.Add(doc);
                    db.SaveChanges();
                    q = Request.QueryString["id"];
                    GridView1.DataSource = db.Documentos.Where(x => x.IDJogador == q).ToList();
                    GridView1.DataBind();
                }

                return(true);
            }
            return(false);
        }
コード例 #2
0
        protected void Btn_docUpload_Click(object sender, EventArgs e)
        {
            con.Open();
            SqlCommand cmd = con.CreateCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "INSERT INTO [uploadDoc] ([filename], [uploaddate], [expiredate], [typefund]) VALUES (N'" + Tb_filename.Text + "', '" + Tb_uploaddate.Text + "','" + Tb_expiredate.Text + "','" + Ddl_inputGroupSelectType.Text + "')";
            cmd.ExecuteNonQuery();
            con.Close();

            FileUploadDoc.SaveAs(Server.MapPath("~/Content/Document/" + FileUploadDoc.FileName));
        }
コード例 #3
0
        //private DataTable CriaDataTable()

        //{
        //    DataTable mDataTable = new DataTable();
        //    DataColumn mDataColumn = new DataColumn();
        //    mDataColumn.DataType = Type.GetType("System.String");
        //    mDataColumn.ColumnName = "NOME";
        //    mDataTable.Columns.Add(mDataColumn);
        //    mDataColumn = new DataColumn();
        //    mDataColumn.DataType = Type.GetType("System.String");
        //    mDataColumn.ColumnName = "Tipo do Arquivo";
        //    mDataTable.Columns.Add(mDataColumn);
        //    return mDataTable;

        //}

        private bool UploadArquivo()
        {
            if (FileUploadDoc.FileName != "")
            {
                using (var db = new ConexaoDB())
                {
                    if (!Directory.Exists(@"C:\Users\lcosta\Documents\ArquivosImportados\" + jogador.ID))
                    {
                        Directory.CreateDirectory(@"C:\Users\lcosta\Documents\ArquivosImportados\" + jogador.ID);
                    }

                    FileUploadDoc.SaveAs((@"C:\Users\lcosta\Documents\ArquivosImportados\" +
                                          jogador.ID + @"\" + FileUploadDoc.FileName).ToString());

                    //List<Documento> newDoc = (List<Documento>)Session["mDocs"];
                    Documento doc = new Documento();
                    doc.IDDocumento = Guid.NewGuid().ToString();
                    doc.Caminho     = @"C:\Users\lcosta\Documents\ArquivosImportados\" +
                                      jogador.ID + @"\" + FileUploadDoc.FileName;
                    doc.Tipo      = Tipos_de_arquivo.SelectedItem.ToString();
                    doc.IDJogador = jogador.ID;
                    //newDoc.Add(doc);
                    //Session["mDocs"] = newDoc;
                    //DataTable dtb = (DataTable)Session["mDatatable"];
                    //DataRow row = dtb.NewRow();
                    //row["NOME"] = FileUploadDoc.FileName;
                    //row["Tipo do Arquivo"] = Tipos_de_arquivo.SelectedItem.ToString();
                    //dtb.Rows.Add(row);
                    //Session["mDatatable"] = dtb;


                    db.Documentos.Add(doc);
                    db.SaveChanges();
                    GridDOC.DataSource = db.Documentos.Where(x => x.IDJogador == jogador.ID).ToList();
                    GridDOC.DataBind();
                }

                return(true);
            }
            return(false);
        }
コード例 #4
0
 protected void btnShare_Click(object sender, EventArgs e)
 {
     if (FileUploadDoc.HasFiles)
     {
         DataRow r = dt.NewRow();
         r[0] = txtId.Text;
         r[1] = txtDesc.Text;
         FileUploadDoc.SaveAs(Server.MapPath("~/Documents/") + "\\" + FileUploadDoc.FileName);
         r[2] = "~/Documents/" + FileUploadDoc.FileName;
         r[3] = DateEnvoie.SelectedDate.ToShortDateString();
         r[4] = txtEtat.Text;
         r[5] = DDLTheme.SelectedValue;
         r[6] = user[0];
         dt.Rows.Add(r);
         SqlCommandBuilder cb = new SqlCommandBuilder(da);
         da.Update(dt);
     }
     else
     {
         Response.Write("<script LANGUAGE='JavaScript' >alert('Selectionee un document')</script>");
     }
 }