Search This Blog

Saturday, August 11, 2012

MSSQL to FoxPro in ASP.net


In my recent project I need to create a routine that will append the data from sql to dbf foxpro table. Our MSSQL  sql dump. The MS Access script that will append data from sql to foxpro has been in place but what the client wants is that an easy simple UI in asp page. So I end up creating a simple routine in asp.

Our MSSQL Temporary Table

CREATE TABLE [dbo].[temp_table_DownloadFruitCount](
      [frtsiz] [int] NULL,
      [variety] [int] NULL,
      [FrtCnt] [int] NULL,
      [AFW] [float] NULL,
      [TonProc] [float] NULL,
      [Eqtons] [int] NULL,
      [Date] [datetime] NOT NULL
) ON [PRIMARY]

Our Stored Procedure
ALTER PROC [dbo].[FrtCnt_sp_DownloadFruitCount]

@dtdate DATETIME

AS

IF OBJECT_ID('temp_table_DownloadFruitCount') IS NOT NULL DROP TABLE temp_table_DownloadFruitCount

SELECT a.fkfruitsize AS frtsiz,
      a.fkvariety as variety,
      SUM(a.HpineCount)FrtCnt,
      MIN(d.afw) AFW,
      ROUND(SUM(a.TonsProc),2) TonProc,
      MIN(0) AS Eqtons,
      a.dtdate AS [Date]

INTO temp_table_DownloadFruitCount

FROM FrtCnt_Tbl_Trans_FruitCount a
LEFT JOIN CanEffy_Tbl_Ref_FrtSize b ON a.FkFruitSize = b.PkFruitSize
LEFT JOIN FrtCnt_Tbl_Ref_Variety c ON a.fkvariety = c.pkvariety
LEFT JOIN FrtCnt_vw_GetAllAFWByFruitSize d ON a.fkFruitSize = d.fkFruitSize AND
                                                                  a.dtdate = d.dtdate
WHERE a.dtdate = @dtdate
GROUP BY a.dtdate,
       a.FkFruitSize,
       a.fkvariety
ORDER BY
       a.FkFruitSize,
       a.fkvariety

-- FINAL QUERY

SELECT     
      a.frtsiz,
      a.variety,
      SUM(a.FrtCnt)AS FrtCnt,
      MIN(a.afw) AS AFW,
      ROUND(SUM(a.TonProc),2) TonProc,
      MIN(a.Eqtons) AS EqTons,
      a.[Date]
FROM temp_table_DownloadFruitCount a

GROUP BY a.[DATE],
       a.frtsiz,
       a.variety
ORDER BY
       a.frtsiz,
       a.variety
Basically, foxpro table and sql table has the same fieldname and type.  In MS Access this is just easy

Private Sub cmdDownloadFC_Click()
    'Author: Nathaniel Sumaya
    'Purpose: Download FruitCount
    'Date Created: 20120806 1143H
   
    Dim dtdate As Date
    dtdate = InputBox("Please input date")
   
    If IsDate(dtdate) Then

            Dim cmRs As New ADODB.Command
           
            Set cmRs = New ADODB.Command
           
            If ConnectSQL(True, "connectionstring", "catalog") Then
                  
                '----- DELETE
                With cmRs
                    .ActiveConnection = conADO
                    '.CommandText = "sp_Operhr " & dtdate & "," & intYear & _
                                            "," & intPeriodNo & "," & intWeekNo
                    .CommandText = "FrtCnt_sp_DownloadFruitCount '" & dtdate & "'"
                    .Execute
                End With
                '----- END OF DELETE ROUTINE
               
            End If
     Else
       
     End If
    
     'Delete FruitDUM
     DeleteFruitDum
    
     'AppendFruitDum
     AppendFruitDum
    
End Sub

Sub DeleteFruitDum()
    DoCmd.RunSQL ("DELETE FROM FRUITDUM")
End Sub

Sub AppendFruitDum()
    Dim strsql As String
    strsql = "INSERT INTO FRUITDUM SELECT * FROM dbo_temp_table_DownloadFruitCount "
    DoCmd.RunSQL strsql
End Sub

Our Business Object Class

using System;
using System.Collections.Generic;
using System.Linq;

using System.Web;

namespace FrtCnt.BO
{

