Exemplo n.º 1
0
    public void bind()
    {
        DB            db  = new DB();
        SqlConnection con = new SqlConnection();

        con = db.GetCon();
        string         str = "select jobskyer.jobskyerID,jobskyer.jobName,myDutyTime.dutyInTime,myDutyTime.dutyOutTime,myDutyTime.flag0,myDutyTime.flag1 from jobskyer,myDutyTime where jobskyer.jobskyerID=myDutyTime.jobskyerID";
        SqlCommand     com = new SqlCommand(str, con);
        SqlDataAdapter da  = new SqlDataAdapter(com);
        DataSet        ds  = new DataSet();

        da.Fill(ds);
        int k = ds.Tables[0].Rows.Count;

        for (int i = 0; i < k; i++)
        {
            string        tojobskyerID = ds.Tables[0].Rows[i]["toJobskyerID"].ToString();
            string        select       = "SELECT jobName FROM JOBSKYER WHERE jobskyerID='" + tojobskyerID + "'";
            DB            db1          = new DB();
            SqlConnection con1         = new SqlConnection();
            con1 = db1.GetCon();
            string         str1 = "select jobName from jobskyer where jobskyerID='" + tojobskyerID + "'";
            SqlCommand     com1 = new SqlCommand(str1, con1);
            SqlDataAdapter da1  = new SqlDataAdapter(com1);
            DataSet        ds1  = new DataSet();
            da1.Fill(ds1);
            string jobname = ds1.Tables[0].Rows[0]["jobName"].ToString();
            ds.Tables[0].Rows[i]["jobName"] = jobname;
            if (i == k)
            {
                com1.Dispose();
                con1.Close();
            }
        }
        try
        {
            DutyRecordGridView.DataSource   = ds;
            DutyRecordGridView.DataKeyNames = new string[] { "jobskyerID" };
            DutyRecordGridView.DataBind();
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
        finally
        {
            com.Dispose();
            con.Close();
        }
    }
Exemplo n.º 2
0
 private void Export(string FileType, string FileName)
 {
     try
     {
         Response.Charset         = "GB2312";
         Response.ContentEncoding = System.Text.Encoding.UTF7;
         Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
         Response.ContentType = FileType;
         this.EnableViewState = false;
         FileStream     fs = new FileStream("~/", FileMode.Open);
         StreamWriter   tw = new StreamWriter(fs);
         HtmlTextWriter hw = new HtmlTextWriter(tw);
         DutyRecordGridView.RenderControl(hw);
         Response.Write(tw.ToString());
         Response.End();
     }
     catch (Exception ex)
     {
         Response.Write(ex.Message);
     }
 }
Exemplo n.º 3
0
 protected void FromExcel_Click(object sender, EventArgs e)
 {
     DutyRecordGridView.DataSource = CreateDataSource();
     DutyRecordGridView.DataBind();
 }