    /// <summary>
    /// Summary description for FrtCnt_UploadFruitCount
    /// </summary>
    public class FrtCnt_UploadFruitCount
    {
        private int _frtsiz;
        private int _variety;
        private int _frtCnt;
        private double _afw;
        private double _tonsproc;
        private int _eqtons;
        private DateTime _dtdate;

        public FrtCnt_UploadFruitCount()
        {

        }

        public int FrtSize
        {
            get { return _frtsiz; }
            set { _frtsiz = value; }
        }

        public int Variety
        {
            get { return _variety; }
            set { _variety = value; }
        }
        public int FrtCnt
        {
            get { return _frtCnt; }
            set { _frtCnt = value; }
        }

        public double AFW
        {
            get { return _afw; }
            set { _afw = value; }
        }

        public double TonsProc
        {
            get { return _tonsproc; }
            set { _tonsproc = value; }
        }

        public int EqTons
        {
            get { return _eqtons; }
            set { _eqtons = value; }
        }

        public DateTime DtDdate
        {
            get { return _dtdate; }
            set { _dtdate = value; }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Web;

namespace FrtCnt.BO
{

    /// <summary>
    /// Summary description for FrtCnt_UploadFruitCountList
    /// </summary>
    public class FrtCnt_UploadFruitCountList:List<FrtCnt_UploadFruitCount>
    {
        public FrtCnt_UploadFruitCountList()
        {
            //
            // TODO: Add constructor logic here
            //
        }
    }
}

Our Business Logic Layer Class
using System;
using System.ComponentModel;

using FrtCnt.BO;
using FrtCnt.DAL;

namespace FrtCnt.BLL
{
    /// <summary>
    /// Summary description for FrtCnt_UploadFruitCountManager
    /// </summary>
    [DataObjectAttribute()]
    public class FrtCnt_UploadFruitCountManager
    {
        public FrtCnt_UploadFruitCountManager()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        [DataObjectMethod(DataObjectMethodType.Select)]
        public static FrtCnt_UploadFruitCountList GetList(DateTime dtdate)
        {
            return FrtCnt_UploadFruitCountDB.GetList(dtdate); 
        }

        //Display Routine
        [DataObjectMethod(DataObjectMethodType.Select)]
        public static FrtCnt_UploadFruitCountList GetListFromFoxPro(DateTime dtdate)
        {
            return FrtCnt_UploadFruitCountDB.GetListFromFoxPro(dtdate); 
        }
        //routine for Insert
        [DataObjectMethod(DataObjectMethodType.Update | DataObjectMethodType.Insert, true)]
        public static FrtCnt_UploadFruitCountList SaveFruitCountToFoxPro(DateTime dtdate)
        {
            return FrtCnt_UploadFruitCountDB.SaveFruitCountToFoxPro(dtdate);
        }

        //routine for delete
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public static bool Delete(FrtCnt_UploadFruitCount myFruitCount)
        {
            return FrtCnt_UploadFruitCountDB.Delete();
        }

       

    }
}

Our Data Access Layer Class
using System;
using System.Collections.Generic;
using System.Web;
using System.Data.Common;
using System.Data.SqlClient;
using System.Data;
using System.Data.Odbc;

using FrtCnt.BO;
using CanEffy.DAL; //for connectionstring

namespace FrtCnt.DAL
{
    /// <summary>
    /// Summary description for FrtCnt_UploadFruitCountDB
    /// </summary>
    public class FrtCnt_UploadFruitCountDB
    {
        public FrtCnt_UploadFruitCountDB()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        #region PUBLIC METHODS

        public static FrtCnt_UploadFruitCountList GetList(DateTime dtdate)
        {
            FrtCnt_UploadFruitCountList tempList = null;

            using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString3))
            {
                SqlCommand myCommand = new SqlCommand("FrtCnt_sp_GetAllFruitCountBySize", myConnection);
                myCommand.CommandType = CommandType.StoredProcedure;
                myCommand.Parameters.AddWithValue("@dtdate", dtdate);

                myConnection.Open();
                using (SqlDataReader myReader = myCommand.ExecuteReader())
                {
                    if (myReader.HasRows)
                    {
                        tempList = new FrtCnt_UploadFruitCountList();
                        while (myReader.Read())
                        {
                            tempList.Add(FillDataRecord(myReader));
                        }
                        myReader.Close();
                    }
                }
                myConnection.Close();
            }

            return tempList;
        }

        /// <summary>
        /// Get the list from FoxPro Database
        /// </summary>
        /// <param name="dtdate">date of operations</param>
        /// <returns>List of FruitCounts</returns>
        public static FrtCnt_UploadFruitCountList GetListFromFoxPro(DateTime dtdate)
        {
            FrtCnt_UploadFruitCountList tempList = null;
            //using (SqlConnection myConnection = new SqlConnection(AppConfiguration.FoxProConnect))
            using (OdbcConnection myConnection = new OdbcConnection(AppConfiguration.FoxProConnect))
            {
                string strsql = "SELECT * FROM FRUITDUM WHERE DATE =#" + dtdate + "#";  
                OdbcCommand myCommand = new OdbcCommand(strsql , myConnection);
                myCommand.CommandType = CommandType.Text;

                myConnection.Open();
                //using (SqlDataReader myReader = myCommand.ExecuteReader())
                using (OdbcDataReader myReader = myCommand.ExecuteReader())
                {
                    if (myReader.HasRows)
                    {
                        tempList = new FrtCnt_UploadFruitCountList();
                        while (myReader.Read())
                        {
                            tempList.Add(FillDataRecordFoxPro(myReader));
                        }
                        myReader.Close();
                    }
                }
                myConnection.Close();

            }
            return tempList;
        }

        /// <summary>
        /// Delete FruitDum Data
        /// </summary>
        /// <returns></returns>
       
        public static bool Delete()
        {
            int result = 0;
            using (OdbcConnection myConnection = new OdbcConnection(AppConfiguration.FoxProConnect ))
            {
                string strsql = "DELETE FROM FRUITDUM";

                OdbcCommand myCommand = new OdbcCommand(strsql, myConnection);
                myCommand.CommandType = CommandType.Text;

                //open the connection
                myConnection.Open();
                result = myCommand.ExecuteNonQuery();
                myConnection.Close();
            }
            return result > 0;
        }

        public static FrtCnt_UploadFruitCountList SaveFruitCountToFoxPro(DateTime dtdate)
        {
            FrtCnt_UploadFruitCountList fcounts = GetList(dtdate); //new FrtCnt_UploadFruitCountList();

            foreach (FrtCnt_UploadFruitCount fc in fcounts)
            {
                SaveFruitCount(fc.AFW, fc.DtDdate.ToShortDateString(), fc.EqTons, fc.FrtCnt, fc.FrtSize, fc.TonsProc, fc.Variety);      
                //Save(fc);
            }

            return fcounts;
        }

        private static void SaveFruitCount(double afw, string dtdate, double eqtons, int frtCount, int frtSize, double tProc, int frtVariety)
        {
            OdbcConnection con = new OdbcConnection(AppConfiguration.FoxProConnect);

            string sqlinsert = " INSERT INTO FRUITDUM  (AFW, [DATE], EQTONS, FRTCNT, FRTSIZ, TONPROC, VARIETY) VALUES " +
                              " ( "  + afw +",#" + dtdate + "#," + eqtons + "," + frtCount + "," + frtSize + "," + tProc + "," + frtVariety + ")";
            con.Open();

            //OdbcCommand cmd = new OdbcCommand("insert into FruitDum('" + age + "','" + name + "')", con);
            OdbcCommand cmd = new OdbcCommand(sqlinsert, con);
            cmd.ExecuteNonQuery();
            con.Close();

        }

        public static int Save(FrtCnt_UploadFruitCount myFruitCount)
        {

            string strsql = " INSERT INTO FRUITDUM  (AFW, [DATE], EQTONS, FRTCNT, FRTSIZ, TONPROC, VARIETY) values " +
                              " (@afw, @dtdate, @eqtons, @frtCnt, @frtSize, @tonsProc, @variety)";

            int result = 0;
            using (OdbcConnection myConnection = new OdbcConnection(AppConfiguration.FoxProConnect))
            {
                using (OdbcCommand myCommand = new OdbcCommand(strsql, myConnection))
                {
                    myCommand.CommandType = CommandType.Text;

                    //myCommand.Parameters.AddWithValue("@afw", myFruitCount.AFW);
                    //myCommand.Parameters.AddWithValue("@dtdate", myFruitCount.DtDdate);
                    //myCommand.Parameters.AddWithValue("@eqtons", myFruitCount.EqTons);
                    //myCommand.Parameters.AddWithValue("@frtCnt", myFruitCount.FrtCnt);
                    //myCommand.Parameters.AddWithValue("@frtSize", myFruitCount.FrtSize);
                    //myCommand.Parameters.AddWithValue("@tonsProc", myFruitCount.TonsProc);
                    //myCommand.Parameters.AddWithValue("@variety", myFruitCount.Variety);    

                    OdbcParameter p = new OdbcParameter("@afw", SqlDbType.Float);
                    p.Value = myFruitCount.AFW;
                    myCommand.Parameters.Add(p);

                    p = new OdbcParameter("@dtdate", SqlDbType.Date);
                    p.Value = myFruitCount.DtDdate;
                    myCommand.Parameters.Add(p);

                    p = new OdbcParameter("@eqtons", SqlDbType.Int);
                    p.Value = myFruitCount.EqTons;
                    myCommand.Parameters.Add(p);

                    p = new OdbcParameter("@frtCnt", SqlDbType.Int);
                    p.Value = myFruitCount.FrtCnt;
                    myCommand.Parameters.Add(p);

                    p = new OdbcParameter("@frtSize", SqlDbType.Int);
                    p.Value = myFruitCount.FrtSize;
                    myCommand.Parameters.Add(p);

                    p = new OdbcParameter("@tonsProc", SqlDbType.Decimal);
                    p.Value = myFruitCount.TonsProc;
                    myCommand.Parameters.Add(p);

                    p = new OdbcParameter("@variety", SqlDbType.Int);
                    p.Value = myFruitCount.Variety;
                    myCommand.Parameters.Add(p);

                    myConnection.Open();
                    myCommand.ExecuteNonQuery();
                    myConnection.Close();
                }
            }
            return result;
        }

       

        #endregion

        #region PRIVATE METHODS


        /// <summary>
        /// Get Fruit Count Instance
        /// </summary>
        /// <param name="myDataRecord"></param>
        /// <returns>Instance of Fruit Count</returns>
        private static FrtCnt_UploadFruitCount FillDataRecord(IDataRecord myDataRecord)
        {
            FrtCnt_UploadFruitCount uploadedFCount = new FrtCnt_UploadFruitCount();

            //frtsize
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("frtsiz")))
            {
                uploadedFCount.FrtSize = myDataRecord.GetInt32(myDataRecord.GetOrdinal("frtsiz"));
            }

            //variety
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("variety")))
            {
                uploadedFCount.Variety = myDataRecord.GetInt32(myDataRecord.GetOrdinal("variety"));
            }

            //FrtCnt 
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("FrtCnt")))
            {
                uploadedFCount.FrtCnt = myDataRecord.GetInt32(myDataRecord.GetOrdinal("FrtCnt"));
            }

            //AFW
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("afw")))
            {
                uploadedFCount.AFW= myDataRecord.GetDouble(myDataRecord.GetOrdinal("afw"));
            }

            //TonsProc
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("TonProc")))
            {
                uploadedFCount.TonsProc = myDataRecord.GetDouble(myDataRecord.GetOrdinal("TonProc"));
            }

            //Eqtons
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("eqtons")))
            {
                uploadedFCount.EqTons = myDataRecord.GetInt32(myDataRecord.GetOrdinal("eqtons"));
            }

            //date
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("date")))
            {
                uploadedFCount.DtDdate  = myDataRecord.GetDateTime(myDataRecord.GetOrdinal("date"));
            }

            return uploadedFCount;
        }


        private static FrtCnt_UploadFruitCount FillDataRecordFoxPro(IDataRecord myDataRecord)
        {
            FrtCnt_UploadFruitCount uploadedFCount = new FrtCnt_UploadFruitCount();

            //frtsize
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("frtsiz")))
            {
                uploadedFCount.FrtSize = (Int32)myDataRecord.GetDouble(myDataRecord.GetOrdinal("frtsiz"));
            }

            //variety
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("variety")))
            {
                uploadedFCount.Variety = (Int32)myDataRecord.GetDouble(myDataRecord.GetOrdinal("variety"));
            }

            //FrtCnt 
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("FrtCnt")))
            {
                uploadedFCount.FrtCnt = (Int32)myDataRecord.GetDouble(myDataRecord.GetOrdinal("FrtCnt"));
            }

            //AFW
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("afw")))
            {
                uploadedFCount.AFW = myDataRecord.GetDouble(myDataRecord.GetOrdinal("afw"));
            }

            //TonsProc
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("TonProc")))
            {
                uploadedFCount.TonsProc = myDataRecord.GetDouble(myDataRecord.GetOrdinal("TonProc"));
            }

            //Eqtons
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("eqtons")))
            {
                uploadedFCount.EqTons = (Int32)myDataRecord.GetDouble(myDataRecord.GetOrdinal("eqtons"));
            }

            //date
            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("date")))
            {
                uploadedFCount.DtDdate = myDataRecord.GetDateTime(myDataRecord.GetOrdinal("date"));
            }

            return uploadedFCount;
        }
      

        #endregion
    }
}

And Finally Our Application Layer Class
Code Behind
//export gridview data to excel
//http://www.c-sharpcorner.com/UploadFile/DipalChoksi/exportxl_asp2_dc11032006003657AM/exportxl_asp2_dc.aspx?ArticleID=000c64fb-8a22-414a-8247-984335aaa0eb

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.ComponentModel; //added to try some funnctionality

using FrtCnt.BO;  //added to try some funnctionality
using FrtCnt.BLL; // Logic Layer 


using System.Text;
using System.IO;


public partial class CanEffy_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

   
       

    private void ExportGridView1()
    {
        string attachment = "attachment; filename=fruitdum.xls";
        Response.ClearContent();
        Response.AddHeader("content-disposition", attachment);
        Response.ContentType = "application/ms-excel";
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);
        this.gvUpload.RenderControl(htw);
        Response.Write(sw.ToString());
        Response.End();
    }

    public override void VerifyRenderingInServerForm(Control control)
    {

    }

    private void PrepareGridViewForExport(Control gv)
    {
        LinkButton lb = new LinkButton();
        Literal l = new Literal();
        string name = String.Empty;

        for (int i = 0; i < gv.Controls.Count; i++)
        {
            if (gv.Controls[i].GetType() == typeof(LinkButton))
            {
                l.Text = (gv.Controls[i] as LinkButton).Text;
                gv.Controls.Remove(gv.Controls[i]);
                gv.Controls.AddAt(i, l);
            }
            else if (gv.Controls[i].GetType() == typeof(DropDownList))
            {
                l.Text = (gv.Controls[i] as DropDownList).SelectedItem.Text;
                gv.Controls.Remove(gv.Controls[i]);
                gv.Controls.AddAt(i, l);
            }

            else if (gv.Controls[i].GetType() == typeof(TextBox))
            {
                l.Text = (gv.Controls[i] as TextBox).Text;
                gv.Controls.Remove(gv.Controls[i]);
                gv.Controls.AddAt(i, l);
            }

            else if (gv.Controls[i].GetType() == typeof(Label))
            {
                l.Text = (gv.Controls[i] as Label).Text;
                gv.Controls.Remove(gv.Controls[i]);
                gv.Controls.AddAt(i, l);
            }

            else if (gv.Controls[i].GetType() == typeof(CheckBox))
            {
                l.Text = (gv.Controls[i] as CheckBox).Checked ? "True" : "False";
                gv.Controls.Remove(gv.Controls[i]);
                gv.Controls.AddAt(i, l);
            }

            if (gv.Controls[i].HasControls())
            {
                PrepareGridViewForExport(gv.Controls[i]);
            }
        }
    }
        

    protected void btnExport_Click1(object sender, EventArgs e)
    {
        PrepareGridViewForExport(this.gvUpload);
        ExportGridView1();
    }

    #region UPLOADFRUITCOUNT

    //added to try some funnctionality
    private static FrtCnt_UploadFruitCountList GetFruitCount(DateTime dtdate)
    {
        FrtCnt_UploadFruitCountList fruitcounts = new FrtCnt_UploadFruitCountList();
        fruitcounts = FrtCnt.BLL.FrtCnt_UploadFruitCountManager.GetListFromFoxPro(dtdate);
        return fruitcounts;
    }

    //added to try some funnctionality
    protected void btnDownload_Click(object sender, EventArgs e)
    {
        //delete all fruitdum
        FrtCnt_UploadFruitCount myFruitCount = new FrtCnt_UploadFruitCount();

        bool del = FrtCnt_UploadFruitCountManager.Delete(myFruitCount);

        //display the fruitdum based on date selected by the user

        //gvUpload.DataSource = null;
        if (this.TextBoxDateStart.Text != null || this.TextBoxDateStart.Text != "")
        {
            //Save to FoxPro Database
            FrtCnt_UploadFruitCountList myFcList = FrtCnt_UploadFruitCountManager.SaveFruitCountToFoxPro(Convert.ToDateTime(this.TextBoxDateStart.Text));
           
            //Display the fruitCount
            FrtCnt_UploadFruitCountList myfruitCount = GetFruitCount(Convert.ToDateTime(this.TextBoxDateStart.Text));
            this.gvFCount.DataSource = myfruitCount;
            gvFCount.DataBind();
           
        }

       
    }

    #endregion
}

ASP Page
<%@ Page Title="" Language="C#" MasterPageFile="~/CanEffy/MasterPage.master" AutoEventWireup="true" EnableEventValidation ="false" CodeFile="FrtCnt_UploadFruitCount.aspx.cs" Inherits="CanEffy_Default" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="maincontent" Runat="Server">
    <div id = "grosscanreport">
        <asp:ToolkitScriptManager ID ="tksmFruitSizeDistribution" runat ="server"></asp:ToolkitScriptManager>
        <table>
            <tr>
                <td class ="Label" style="width: 107px; height: 25px;">Date of Operation</td>
                <td style="height: 18px; width: 82px;">
                    <asp:TextBox ID="TextBoxDateStart" runat="server" Width="83px"
                     ToolTip="Date Start" TextMode ="SingleLine" AutoPostBack ="true" ></asp:TextBox>
                    <asp:CalendarExtender ID="TextBoxDateStart_CalendarExtender" runat="server"
                        Enabled="True" TargetControlID="TextBoxDateStart">
                    </asp:CalendarExtender>
                </td>
                <td style="height:18px">
                <a href="javascript:OpenPopupPage('Calendar.aspx','<%= TextBoxDateStart.ClientID %>','<%= Page.IsPostBack %>');">
                        <img src="images/icon-calendar.gif" border="0" align="absBottom" width="24" height="16"></a>
                        <asp:CompareValidator id="cvDateStart" runat="server" Display="Dynamic" ErrorMessage="Date format is incorrect." ControlToValidate="TextBoxDateStart" Operator="DataTypeCheck" Type="Date">
                </asp:CompareValidator>
               </td>
            </tr>
        </table>
       
        <asp:Button ID = "btnExport" Text ="Upload" runat ="server"
            onclick="btnExport_Click1" />
       
        <asp:Button ID = "btnDownload" Text = "Download" runat ="server"
            onclick="btnDownload_Click" />

        <br />
       
        <asp:GridView ID = "gvUpload" runat ="server" AutoGenerateColumns="False"
            DataSourceID="odsUpload">
            <Columns>
                <asp:BoundField DataField="FrtSize" HeaderText="FrtSize"
                    SortExpression="FrtSize" >
                <ItemStyle HorizontalAlign="Right" />
                </asp:BoundField>
                <asp:BoundField DataField="Variety" HeaderText="Variety"
                    SortExpression="Variety" >
                <ItemStyle HorizontalAlign="Right" />
                </asp:BoundField>
                <asp:BoundField DataField="FrtCnt" HeaderText="FrtCnt"
                    SortExpression="FrtCnt" >
                <ItemStyle HorizontalAlign="Right" />
                </asp:BoundField>
                <asp:BoundField DataField="AFW" HeaderText="AFW" SortExpression="AFW" >
                <ItemStyle HorizontalAlign="Right" />
                </asp:BoundField>
                <asp:BoundField DataField="TonsProc" HeaderText="TonsProc"
                    SortExpression="TonsProc" >
                <ItemStyle HorizontalAlign="Right" />
                </asp:BoundField>
                <asp:BoundField DataField="EqTons" HeaderText="EqTons"
                    SortExpression="EqTons" />
                <asp:BoundField DataField="DtDdate" HeaderText="Date"
                    SortExpression="DtDdate" DataFormatString="{0:d}" />
            </Columns>
        </asp:GridView>
        
         <br />

         <asp:GridView ID = "gvFCount" runat ="server" ></asp:GridView>
       
        <asp:ObjectDataSource ID="odsUpload" runat="server"
            OldValuesParameterFormatString="original_{0}" SelectMethod="GetList"
            TypeName="FrtCnt.BLL.FrtCnt_UploadFruitCountManager">
            <SelectParameters>
                <asp:ControlParameter ControlID="TextBoxDateStart" DefaultValue="4/12/2010"
                    Name="dtdate" PropertyName="Text" Type="DateTime" />
            </SelectParameters>
        </asp:ObjectDataSource>
        
       
    </div>

</asp:Content>



No comments:

Post a Comment