Ejemplo n.º 1
0
 private void BindGrid()
 {
     SqlCommand cmd = new SqlCommand("select * from tblUser", con);
     SqlDataAdapter da = new SqlDataAdapter(cmd);
     DataTable dt = new DataTable();
     da.Fill(dt);
     if (dt.Rows.Count > 0)
     {
         for (int i = 0; i < dt.Columns.Count; i++)
         {
             if (i == 0)
             {
                 HyperLinkField b = new HyperLinkField();
                 b.HeaderText = dt.Columns[i].ColumnName;
                 b.DataTextField = dt.Columns[i].ColumnName;
                 b.DataNavigateUrlFormatString = "Default.aspx?Id={0}";
                 b.DataNavigateUrlFields = new string[] { dt.Columns[i].ColumnName };
                 b.Target = "_blank";
                 GridView1.Columns.Add(b);
             }
             else
             {
                 BoundField b = new BoundField();
                 b.HeaderText = dt.Columns[i].ColumnName;
                 b.DataField = dt.Columns[i].ColumnName;
                 GridView1.Columns.Add(b);
             }
         }
         GridView1.DataSource = dt;
         GridView1.DataBind();
     }
 }
    protected void bindDataByDate(GridView gv)
    {
        DataSet ds = getBookingsDataThisyear(getSegmentID(), getSalesOrgID());
        if (ds != null)
        {
            gv.Width = Unit.Pixel(300);
            gv.AutoGenerateColumns = false;
            gv.AllowPaging = false;
            gv.Visible = true;

            //Calculate the VAR column and Total row of next year.
            try
            {
                ds.Tables[0].Columns.Add("VAR");
                if (ds.Tables[0].Rows[0][0] != DBNull.Value)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        float tmp = 0;
                        if (float.Parse(dr[2].ToString()) != 0)
                        {
                            tmp = (float.Parse(dr[1].ToString()) - float.Parse(dr[2].ToString())) * 100 / float.Parse(dr[2].ToString());
                            dr["VAR"] = Convert.ToInt32(tmp).ToString() + "%";
                        }
                    }
                }
            }
            catch
            {
                log.WriteLog(LogUtility.LogErrorLevel.LOG_ERROR, "Format string to float Error.");
                Response.Redirect("~/Executive/ExecutiveError.aspx");
            }

            for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            {
                BoundField bf = new BoundField();

                bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString();
                bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString();
                bf.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
                if (i == 0)
                {
                    bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                    bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
                }
                bf.ReadOnly = true;
                gv.Columns.Add(bf);
            }

            gv.Caption = "Total(" + year.Substring(2, 2) + ")";
            gv.CaptionAlign = TableCaptionAlign.Top;
            gv.AllowSorting = true;
            gv.DataSource = ds.Tables[0];
            gv.DataBind();
        }
        else
            gv.Visible = false;
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Use for displaying out a data table by gridview 
    /// </summary>
    /// <param name="gridview"></param>
    /// <param name="str_caption">caption of gridview</param>
    /// <param name="ds">DataSet</param>
    protected void bindDataSource(GridView gridview, string str_caption, DataSet ds)
    {
        bool flag = true;
        if (ds != null)
        {
            if (ds.Tables[0].Rows.Count == 0)
            {
                flag = false;
                sql.getNullDataSet(ds);
            }
            //By Lhy 20110512 ITEM18  DEL Start
            //gridview.Width = Unit.Pixel(260);
            //By Lhy 20110512 ITEM18  DEL End
            gridview.AutoGenerateColumns = false;
            //BY lhy 20110511 DEL Start;
            // gridview.AllowPaging = true;
            //BY lhy 20110511 DEL End;

            //BY lhy 20110511 ADD Start;
            gridview.AllowPaging = false;
            //BY lhy 20110511 ADD End;
            gridview.Visible = true;

            for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            {
                BoundField bf = new BoundField();

                bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString();
                bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString();
                bf.ItemStyle.Width = 200;
                bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
                bf.HeaderStyle.Wrap = false;
                gridview.Columns.Add(bf);
            }

            CommandField cf_Delete = new CommandField();
            cf_Delete.ButtonType = ButtonType.Image;
            cf_Delete.ShowDeleteButton = true;
            cf_Delete.ShowCancelButton = true;
            cf_Delete.CausesValidation = false;
            cf_Delete.DeleteImageUrl = "~/images/del.jpg";
            cf_Delete.DeleteText = "Delete";
            gridview.Columns.Add(cf_Delete);

            gridview.AllowSorting = true;
            //By Lhy 20110512 ITEM18  DEL End
            //gridview.Caption = str_caption;
            //gridview.CaptionAlign = TableCaptionAlign.Top;
            //By Lhy 20110512 ITEM18  DEL End
            gridview.DataSource = ds.Tables[0];
            gridview.DataBind();
            gridview.Columns[0].Visible = false;
            gridview.Columns[gridview.Columns.Count - 1].Visible = flag;
            if (getRoleID(getRole()) != "0")
                gridview.Columns[gridview.Columns.Count - 1].Visible = false;
        }
    }
Ejemplo n.º 4
0
    protected void bindDataSource(DataSet ds_channel)
    {
        bool notNullFlag = true;
        if (ds_channel.Tables[0].Rows.Count == 0)
        {
            notNullFlag = false;
            sql.getNullDataSet(ds_channel);
        }
        gv_channel.Width = Unit.Pixel(600);
        gv_channel.AutoGenerateColumns = false;
        //By Wsy 20110512 ITEM 18 DEL Start
        //gv_channel.AllowPaging = true;
        //By Wsy 20110512 ITEM 18 DEL End

        //By Wsy 20110512 ITEM 18 ADD Start
        gv_channel.AllowPaging = false;
        //By Wsy 20110512 ITEM 18 ADD End
        gv_channel.Visible = true;
        gv_channel.HeaderStyle.Wrap = false;

        for (int i = 0; i < ds_channel.Tables[0].Columns.Count; i++)
        {
            BoundField bf = new BoundField();

            bf.DataField = ds_channel.Tables[0].Columns[i].ColumnName.ToString();
            bf.HeaderText = ds_channel.Tables[0].Columns[i].Caption.ToString();
            bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
            bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
            bf.ReadOnly = true;
            //By Wsy 20110512 ITEM 18 ADD Start
            bf.ItemStyle.Width = 500;
            //By Wsy 20110512 ITEM 18 ADD End
            bf.ControlStyle.Width = bf.ItemStyle.Width;
            gv_channel.Columns.Add(bf);
        }

        CommandField cf_Delete = new CommandField();
        cf_Delete.ButtonType = ButtonType.Image;
        cf_Delete.ShowDeleteButton = true;
        cf_Delete.ShowCancelButton = true;
        cf_Delete.CausesValidation = false;
        cf_Delete.DeleteImageUrl = "~/images/del.jpg";
        cf_Delete.DeleteText = "Delete";
        gv_channel.Columns.Add(cf_Delete);

        gv_channel.AllowSorting = true;
        gv_channel.DataSource = ds_channel.Tables[0];
        gv_channel.DataBind();
        gv_channel.Columns[0].Visible = false;
        gv_channel.Columns[gv_channel.Columns.Count - 1].Visible = notNullFlag;
        if (getRoleID(getRole()) != "0")
        {
            gv_channel.Columns[gv_channel.Columns.Count - 1].Visible = false;
        }
        lbtn_channel.Visible = true;
    }
    /// <summary>
    /// Adds new column to specified GridView control.
    /// </summary>
    /// <param name="gv">GridView control.</param>
    /// <param name="dataField">Name of the data field.</param>
    /// <param name="headerText">Header text.</param>
    private void AddColumnToGridView(GridView gv, string dataField, string headerText)
    {
        // Define first header column
        BoundField boundfield = new BoundField
        {
            DataField = dataField,
            HeaderText = headerText
        };

        gv.Columns.Add(boundfield);
    }
Ejemplo n.º 6
0
 private void createColumns(DataSet ds)
 {
     gvResult.Columns.Clear();
     foreach (DataColumn column in ds.Tables[0].Columns)
     {
         BoundField boundField = new BoundField();
         boundField.DataField = column.ColumnName;
         boundField.HeaderText = column.ColumnName;
         gvResult.Columns.Add(boundField);
     }
 }
Ejemplo n.º 7
0
    public void BindGrid()
    {
        DataTable dtCost = getTable();
        if (dtCost != null)
        {
            if (dtCost.Rows.Count > 0)
            {
                btnExport.Visible = true;
                grdCostReport.DataSource = dtCost;

                BoundField bnd = new BoundField();
                bnd.DataField = "Field";
                bnd.HeaderText = "Model";
                grdCostReport.Columns.Add(bnd);

                string strQuarterQuery = "Select distinct Quarter from vw_QuarterWiseBudgetCost";
                DataTable dtQuarter = objQueryController.ExecuteQuery(strQuarterQuery);
                if (dtQuarter != null)
                {
                    if (dtQuarter.Rows.Count > 0)
                    {
                        foreach (DataRow drQuarter in dtQuarter.Rows)
                        {
                            BoundField bndf = new BoundField();
                            bndf.DataField = drQuarter["Quarter"].ToString();
                            bndf.HeaderText = drQuarter["Quarter"].ToString();
                            grdCostReport.Columns.Add(bndf);
                        }
                    }
                }
                strGroup = "ModelGroupName";
                helper = new GridViewHelper(this.grdCostReport, false);
                string[] cols = new string[1];
                cols[0] = strGroup;
                helper.RegisterGroup(cols, true, true);
                helper.GroupHeader += new GroupEvent(helper_GroupHeader);
                grdCostReport.DataBind();

            }
            else
            {
                btnExport.Visible = false;
                grdCostReport.DataSource = null;
                grdCostReport.DataBind();

            }
        }
        else
        {
            btnExport.Visible = false;
            grdCostReport.DataSource = null;
            grdCostReport.DataBind();
        }
    }
Ejemplo n.º 8
0
    protected void bound(string nombreCampo, string nombreLabel)
    {
        if (dt.Rows[0][nombreCampo].ToString() != "0" && dt.Rows[0][nombreCampo] != null && dt.Rows[0][nombreCampo].ToString() != "")
        {
            BoundField bound = new BoundField();

            if (nombreCampo == "PrecioVenta")
            {
                if (dt.Rows[0]["MonedaVenta"].ToString() == "P")
                {
                    bound.HeaderText = nombreLabel + " (ARS$)";
                }
                else if (dt.Rows[0]["MonedaVenta"].ToString() == "D")
                {
                    bound.HeaderText = nombreLabel + " (US$)";
                }
            }
            else if (nombreCampo == "PrecioVenta2")
            {
                if (dt.Rows[0]["MonedaVenta2"].ToString() == "P")
                {
                    bound.HeaderText = nombreLabel + " (ARS$)";
                }
                else if (dt.Rows[0]["MonedaVenta2"].ToString() == "D")
                {
                    bound.HeaderText = nombreLabel + " (US$)";
                }
            }
            else if (nombreCampo == "PrecioAlquiler")
            {
                if (dt.Rows[0]["MonedaAlquiler"].ToString() == "P")
                {
                    bound.HeaderText = nombreLabel + " (ARS$)";
                }
                else if (dt.Rows[0]["MonedaAlquiler"].ToString() == "D")
                {
                    bound.HeaderText = nombreLabel + " (US$)";
                }
            }
            else
            {
                bound.HeaderText = nombreLabel;
            }

            bound.DataField = nombreCampo;
            bound.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
            bound.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
            DetailsView1.Fields.Add(bound);
        }
    }
Ejemplo n.º 9
0
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        this.Visible = false;

        if (this.Table != null)
        {
            // Get the log table
            DataTable dt = this.Table;
            if (!DataHelper.DataSourceIsEmpty(dt))
            {
                this.Visible = true;

                // Set the column names
                foreach (DataColumn dc in dt.Columns)
                {
                    BoundField col = new BoundField();
                    col.DataField = dc.ColumnName;
                    col.HeaderText = GetString(ResourcePrefix + dc.ColumnName);

                    // Set style
                    col.ItemStyle.BorderColor = Color.FromArgb(204, 204, 204);
                    col.ItemStyle.BorderStyle = BorderStyle.Solid;
                    col.ItemStyle.BorderWidth = 1;
                    col.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                    if (dc.DataType != typeof(string))
                    {
                        col.ItemStyle.Wrap = false;
                    }

                    col.HeaderStyle.CopyFrom(col.ItemStyle);

                    gridValues.Columns.Add(col);
                }

                // Bind the data
                gridValues.DataSource = dt;
                gridValues.DataBind();

                if (!String.IsNullOrEmpty(this.Title))
                {
                    this.ltlInfo.Text = "<div style=\"padding: 5px 2px 2px 2px;\"><strong>" + this.Title + "</strong></div>";
                }
            }
        }
    }
Ejemplo n.º 10
0
    protected void bindDataSource(DataSet ds_region)
    {
        bool notNullFlag = true;
        if (ds_region.Tables[0].Rows.Count == 0)
        {
            notNullFlag = false;
            sql.getNullDataSet(ds_region);
        }

        gv_Region.Width = Unit.Pixel(800);
        gv_Region.AutoGenerateColumns = false;
        gv_Region.AllowPaging = false;
        gv_Region.Visible = true;

        for (int i = 0; i < ds_region.Tables[0].Columns.Count; i++)
        {
            BoundField bf = new BoundField();

            bf.DataField = ds_region.Tables[0].Columns[i].ColumnName.ToString();
            bf.HeaderText = ds_region.Tables[0].Columns[i].Caption.ToString();
            bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
            bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
            bf.HeaderStyle.Wrap = false;
            gv_Region.Columns.Add(bf);
        }

        //CommandField cf_Delete = new CommandField();
        //cf_Delete.ButtonType = ButtonType.Image;
        //cf_Delete.ShowDeleteButton = true;
        //cf_Delete.ShowCancelButton = true;
        //cf_Delete.CausesValidation = false;
        //cf_Delete.DeleteImageUrl = "~/images/del.jpg";
        //cf_Delete.DeleteText = "Delete";
        //gv_Region.Columns.Add(cf_Delete);

        gv_Region.AllowSorting = true;
        gv_Region.DataSource = ds_region.Tables[0];
        gv_Region.DataBind();

        gv_Region.Columns[gv_Region.Columns.Count - 1].Visible = notNullFlag;
        gv_Region.Columns[0].Visible = false;
        gv_Region.Columns[1].Visible = false;
        gv_Region.Columns[2].Visible = false;
        gv_Region.Columns[3].Visible = false;
        if (getRoleID(getRole()) != "0")
            gv_Region.Columns[gv_Region.Columns.Count - 1].Visible = false;
    }
    //private SqlDataSource _sqlDataSource;
    private void _SetupGridView()
    {
        var idBoundField = new ButtonField
                               {
                                   DataTextField = "ID",
                                   ButtonType = ButtonType.Link,
                                   CommandName = "Select",
                                   HeaderText = "Select"
                               };
        var firstNameField = new BoundField
                                 {
                                     DataField = "FirstName",
                                     HeaderText = "First Name",
                                     SortExpression = "FirstName, LastName"
                                 };
        var lastNameField = new BoundField
                                {
                                    DataField = "LastName",
                                    HeaderText = "Last Name",
                                    SortExpression = "LastName, FirstName"
                                };
        var phoneField = new BoundField
                             {
                                 DataField = "Phone",
                                 HeaderText = "Phone",
                                 SortExpression = "Phone"
                             };
        var emailField = new BoundField
                             {
                                 DataField = "EmailAddress",
                                 HeaderText = "Email Address",
                                 SortExpression = "EmailAddress"
                             };

        _gridView.Columns.Add(idBoundField);
        _gridView.Columns.Add(firstNameField);
        _gridView.Columns.Add(lastNameField);
        _gridView.Columns.Add(phoneField);
        _gridView.Columns.Add(emailField);

        _gridView.DataSourceID = "_sqlDataSource";
        _gridView.DataKeyNames = new[] {"Id"};
        _gridView.RowCommand += GridCommand;
    }
    /// <summary>
    /// bindDataSource
    /// </summary>
    /// <param name="gridview"></param>
    /// <param name="str_caption"></param>
    /// <param name="ds"></param>
    /// <param name="sel"></param>
    /// 
    protected void bindDataSource(GridView gridview, string str_caption, DataSet ds, bool sel)
    {
        bool bflag = true;
        if (ds.Tables[0].Rows.Count == 0)
        {
            bflag = false;
            sql.getNullDataSet(ds);
        }
        gridview.Width = Unit.Pixel(370);
        gridview.AutoGenerateColumns = false;
        gridview.AllowPaging = false;
        gridview.Visible = true;

        for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
        {
            BoundField bf = new BoundField();

            bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString();
            bf.ItemStyle.Width = 200;
            bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString();
            bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
            bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;

            gridview.Columns.Add(bf);
        }

        CommandField cf_Delete = new CommandField();
        cf_Delete.ButtonType = ButtonType.Image;
        cf_Delete.ShowDeleteButton = true;
        cf_Delete.ShowCancelButton = true;
        cf_Delete.CausesValidation = false;
        cf_Delete.DeleteImageUrl = "~/images/del.jpg";
        cf_Delete.DeleteText = "Delete";
        gridview.Columns.Add(cf_Delete);

        gridview.Caption = str_caption;
        gridview.CaptionAlign = TableCaptionAlign.Top;
        gridview.AllowSorting = true;
        gridview.DataSource = ds.Tables[0];
        gridview.DataBind();
        gridview.Columns[0].Visible = false;
        gridview.Columns[gridview.Columns.Count - 1].Visible = bflag;
    }
    protected void bindDataSource()
    {
        DataSet ds_Country = sql.getOperationBySegment(ddlist_segment.SelectedItem.Value);

        if (ds_Country.Tables[0].Rows.Count > 0)
        {
            gv_opAbbr.Width = Unit.Pixel(200);
            gv_opAbbr.AutoGenerateColumns = false;
            gv_opAbbr.AllowPaging = true;
            gv_opAbbr.Visible = true;

            for (int i = 2; i < ds_Country.Tables[0].Columns.Count; i++)
            {
                BoundField bf = new BoundField();

                bf.DataField = ds_Country.Tables[0].Columns[i].ColumnName.ToString();
                bf.HeaderText = ds_Country.Tables[0].Columns[i].Caption.ToString();
                bf.ItemStyle.Width = 100;
                bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
                bf.ReadOnly = true;

                gv_opAbbr.Columns.Add(bf);
            }

            gv_opAbbr.AllowSorting = true;
            gv_opAbbr.DataSource = ds_Country.Tables[0];
            gv_opAbbr.DataBind();
            panel_enter.Visible = true;
            panel_enter.Enabled = true;
        }
        else
        {
            panel_enter.Visible = true;
            gv_opAbbr.Visible = false;
            panel_enter.Enabled = false;
        }
    }
Ejemplo n.º 14
0
    /// <summary>
    ///  Bind user information
    /// </summary>
    /// <param name="ds">dataset</param>
    protected void bindDataSource(DataSet ds)
    {
        if (ds.Tables[0].Rows.Count == 0)
        {
            sql.getNullDataSet(ds);
        }
        gv_administrator.Width = Unit.Pixel(800);
        gv_administrator.AutoGenerateColumns = false;
        gv_administrator.AllowPaging = true;
        gv_administrator.Visible = true;

        //add columns
        addOperationCol(ds);
        addCountryCol(ds);
        addSegmentCol(ds);

        for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
        {
            BoundField bf = new BoundField();

            bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString();
            bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString();
            bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
            bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;

            gv_administrator.Columns.Add(bf);
        }

        gv_administrator.AllowSorting = true;
        gv_administrator.DataSource = ds.Tables[0];
        gv_administrator.DataBind();
        gv_administrator.Columns[0].Visible = false;
        gv_administrator.Columns[6].Visible = false;
        gv_administrator.Columns[7].Visible = false;
        gv_administrator.Columns[8].Visible = false;
        gv_administrator.Columns[9].Visible = false;
    }
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        Visible = false;

        if (Table != null)
        {
            // Get the log table
            DataTable dt = Table;
            if (!DataHelper.DataSourceIsEmpty(dt))
            {
                Visible = true;

                // Set the column names
                foreach (DataColumn dc in dt.Columns)
                {
                    BoundField col = new BoundField();
                    col.DataField = dc.ColumnName;
                    col.HeaderText = GetString(ResourcePrefix + dc.ColumnName);

                    col.HeaderStyle.CopyFrom(col.ItemStyle);

                    gridValues.Columns.Add(col);
                }

                // Bind the data
                gridValues.DataSource = dt;
                gridValues.DataBind();

                if (!String.IsNullOrEmpty(Title))
                {
                    ltlInfo.Text = "<div style=\"padding: 5px 2px 2px 2px;\"><strong>" + Title + "</strong></div>";
                }
            }
        }
    }
Ejemplo n.º 16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            BoundField dcf = new BoundField();
            dcf.HeaderText = "Nome";
            dcf.DataField = "Name";
            GridViewSubscriptions.Columns.Add(dcf);

            dcf = new BoundField();
            dcf.HeaderText = "Cognome";
            dcf.DataField = "Surname";
            GridViewSubscriptions.Columns.Add(dcf);

            dcf = new BoundField();
            dcf.HeaderText = "Gruppo";
            dcf.DataField = "Club";
            GridViewSubscriptions.Columns.Add(dcf);

            dcf = new BoundField();
            dcf.HeaderText = "Mail";
            dcf.DataField = "EMail";
            GridViewSubscriptions.Columns.Add(dcf);

            dcf = new BoundField();
            dcf.HeaderText = "Data di nascita";
            dcf.DataField = "BirthDateFormatted";
            GridViewSubscriptions.Columns.Add(dcf);

            dcf = new BoundField();
            dcf.HeaderText = "Sesso";
            dcf.DataField = "GenderDescription";
            GridViewSubscriptions.Columns.Add(dcf);
        }
        LoadSubscriptors();
    }
Ejemplo n.º 17
0
    //private DataSet fillDataSet()
    //{
    //    IAppointment FormManager;
    //    DataSet theDtSet;
    //    IQCareUtils clsUtil = new IQCareUtils();

    //    FormManager = (IAppointment)ObjectFactory.CreateInstance("BusinessProcess.Scheduler.BAppointment, BusinessProcess.Scheduler");
    //    IQCareUtils theUtil = new IQCareUtils();

    //    theDtSet = new DataSet();

    //    grdSearchResult.Columns.Clear();
    //    grdSearchResult.DataSource = null;

    //    return theDtSet;
    //}

    private void BindGrid()
    {
        BoundField theCol0 = new BoundField();

        theCol0.HeaderText         = "SubTestID";
        theCol0.DataField          = "SubTestID";
        theCol0.ItemStyle.CssClass = " textstyle";
        theCol0.ReadOnly           = true;
        grdSearchResult.Columns.Add(theCol0);
        grdSearchResult.Columns[0].Visible = false;

        BoundField theCol1 = new BoundField();

        theCol1.HeaderText         = "SubTestName";
        theCol1.DataField          = "SubTestName";
        theCol1.ItemStyle.CssClass = "textstyle";
        theCol1.ReadOnly           = true;
        grdSearchResult.Columns.Add(theCol1);
        grdSearchResult.Columns[1].Visible = false;

        BoundField theCol2 = new BoundField();

        theCol2.HeaderText         = "UnitID";
        theCol2.DataField          = "UnitID";
        theCol2.ItemStyle.CssClass = "textstyle";
        theCol2.ReadOnly           = true;
        grdSearchResult.Columns.Add(theCol2);
        grdSearchResult.Columns[2].Visible = false;

        BoundField theCol3 = new BoundField();

        theCol3.HeaderText         = "Units";
        theCol3.DataField          = "UnitName";
        theCol3.ItemStyle.CssClass = "textstyle";
        theCol3.SortExpression     = "UnitName";
        theCol3.ReadOnly           = true;
        grdSearchResult.Columns.Add(theCol3);
        grdSearchResult.Columns[3].Visible = true;

        BoundField theCol4 = new BoundField();

        theCol4.HeaderText         = "Lower Boundary";
        theCol4.DataField          = "MinBoundaryValue";
        theCol4.ItemStyle.CssClass = "textstyle";
        theCol4.SortExpression     = "MinBoundaryValue";
        theCol4.ReadOnly           = true;
        grdSearchResult.Columns.Add(theCol4);
        grdSearchResult.Columns[4].Visible = true;

        BoundField theCol5 = new BoundField();

        theCol5.HeaderText         = "Upper Boundary";
        theCol5.DataField          = "MaxBoundaryValue";
        theCol5.ItemStyle.CssClass = "textstyle";
        theCol5.SortExpression     = "MaxBoundaryValue";
        theCol5.ReadOnly           = true;
        grdSearchResult.Columns.Add(theCol5);
        grdSearchResult.Columns[5].Visible = true;

        BoundField theCol6 = new BoundField();

        theCol6.HeaderText         = "Default";
        theCol6.DataField          = "DefaultUnit";
        theCol6.ItemStyle.CssClass = "textstyle";
        theCol6.ReadOnly           = true;
        theCol6.SortExpression     = "DefaultUnit";
        grdSearchResult.Columns.Add(theCol6);
        grdSearchResult.Columns[6].Visible = true;

        BoundField theCol7 = new BoundField();

        theCol7.HeaderText         = "ID";
        theCol7.DataField          = "ID";
        theCol7.ItemStyle.CssClass = "textstyle";
        theCol7.ReadOnly           = true;
        grdSearchResult.Columns.Add(theCol7);
        grdSearchResult.Columns[7].Visible = false;

        BoundField theCol8 = new BoundField();

        theCol8.HeaderText         = "Undetectable";
        theCol8.DataField          = "undetectable";
        theCol8.ItemStyle.CssClass = "textstyle";
        theCol8.ReadOnly           = true;
        theCol8.SortExpression     = "undetectable";
        grdSearchResult.Columns.Add(theCol8);
        grdSearchResult.Columns[8].Visible = true;

        //grdSearchResult.DataSource = ((DataSet)ViewState["MstDS"]).Tables[1];
        grdSearchResult.DataBind();
    }
Ejemplo n.º 18
0
    protected void bindDataSource()
    {
        tbox_date.Text = ddlist_meetingdate.SelectedItem.Text.Trim();
        DataSet ds_currency = getCurrencyInfo(ddlist_meetingdate.SelectedItem.Value.Trim());

        if (ds_currency != null)
        {
            gv_currency.Width = Unit.Pixel(600);
            gv_currency.AutoGenerateColumns = false;
            // update by SJ 20110511 Start
            //gv_currency.AllowPaging = true;
            gv_currency.AllowPaging = false;
            // update by SJ 20110511 End
            gv_currency.Visible = true;

            for (int i = 0; i < ds_currency.Tables[0].Columns.Count; i++)
            {
                BoundField bf = new BoundField();
                bf.DataField = ds_currency.Tables[0].Columns[i].ColumnName.ToString();
                bf.HeaderText = ds_currency.Tables[0].Columns[i].Caption.ToString();
                if (ds_currency.Tables[0].Columns[i].ColumnName == "ID" || ds_currency.Tables[0].Columns[i].ColumnName == "Currency")
                    bf.ReadOnly = true;
                else
                {
                    bf.ItemStyle.Width = 120;
                    bf.ReadOnly = false;
                }
                bf.ControlStyle.Width = bf.ItemStyle.Width;
                bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
                gv_currency.Columns.Add(bf);
            }

            CommandField cf_Update = new CommandField();
            cf_Update.ButtonType = ButtonType.Image;
            cf_Update.ShowEditButton = true;
            cf_Update.ShowCancelButton = true;
            cf_Update.EditImageUrl = "~/images/edit.jpg";
            cf_Update.EditText = "Edit";
            cf_Update.CausesValidation = false;
            cf_Update.CancelImageUrl = "~/images/cancel.jpg";
            cf_Update.CancelText = "Cancel";
            cf_Update.UpdateImageUrl = "~/images/ok.jpg";
            cf_Update.UpdateText = "Update";
            gv_currency.Columns.Add(cf_Update);

            CommandField cf_Delete = new CommandField();
            cf_Delete.ButtonType = ButtonType.Image;
            cf_Delete.ShowDeleteButton = true;
            cf_Delete.ShowCancelButton = true;
            cf_Delete.CausesValidation = false;
            cf_Delete.DeleteImageUrl = "~/images/del.jpg";
            cf_Delete.DeleteText = "Delete";
            gv_currency.Columns.Add(cf_Delete);

            gv_currency.AllowSorting = true;
            gv_currency.DataSource = ds_currency.Tables[0];
            gv_currency.DataBind();
            gv_currency.Columns[0].Visible = false;
            if (getRoleID(getRole()) != "0")
            {
                gv_currency.Columns[gv_currency.Columns.Count - 1].Visible = false;
                gv_currency.Columns[gv_currency.Columns.Count - 2].Visible = false;
            }
        }
    }
Ejemplo n.º 19
0
        /// <summary>
        /// 绑定Gridview
        /// </summary>
        private void BindGridView()
        {
            using (db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
            {
                if (!string.IsNullOrEmpty(Request.QueryString["QCBatch"]))
                {
                    QCbatch = Request.QueryString["QCBatch"];
                }
                BoundField bfColumn;
                foreach (var kvp in Titlelist)
                {
                    bfColumn            = new BoundField();
                    bfColumn.HeaderText = kvp.Split(':')[0];
                    bfColumn.DataField  = kvp.Split(':')[1];
                    this.gv.Columns.Add(bfColumn);
                }

                //添加选择列


                TemplateField reportNum = new TemplateField();
                reportNum.ItemTemplate    = new MulTextBoxTemplate("请选择", DataControlRowType.DataRow, "", "MaterialsLeaderID", "txtgentaojianNum");
                reportNum.HeaderTemplate  = new MulTextBoxTemplate("根/台/套/件(合格)", DataControlRowType.Header);
                reportNum.ItemStyle.Width = 150;
                this.gv.Columns.Insert(5, reportNum);


                TemplateField f_reportNum = new TemplateField();
                f_reportNum.ItemTemplate    = new MulTextBoxTemplate("请选择", DataControlRowType.DataRow, "", "MaterialsLeaderID", "txtgentaojianNums");
                f_reportNum.HeaderTemplate  = new MulTextBoxTemplate("根/台/套/件(不合格)", DataControlRowType.Header);
                f_reportNum.ItemStyle.Width = 150;
                this.gv.Columns.Insert(6, f_reportNum);


                TemplateField metreNum = new TemplateField();
                metreNum.ItemTemplate    = new MulTextBoxTemplate("请选择", DataControlRowType.DataRow, "", "MaterialsLeaderID", "txtmetreNum");
                metreNum.HeaderTemplate  = new MulTextBoxTemplate("米(合格)", DataControlRowType.Header);
                metreNum.ItemStyle.Width = 150;
                this.gv.Columns.Insert(8, metreNum);

                TemplateField f_metreNum = new TemplateField();
                f_metreNum.ItemTemplate    = new MulTextBoxTemplate("请选择", DataControlRowType.DataRow, "", "MaterialsLeaderID", "txtmetreNums");
                f_metreNum.HeaderTemplate  = new MulTextBoxTemplate("米(不合格)", DataControlRowType.Header);
                f_metreNum.ItemStyle.Width = 150;
                this.gv.Columns.Insert(9, f_metreNum);



                TemplateField tonNum = new TemplateField();
                tonNum.ItemTemplate    = new MulTextBoxTemplate("请选择", DataControlRowType.DataRow, "", "MaterialsLeaderID", "txttonNum");
                tonNum.HeaderTemplate  = new MulTextBoxTemplate("吨(合格)", DataControlRowType.Header);
                tonNum.ItemStyle.Width = 150;
                this.gv.Columns.Insert(11, tonNum);

                TemplateField f_tonNum = new TemplateField();
                f_tonNum.ItemTemplate    = new MulTextBoxTemplate("请选择", DataControlRowType.DataRow, "", "MaterialsLeaderID", "txttonNums");
                f_tonNum.HeaderTemplate  = new MulTextBoxTemplate("吨(不合格)", DataControlRowType.Header);
                f_tonNum.ItemStyle.Width = 150;
                this.gv.Columns.Insert(12, f_tonNum);

                TemplateField testReport = new TemplateField();
                testReport.ItemTemplate    = new MulTextBoxTemplate("请选择", DataControlRowType.DataRow, "", "MaterialsLeaderID", "txtreportNum");
                testReport.HeaderTemplate  = new MulTextBoxTemplate("质检报告号", DataControlRowType.Header);
                testReport.ItemStyle.Width = 150;
                this.gv.Columns.Insert(13, testReport);

                //HyperLinkField hlTask = new HyperLinkField();
                //hlTask.HeaderText = "上传质检报告";
                //this.gv.Columns.Insert(14, hlTask);


                this.gv.DataSource = from a in db.StorageInMaterialsLeader

                                     join b in db.StorageInMain on a.StorageInMaterials.StorageProduce.StorageInID equals b.StorageInID

                                     where a.StorageInMaterials.StorageProduce.StorageInID == _storageInID && a.StorageInMaterials.StorageProduce.BatchIndex == (string.IsNullOrEmpty(QCbatch) ? a.StorageInMaterials.StorageProduce.BatchIndex : QCbatch)
                                     select new
                {
                    a.MaterialsLeaderID,
                    a.StorageInMaterials.StorageProduce.MaterialInfo.MaterialName,
                    a.StorageInMaterials.StorageProduce.MaterialInfo.SpecificationModel,
                    a.StorageInMaterials.StorageProduce.MaterialInfo.FinanceCode,
                    b.StorageInCode,
                    a.StorageInMaterials.RealGentaojian,
                    a.StorageInMaterials.RealMetre,
                    a.StorageInMaterials.RealTon,
                    a.StorageInMaterials.StorageProduce.ProjectInfo.ProjectName,
                    a.StorageInMaterials.StorageProduce.ExpectedTime,
                    a.StorageInMaterials.StorageProduce.BatchIndex,
                    a.Remark
                };
                this.gv.RowDataBound += new GridViewRowEventHandler(gv_RowDataBound);
                this.gv.DataBind();
                this.gv.Columns[this.gv.Columns.Count - 1].Visible = false;

                Panel p1 = (Panel)GetControltByMaster("Panel1");
                p1.Controls.Add(this.gv);
            }
        }
Ejemplo n.º 20
0
        protected void btnExport_Click(object sender, EventArgs e)
        {
            string sWhereSQL = " And SignStatus=" + ddlSignStatus.SelectedValue.ToString();

            if (txtUserSalaryOpCode.Text.Length > 0)
            {
                sWhereSQL = sWhereSQL + " And a.OpCode = '" + txtUserSalaryOpCode.Text + "'";
            }

            if (txtSalaryYears.Text.Length > 0)
            {
                sWhereSQL += " And a.SalaryYears = '" + txtSalaryYears.Text + "'";
            }
            if (ddlImportRec.SelectedIndex > 0)
            {
                sWhereSQL += " And a.SalaryRecGuid='" + ddlImportRec.SelectedValue.ToString() + "'";
            }

            string        sSQL = "select a.ID, a.OpCode, b.OpName, b.Sex, b.IdNumber, a.SalaryYears, a.SalaryDate";
            SqlDataReader sdr  = SysClass.SysUserSalary.GetUserSalaryFieldsLstByReader(txtSalaryYears.Text);

            //gvLists.Columns.Clear();
            while (sdr.Read())
            {
                sSQL += "," + sdr["FieldName"].ToString();

                string sPDSQL = " Select top 1 1 From UserSalary_Info a"
                                + " left join SysUser_Info b on b.Status=0 And a.OpCode=b.OpCode"
                                + " Where a.Status=0 " + sWhereSQL;

                if ((sdr["FieldName"].ToString() == "TotalSalary") || (sdr["FieldType"].ToString() != "1"))
                {
                    sPDSQL += " And IsNull(" + sdr["FieldName"].ToString() + ",0) > 0 ";
                }
                else
                {
                    sPDSQL += " And IsNull(" + sdr["FieldName"].ToString() + ",'') <> '' ";
                }

                if (SysClass.SysGlobal.GetExecSqlIsExist(sPDSQL))
                {
                    BoundField nameColumn = new BoundField();
                    nameColumn.HeaderText = sdr["UserFieldTitle"].ToString();
                    nameColumn.DataField  = sdr["FieldName"].ToString();

                    gvLists.Columns.Add(nameColumn);
                }
            }
            sdr.Close();

            sSQL += " from UserSalary_Info a "
                    + " left join SysUser_Info b on b.Status=0 And a.OpCode=b.OpCode"
                    + " Where a.Status=0 " + sWhereSQL;

            sSQL += " Order By a.SalaryYears Desc";

            CyxPack.CommonOperation.DataBinder.BindGridViewData(gvLists, CyxPack.OperateSqlServer.DataCommon.GetDataByReader(sSQL));

            if (gvLists.Rows.Count > 0)
            {
                //调用导出方法
                ExportGridViewForUTF8(gvLists, DateTime.Now.ToString() + ".xls");
            }
            else
            {
            }
        }
Ejemplo n.º 21
0
        private string GenerateExportData(string dataFormat)
        {
            border      = (dataFormat == "Print" ? "0" : "1");
            dtExcelData = Session["ListDetail"] as DataTable;

            string styleSheet    = "<style>.text { mso-number-format:\\@; } .barcode {font-size : 12pt; font-family : IDAutomationC39S; }</style>";
            string headerContent = string.Empty;
            string footerContent = string.Empty;
            string excelContent  = string.Empty;

            headerContent  = "<table border='0' width='800px'>";
            headerContent += "<tr><td  colspan='7' align='center'><span style='font-size : 12pt; font-family : IDAutomationC39S; '>*" + Request.QueryString["ListName"].ToString() + "*</span></td></tr>";
            headerContent += "<tr><td  colspan='7' align='center' style='color:blue;font-family: Arial, Helvetica, sans-serif;font-size: 14px;	font-weight: bold;'><center>Shipping List</center></td></tr>";
            headerContent += "<tr><td  style='padding-left:40px'><b>List Name :" + Request.QueryString["ListName"].ToString() + "</b></td><td><b>Location:" + Request.QueryString["Location"].ToString() + "</b></td><td colspan='5'><b>Change ID: " + Request.QueryString["ChangeID"].ToString() + "</b></td></tr>";
            headerContent += "<tr><td style='padding-left:40px'><b>Entry ID:" + Request.QueryString["EntryID"].ToString() + "</b></td>" +
                             "<td><b>Entry Date: " + Request.QueryString["EntryDt"].ToString() + "</b></td>" +
                             "<td colspan='5'><b>Change Date: " + Request.QueryString["ChangeDt"].ToString() + "</></td></tr>";
            headerContent += "<tr><th colspan='7' style='color:blue' align=left></th></tr>";

            if (dtExcelData.Rows.Count > 0)
            {
                dv.AutoGenerateColumns = false;
                dv.ShowHeader          = true;
                dv.ShowFooter          = true;
                dv.RowDataBound       += new GridViewRowEventHandler(dv_RowDataBound);

                BoundField bfExcel = new BoundField();
                bfExcel.HeaderText                  = "Document No";
                bfExcel.DataField                   = "OrderNo";
                bfExcel.ItemStyle.Height            = 25;
                bfExcel.FooterStyle.Height          = 25;
                bfExcel.HeaderStyle.Height          = 25;
                bfExcel.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
                bfExcel.FooterStyle.HorizontalAlign = HorizontalAlign.Right;
                dv.Columns.Add(bfExcel);

                bfExcel                             = new BoundField();
                bfExcel.HeaderText                  = "Customer Name";
                bfExcel.DataField                   = "CustName";
                bfExcel.ItemStyle.Width             = 150;
                bfExcel.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
                bfExcel.FooterStyle.HorizontalAlign = HorizontalAlign.Right;
                dv.Columns.Add(bfExcel);

                bfExcel                             = new BoundField();
                bfExcel.HeaderText                  = "Pallet No";
                bfExcel.DataField                   = "PalletNo";
                bfExcel.ItemStyle.Width             = 80;
                bfExcel.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
                bfExcel.FooterStyle.HorizontalAlign = HorizontalAlign.Right;
                dv.Columns.Add(bfExcel);

                bfExcel                             = new BoundField();
                bfExcel.HeaderText                  = "Doc Lbs";
                bfExcel.DataField                   = "ShipWght";
                bfExcel.DataFormatString            = "{0:#,##0.00}";
                bfExcel.ItemStyle.Width             = 60;
                bfExcel.ItemStyle.HorizontalAlign   = HorizontalAlign.Right;
                bfExcel.FooterStyle.HorizontalAlign = HorizontalAlign.Right;
                bfExcel.FooterStyle.Font.Bold       = true;
                dv.Columns.Add(bfExcel);

                bfExcel                             = new BoundField();
                bfExcel.HeaderText                  = "Entry ID";
                bfExcel.DataField                   = "EntryID";
                bfExcel.ItemStyle.Width             = 80;
                bfExcel.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
                bfExcel.FooterStyle.HorizontalAlign = HorizontalAlign.Right;
                dv.Columns.Add(bfExcel);

                bfExcel                             = new BoundField();
                bfExcel.HeaderText                  = "Change ID";
                bfExcel.DataField                   = "ChangeID";
                bfExcel.ItemStyle.Width             = 80;
                bfExcel.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
                bfExcel.FooterStyle.HorizontalAlign = HorizontalAlign.Right;
                dv.Columns.Add(bfExcel);

                bfExcel                           = new BoundField();
                bfExcel.HeaderText                = "PO #";
                bfExcel.DataField                 = "CustPONo";
                bfExcel.ItemStyle.Width           = 170;
                bfExcel.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                dv.Columns.Add(bfExcel);

                bfExcel                             = new BoundField();
                bfExcel.HeaderText                  = "Status";
                bfExcel.DataField                   = "StatusCd";
                bfExcel.ItemStyle.Width             = 60;
                bfExcel.FooterStyle.HorizontalAlign = HorizontalAlign.Right;
                dv.Columns.Add(bfExcel);

                dv.DataSource = dtExcelData;
                dv.DataBind();

                System.Text.StringBuilder sb  = new System.Text.StringBuilder();
                System.IO.StringWriter    sw  = new System.IO.StringWriter(sb);
                HtmlTextWriter            htw = new HtmlTextWriter(sw);
                dv.RenderControl(htw);
                excelContent += "<table><tr><th colspan='7' style='padding-left:40px;padding-top:10px;' align=left>";
                excelContent += sb.ToString();
                excelContent += "</th></tr></table>";
            }
            else
            {
                excelContent = "<tr  ><th width='100%' align ='center' colspan='7' > No records found</th></tr> </table>";
            }

            return(styleSheet + headerContent + excelContent);
        }
Ejemplo n.º 22
0
    private void BindGrid()
    {
        //Bind the fields of the gridview
        BoundField theCol0 = new BoundField();

        theCol0.HeaderText         = "Lab Test ID";
        theCol0.DataField          = "LabTestID";
        theCol0.ItemStyle.CssClass = "textstyle";
        theCol0.ReadOnly           = true;

        BoundField theCol1 = new BoundField();

        theCol1.HeaderText               = "Priority";
        theCol1.DataField                = "Sequence";
        theCol1.ItemStyle.CssClass       = "textstyle";
        theCol1.SortExpression           = "Sequence";
        theCol1.ItemStyle.Font.Underline = true;
        theCol1.ReadOnly = true;


        BoundField theCol2 = new BoundField();

        theCol2.HeaderText         = "Lab Type";
        theCol2.ItemStyle.CssClass = "textstyle";
        theCol2.DataField          = "LabTypeName";
        theCol2.SortExpression     = "LabTypeName";
        theCol2.ReadOnly           = true;

        BoundField theCol3 = new BoundField();

        theCol3.HeaderText         = "Department";
        theCol3.ItemStyle.CssClass = "textstyle";
        theCol3.DataField          = "LabDepartmentName";
        theCol3.SortExpression     = "LabDepartmentName";
        theCol3.ReadOnly           = true;

        BoundField theCol4 = new BoundField();

        theCol4.HeaderText         = "Test Name";
        theCol4.ItemStyle.CssClass = "textstyle";
        theCol4.DataField          = "LabName";
        theCol4.SortExpression     = "LabName";
        theCol4.ReadOnly           = true;

        BoundField theCol5 = new BoundField();

        theCol5.HeaderText         = "Status";
        theCol5.DataField          = "Status";
        theCol5.ItemStyle.CssClass = "textstyle";
        theCol5.SortExpression     = "Status";
        theCol5.ReadOnly           = true;


        ButtonField theBtn = new ButtonField();

        theBtn.ButtonType           = ButtonType.Link;
        theBtn.CommandName          = "Select";
        theBtn.HeaderStyle.CssClass = "textstylehidden";
        theBtn.ItemStyle.CssClass   = "textstylehidden";

        grdLab.Columns.Add(theCol0);
        grdLab.Columns.Add(theCol1);
        /////grdLab.Columns.Add(theCol2);   ----- Sanjay 13 Sept 2006
        grdLab.Columns.Add(theCol3);
        grdLab.Columns.Add(theCol4);
        grdLab.Columns.Add(theCol5);


        grdLab.Columns.Add(theBtn);

        grdLab.DataBind();
        grdLab.Columns[0].Visible = false;
    }
Ejemplo n.º 23
0
        void RefreshGridView()
        {
            GlobalMethods.DeleteOldFile();

            GridView1.RowDeleting          += new GridViewDeleteEventHandler(GridView1_RowDeleting);
            GridView1.RowEditing           += new GridViewEditEventHandler(GridView1_RowEditing);
            GridView1.SelectedIndexChanged += new EventHandler(GridView1_SelectedIndexChanged);

            string[] files = System.IO.Directory.GetFiles(Server.MapPath("~/dumpfiles"));

            DataTable dt = new DataTable();

            dt.Columns.Add("Filename");

            foreach (string s in files)
            {
                if (!s.EndsWith("sql"))
                {
                    continue;
                }
                dt.Rows.Add(System.IO.Path.GetFileName(s));
            }

            if (Session["filedeleted"] != null)
            {
                Label1.Text            = Session["filedeleted"] + " is deleted.<br />";
                Session["filedeleted"] = null;
            }
            else
            {
                Label1.Text = string.Empty;
            }

            if (dt.Rows.Count == 0)
            {
                Label1.Text += "No files.";
            }
            else
            {
                Label1.Text += string.Empty;
            }

            GridView1.DataSource = null;
            GridView1.DataBind();
            GridView1.Columns.Clear();
            GridView1.DataSource          = dt;
            GridView1.AutoGenerateColumns = false;

            BoundField colnName = new BoundField();

            colnName.HeaderText = "Filename";
            colnName.DataField  = "Filename";
            colnName.ReadOnly   = true;

            CommandField colnDel = new CommandField();

            colnDel.DeleteText       = "Delete";
            colnDel.ShowDeleteButton = true;

            CommandField colnDownload = new CommandField();

            colnDownload.EditText       = "Download";
            colnDownload.ShowEditButton = true;

            CommandField colnView = new CommandField();

            colnView.ShowSelectButton = true;
            colnView.SelectText       = "View";

            GridView1.Columns.Add(colnName);
            GridView1.Columns.Add(colnDel);
            GridView1.Columns.Add(colnDownload);
            GridView1.Columns.Add(colnView);

            GridView1.Columns[0].ItemStyle.Width = Unit.Pixel(150);
            GridView1.Columns[1].ItemStyle.Width = Unit.Pixel(55);
            GridView1.Columns[2].ItemStyle.Width = Unit.Pixel(70);
            GridView1.Columns[3].ItemStyle.Width = Unit.Pixel(70);

            GridView1.SelectedIndex = -1;

            GridView1.DataBind();

            Session.Clear();
        }
 public override void SetStylesAndFormats(BoundField column, string format)
 {
     base.SetStylesAndFormats(column, format);
     column.DataFormatString = format != string.Empty ? string.Format("{{0:{0}}}", format) : "{0:g}";
 }
Ejemplo n.º 25
0
        private void InitializeCustomControls()
        {
            InitBar();

            //***初始化新建物资列表***//
            this.spgvMaterial = new SPGridView();
            this.spgvMaterial.AutoGenerateColumns = false;
            this.spgvMaterial.Attributes.Add("style", "word-break:keep-all;word-wrap:normal");

            Panel p1 = (Panel)GetControltByMaster("Panel1");

            p1.Controls.Add(this.spgvMaterial);//应用分页模版,必须先将spgvMaterial加入到页面中

            //分页
            this.spgvMaterial.AllowPaging        = true;
            this.spgvMaterial.PageSize           = 10;
            this.spgvMaterial.PageIndexChanging += new GridViewPageEventHandler(spgvMaterial_PageIndexChanging);
            this.spgvMaterial.PagerTemplate      = new PagerTemplate("{0} - {1}", spgvMaterial);
            this.spgvMaterial.Columns.Clear();//应用分页模版,必须清除所有列

            //添加选择列
            TemplateField tfieldCheckbox = new TemplateField();

            tfieldCheckbox.ItemTemplate   = new CheckBoxTemplate("选择", DataControlRowType.DataRow);
            tfieldCheckbox.HeaderTemplate = new CheckBoxTemplate("选择", DataControlRowType.Header);
            this.spgvMaterial.Columns.Add(tfieldCheckbox);

            BoundField bfColumn;

            foreach (var kvp in Titlelist)
            {
                bfColumn            = new BoundField();
                bfColumn.HeaderText = kvp.Split(':')[0];
                bfColumn.DataField  = kvp.Split(':')[1];
                this.spgvMaterial.Columns.Add(bfColumn);
            }

            //加入调拨数量(根/台/套/件)列
            TemplateField tfGentaojian = new TemplateField();

            tfGentaojian.HeaderText   = "调拨数量(根/台/套/件)";
            tfGentaojian.ItemTemplate = new TextBoxTemplate("Gentaojian", string.Empty, "^(-?\\d+)(\\.\\d+)?$", "0", 80);
            this.spgvMaterial.Columns.Insert(5, tfGentaojian);

            //加入调拨数量(米)列
            TemplateField tfMetre = new TemplateField();

            tfMetre.HeaderText   = "调拨数量(米)";
            tfMetre.ItemTemplate = new TextBoxTemplate("Metre", string.Empty, "^(-?\\d+)(\\.\\d+)?$", "0", 80);
            this.spgvMaterial.Columns.Insert(7, tfMetre);

            //加入调拨数量(吨)列
            TemplateField tfTon = new TemplateField();

            tfTon.HeaderText   = "调拨数量(吨)";
            tfTon.ItemTemplate = new TextBoxTemplate("Ton", string.Empty, "^(-?\\d+)(\\.\\d+)?$", "0", 80);
            this.spgvMaterial.Columns.Insert(9, tfTon);

            //加入备注
            TemplateField tfRemark = new TemplateField();

            tfRemark.HeaderText   = "备注";
            tfRemark.ItemTemplate = new TextBoxTemplate("Remark", DataControlRowType.DataRow);
            this.spgvMaterial.Columns.Insert(10, tfRemark);

            //***初始化已加入物资列表***//
            this.spgvExistMaterial = new SPGridView();
            this.spgvExistMaterial.AutoGenerateColumns = false;
            this.spgvExistMaterial.Attributes.Add("style", "word-break:keep-all;word-wrap:normal");

            foreach (var kvp in ExistTitlelist)
            {
                bfColumn            = new BoundField();
                bfColumn.HeaderText = kvp.Split(':')[0];
                bfColumn.DataField  = kvp.Split(':')[1];
                this.spgvExistMaterial.Columns.Add(bfColumn);
            }


            btnOK        = (Button)GetControltByMaster("btnOK");
            btnOK.Click += new EventHandler(btnOK_Click);

            btnSearch        = (Button)GetControltByMaster("btnSearch");
            btnSearch.Click += new EventHandler(btnSearch_Click);

            chbShowAll = (CheckBox)GetControltByMaster("chbShowAll");
            chbShowAll.CheckedChanged += new EventHandler(chbShowAll_CheckedChanged);

            txtMaterialName       = GetControltByMaster("txtMaterialName") as TextBox;
            txtFinanceCode        = GetControltByMaster("txtFinanceCode") as TextBox;
            txtSpecificationModel = GetControltByMaster("txtSpecificationModel") as TextBox;
        }
        protected bool sendEmail(string RequestNo, string requestEmail)
        {
            bool mailSent = false;

            try
            {
                GridView objGV = new GridView();
                objGV.AutoGenerateColumns = false;
                BoundField bfLabourCategory = new BoundField();
                bfLabourCategory.HeaderText = "LabourCategory";
                bfLabourCategory.DataField  = "LabourCategory";
                objGV.Columns.Add(bfLabourCategory);
                //BoundField bfDateofAttendance = new BoundField();
                //bfDateofAttendance.HeaderText = "DateOfAttendance";
                //bfDateofAttendance.DataField = "DateOfAttendance";
                //bfDateofAttendance.DataFormatString = "{0:dd-MMM-yyyy}";
                //objGV.Columns.Add(bfDateofAttendance);
                BoundField bfLabourNo = new BoundField();
                bfLabourNo.HeaderText = "LabourNo";
                bfLabourNo.DataField  = "LabourNo";
                objGV.Columns.Add(bfLabourNo);
                BoundField bfJustification = new BoundField();
                bfJustification.HeaderText = "Justification";
                bfJustification.DataField  = "Justification";
                objGV.Columns.Add(bfJustification);
                BoundField bfRemarks = new BoundField();
                bfRemarks.HeaderText = "Remarks";
                bfRemarks.DataField  = "Remarks";
                objGV.Columns.Add(bfRemarks);

                SqlConnection sqlConnection = new SqlConnection();
                sqlConnection.ConnectionString = connectionString;                                                                                                                                  //Connection Details
                                                                                                                                                                                                    //select fields to mail example student details
                SqlCommand     sqlCommand     = new SqlCommand("select LabourCategory,LabourNo,Justification,Remarks from vwLabourRequestFormDetails where RequestNo = @RequestNo", sqlConnection); //select query command
                SqlDataAdapter sqlDataAdapter = new SqlDataAdapter();
                sqlDataAdapter.SelectCommand = sqlCommand;                                                                                                                                          //add selected rows to sql data adapter
                sqlDataAdapter.SelectCommand.Parameters.Add("@RequestNo", SqlDbType.VarChar).Value = RequestNo;
                DataSet dataSetStud = new DataSet();                                                                                                                                                //create new data set
                sqlConnection.Open();
                sqlDataAdapter.Fill(dataSetStud);

                objGV.DataSource = dataSetStud;
                objGV.DataBind();

                using (StringWriter sw = new StringWriter())
                {
                    using (HtmlTextWriter hw = new HtmlTextWriter(sw))
                    {
                        objGV.RenderControl(hw);
                        StringReader sr          = new StringReader(sw.ToString());
                        string       mailSubject = "LABOUR REQUEST-" + dlCompany.SelectedItem.Text;
                        string       message     = "Dear GDLC, <br><br>";
                        message += "Please find below labour request submitted by <strong>" + dlCompany.SelectedItem.Text + "</strong> from the Client Portal. <br><br> ";
                        message += "Request No: " + RequestNo + "<br>";
                        message += "Terminal : " + txtTerminal.Text + "<br>";
                        message += "Request Date : " + dpReqdate.SelectedDate.Value.ToString("dd-MMM-yyyy") + "<br>";
                        message += "Vessel : " + txtVessel.Text + "<br>";
                        message += "DOA : " + dpDOA.SelectedDate.Value.ToString("dd-MMM-yyyy") + "<br>";
                        message += "Activity : " + dlActivity.SelectedText + "<br>";
                        message += "WorkShift : " + dlWorkShift.SelectedText + "<br>";
                        message += sw.ToString() + "<br><br>";
                        message += "<strong><a href='https://gdlcwave.com/' target='_blank'>Click here</a></strong> to log on to the portal for more details. <br /><br />";
                        message += "<strong>This is an auto generated email. Please do not reply.</strong>";
                        MailMessage myMessage = new MailMessage();
                        myMessage.From = (new MailAddress("*****@*****.**", "GDLC Client Portal"));
                        myMessage.To.Add(new MailAddress(requestEmail));
                        myMessage.Bcc.Add(new MailAddress("*****@*****.**"));
                        myMessage.Subject    = mailSubject;
                        myMessage.Body       = message;
                        myMessage.IsBodyHtml = true;
                        SmtpClient mySmtpClient = new SmtpClient();
                        mySmtpClient.Send(myMessage);
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "mailsuccess", "toastr.success('Email Sent Successfully', 'Success');", true);
                        mailSent = true;
                    }
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "mailerror", "toastr.error('" + ex.Message.Replace("'", "").Replace("\r\n", "") + "', 'Error');", true);
            }
            return(mailSent);
        }
Ejemplo n.º 27
0
        public void RowChangeCell(DataTable _dt)
        {
            try
            {
                DataTable Rdt = new DataTable();
                decimal[] Tol;

                //为Rdt添加列
                Rdt.Columns.Add(new DataColumn("PX", System.Type.GetType("System.String")));
                Rdt.Columns.Add(new DataColumn("Tol", System.Type.GetType("System.Decimal")));
                Rdt.Columns.Add(new DataColumn("DATETIME", System.Type.GetType("System.DateTime")));
                Rdt.Columns.Add(new DataColumn("Note", System.Type.GetType("System.String")));
                if (_dt.Rows.Count > 0)
                {
                    string   ControlInfo = _dt.Rows[0]["ControlInfo"].ToString();
                    string[] arr         = ControlInfo.Split('|');
                    Tol = new decimal[arr.Length];  //总数列
                    //为每一个列赋值
                    for (int i = 0; i < Tol.Length; i++)
                    {
                        Tol[i] = 0;
                    }

                    for (int i = 0; i < arr.Length; i++)
                    {
                        string[] a = arr[i].Split(',');

                        Rdt.Columns.Add(new DataColumn(a[1], System.Type.GetType("System.Decimal")));
                    }

                    DataRow _dRow;
                    int     Rnum = 1;
                    //为每行赋值
                    foreach (DataRow ds in _dt.Rows)
                    {
                        _dRow = Rdt.NewRow();

                        _dRow["PX"]       = Rnum.ToString();
                        _dRow["DATETIME"] = ds["DATETIME"];
                        string[] _arr = ds["ControlInfo"].ToString().Split('|');
                        for (int i = 0; i < _arr.Length; i++)
                        {
                            string[] a = _arr[i].Split(',');
                            _dRow[a[1]] = decimal.Parse(a[2]);
                            decimal D = 0;
                            if (!string.IsNullOrEmpty(_dRow["Tol"].ToString()))
                            {
                                D = decimal.Parse(_dRow["Tol"].ToString());
                            }
                            _dRow["Tol"] = D + decimal.Parse(a[2]);
                            Tol[i]       = Tol[i] + decimal.Parse(a[2]);
                        }
                        _dRow["Note"] = ds["NOTES"];
                        Rdt.Rows.Add(_dRow);
                        Rnum++;
                    }

                    //汇总值添加进表中,同时为gridview添加新列
                    _dRow       = Rdt.NewRow();
                    _dRow["PX"] = "汇总";
                    decimal dec = 0;
                    for (int i = 4; i < Rdt.Columns.Count; i++)
                    {
                        dec     += Tol[i - 4];
                        _dRow[i] = Tol[i - 4];
                        BoundField f = new BoundField();
                        f.DataField            = Rdt.Columns[i].ColumnName;
                        f.HeaderText           = Rdt.Columns[i].ColumnName;
                        f.HeaderStyle.CssClass = "HeaderStyle11";
                        f.ItemStyle.CssClass   = "ItemStyle11";
                        GridView1.Columns.Add(f);
                    }
                    _dRow["Tol"] = dec;
                    Rdt.Rows.Add(_dRow);
                    BoundField bf = new BoundField();
                    bf.DataField            = "Tol";
                    bf.HeaderText           = "总金额";
                    bf.HeaderStyle.CssClass = "HeaderStyle12";
                    bf.ItemStyle.CssClass   = "ItemStyle12";
                    GridView1.Columns.Add(bf);

                    //最后添加时间列
                    bf                      = new BoundField();
                    bf.DataField            = "DATETIME";
                    bf.HeaderText           = "时间";
                    bf.HeaderStyle.CssClass = "HeaderStyle12";
                    bf.ItemStyle.CssClass   = "ItemStyle12";
                    bf.DataFormatString     = "{0:yyyy-MM-dd}";
                    GridView1.Columns.Add(bf);

                    //付全文    2013-4-11   备注
                    bf                      = new BoundField();
                    bf.DataField            = "Note";
                    bf.HeaderText           = "备注";
                    bf.HeaderStyle.CssClass = "HeaderStyle12";
                    bf.ItemStyle.CssClass   = "ItemStyle12";
                    GridView1.Columns.Add(bf);
                }

                GridView1.Visible    = true;
                GridView1.DataSource = Rdt; //指定GridView1的数据是dv
                GridView1.DataBind();       //将上面指定的信息绑定到GridView1上
            }
            catch { }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 绑定Gridview
        /// </summary>
        private void BindGridView()
        {
            using (db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
            {
                BoundField bfColumn;
                //添加选择列

                foreach (var kvp in Titlelist)
                {
                    bfColumn            = new BoundField();
                    bfColumn.HeaderText = kvp.Split(':')[0];
                    bfColumn.DataField  = kvp.Split(':')[1];
                    this.gv.Columns.Add(bfColumn);
                }
                this.gv.DataSource = from a in db.StorageInQualified
                                     join b in db.StorageIn on a.StorageInID equals b.StorageInID
                                     join c in db.MaterialInfo on a.MaterialID equals c.MaterialID
                                     join d in db.PileInfo on a.PileID equals d.PileID
                                     join e in db.SupplierInfo on a.SupplierID equals e.SupplierID

                                     where a.StorageInID == Convert.ToInt32(Request.QueryString["StorageInID"]) && a.BatchIndex == Request.QueryString["QCBatch"].ToString()
                                     select new
                {
                    a.StorageInQualifiedID,
                    b.StorageInCode,
                    a.SpecificationModel,
                    a.BatchIndex,
                    c.MaterialName,
                    c.MaterialCode,
                    a.Quantity,
                    a.QuantityGentaojian,
                    a.QuantityMetre,
                    a.QuantityTon,
                    a.CurUnit,
                    a.UnitPrice,
                    a.Amount,
                    a.NumberQualified,
                    a.InspectionReportNum,
                    a.InspectionTime,
                    d.StorageInfo.StorageName,
                    d.PileCode,
                    a.financeCode,
                    a.StorageTime,
                    e.SupplierName,
                    MaterialsManager = db.EmpInfo.SingleOrDefault(u => u.EmpID == a.MaterialsManager).EmpName,
                    WarehouseWorker  = db.EmpInfo.SingleOrDefault(u => u.EmpID == a.WarehouseWorker).EmpName,

                    a.Remark
                };
                this.gv.DataBind();
                //btnSend = new Button();
                //btnSend.Text ="发送审核";
                //btnSend.Click +=new EventHandler(btnSend_Click);
                //btnCannel = new Button();
                //btnCannel.Text = "取消";
                //btnCannel.Click += new EventHandler(btnCannel_Click);
                Panel p1 = (Panel)GetControltByMaster("Panel1");

                p1.Controls.Add(this.gv);
                //p1.Controls.Add(btnSend);
                //p1.Controls.Add(btnCannel);
            }
        }
        private void BindGrid()
        {
            if (ViewState["Sorted"] != null)
            {
                IPatientTransfer PatientTransferMgr = (IPatientTransfer)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BPatientTransfer, BusinessProcess.Clinical");
                DataSet          theDS = PatientTransferMgr.GetSatelliteLocation(PatientId.ToString(), TransferId, 0, Session["SystemId"].ToString());
                txtLocationName.Text = theDS.Tables[0].Rows[0]["CurrentSatName"].ToString();
                BindFunctions BindManager = new BindFunctions();
                IQCareUtils   theUtils    = new IQCareUtils();
                DataView      theDV       = new DataView(theDS.Tables[1]);
                DataTable     theDT       = new DataTable();
                if (theDV.Table != null)
                {
                    theDT = (DataTable)theUtils.CreateTableFromDataView(theDV);
                    BindManager.BindCombo(ddSatellite, theDT, "Name", "ID");
                    theDV.Dispose();
                    theDT.Clear();
                }
                GrdTransfer.DataSource = theDS.Tables[2];
                if (ViewState["grdDataSource"] == null)
                {
                    ViewState["grdDataSource"] = theDS.Tables[2];
                }
            }

            ViewState["Sorted"] = "";
            BoundField theCol0 = new BoundField();

            theCol0.HeaderText           = "ID";
            theCol0.DataField            = "ID";
            theCol0.HeaderStyle.CssClass = "textstylehidden";
            theCol0.ItemStyle.CssClass   = "textstylehidden";
            theCol0.ReadOnly             = true;

            BoundField theCol1 = new BoundField();

            theCol1.HeaderText         = "From Location";
            theCol1.DataField          = "TransferfromSatellite";
            theCol1.ItemStyle.CssClass = "textstyle";
            theCol1.SortExpression     = "TransferfromSatellite";
            theCol1.ReadOnly           = true;

            BoundField theCol2 = new BoundField();

            theCol2.HeaderText         = "To Location";
            theCol2.DataField          = "TransfertoSatellite";
            theCol2.ItemStyle.CssClass = "textstyle";
            theCol2.SortExpression     = "TransfertoSatellite";
            theCol2.ReadOnly           = true;

            BoundField theCol3 = new BoundField();

            theCol3.HeaderText         = "Transferred Date";
            theCol3.DataField          = "TransferredDate";
            theCol3.ItemStyle.CssClass = "textstyle";
            theCol3.SortExpression     = "TransferredDate";
            theCol3.ReadOnly           = true;

            ButtonField theBtn = new ButtonField();

            theBtn.ButtonType           = ButtonType.Link;
            theBtn.CommandName          = "Select";
            theBtn.HeaderStyle.CssClass = "textstylehidden";
            theBtn.ItemStyle.CssClass   = "textstylehidden";

            GrdTransfer.Columns.Add(theCol0);
            GrdTransfer.Columns.Add(theCol1);
            GrdTransfer.Columns.Add(theCol2);
            GrdTransfer.Columns.Add(theCol3);
            GrdTransfer.Columns.Add(theBtn);
            GrdTransfer.DataBind();
        }
Ejemplo n.º 30
0
        void BindShippingCalculationTable(bool addInsertRow)
        {
            //clear the columns to prevent duplicates
            ShippingGrid.Columns.Clear();

            //We're going to assemble the datasource that we need by putting it together manually here.
            using (DataTable gridData = new DataTable())
            {
                //We'll need shipping method shipping charge amounts to work with in building the data source
                using (DataTable methodAmountsData = new DataTable())
                {
                    //Populate shipping methods data
                    using (SqlConnection sqlConnection = new SqlConnection(DB.GetDBConn()))
                    {
                        sqlConnection.Open();

                        string getShippingMethodMapping       = "exec aspdnsf_GetStoreShippingMethodMapping @StoreID = @StoreId, @IsRTShipping = 0, @OnlyMapped = @FilterByStore";
                        var    getShippingMethodMappingParams = new[]
                        {
                            new SqlParameter("@StoreId", SelectedStoreId),
                            new SqlParameter("@FilterByStore", FilterShipping),
                        };

                        using (IDataReader rs = DB.GetRS(getShippingMethodMapping, getShippingMethodMappingParams, sqlConnection))
                            methodAmountsData.Load(rs);
                    }

                    if (methodAmountsData.Rows.Count == 0)
                    {
                        AlertMessage.PushAlertMessage(String.Format("You do not have any shipping methods setup for the selected store. Please <a href=\"{0}\">click here</a> to set them up.", AppLogic.AdminLinkUrl("shippingmethods.aspx")), AspDotNetStorefrontControls.AlertMessage.AlertType.Error);
                        ShippingRatePanel.Visible = false;
                        return;
                    }

                    using (DataTable shippingRangeData = new DataTable())
                    {
                        using (SqlConnection sqlConnection = new SqlConnection(DB.GetDBConn()))
                        {
                            //populate the shipping range data
                            var sqlShipping = @"SELECT DISTINCT sw.RowGuid, sw.LowValue, sw.HighValue
									FROM ShippingWeightByZone sw WITH (NOLOCK)
									INNER JOIN ShippingMethod sm WITH (NOLOCK) ON sm.ShippingMethodid = sw.ShippingMethodId AND (@FilterByStore = 0 or @StoreId = sw.StoreID)
									WHERE sw.ShippingZoneID = @ZoneId
									ORDER BY LowValue"                                    ;

                            var shippingRangeDataParams = new[]
                            {
                                new SqlParameter("@StoreId", SelectedStoreId),
                                new SqlParameter("@FilterByStore", FilterShipping),
                                new SqlParameter("@ZoneId", SelectedZoneId),
                            };

                            sqlConnection.Open();
                            using (IDataReader rs = DB.GetRS(sqlShipping, shippingRangeDataParams, sqlConnection))
                                shippingRangeData.Load(rs);
                        }

                        //Add the data columns we'll need on our table and add grid columns to match
                        gridData.Columns.Add(new DataColumn("RowGuid", typeof(string)));

                        gridData.Columns.Add(new DataColumn("LowValue", typeof(string)));
                        BoundField boundField = new BoundField();
                        boundField.DataField             = "LowValue";
                        boundField.HeaderText            = "Low";
                        boundField.ControlStyle.CssClass = "text-xs";
                        ShippingGrid.Columns.Add(boundField);

                        gridData.Columns.Add(new DataColumn("HighValue", typeof(string)));
                        boundField                       = new BoundField();
                        boundField.DataField             = "HighValue";
                        boundField.HeaderText            = "High";
                        boundField.ControlStyle.CssClass = "text-xs";
                        ShippingGrid.Columns.Add(boundField);

                        //Add shipping method columns to our grid data
                        foreach (DataRow methodAmountsRow in methodAmountsData.Rows)
                        {
                            var columnName = String.Format("MethodAmount_{0}", DB.RowField(methodAmountsRow, "ShippingMethodID"));
                            gridData.Columns.Add(new DataColumn(columnName, typeof(string)));
                            //add a column to the gridview to hold the data
                            boundField                       = new BoundField();
                            boundField.DataField             = columnName;
                            boundField.HeaderText            = DB.RowFieldByLocale(methodAmountsRow, "Name", LocaleSetting);
                            boundField.ControlStyle.CssClass = "text-xs";
                            ShippingGrid.Columns.Add(boundField);
                        }

                        //now that our columns are setup add rows to our table
                        foreach (DataRow rangeRow in shippingRangeData.Rows)
                        {
                            var newRow = gridData.NewRow();
                            //add the range data
                            newRow["RowGuid"]   = rangeRow["RowGuid"];
                            newRow["LowValue"]  = rangeRow["LowValue"];
                            newRow["HighValue"] = rangeRow["HighValue"];
                            //add shipping method amounts to our grid data
                            foreach (DataRow methodAmountsRow in methodAmountsData.Rows)
                            {
                                var shippingMethodId  = DB.RowFieldInt(methodAmountsRow, "ShippingMethodID");
                                var shippingRangeGuid = DB.RowFieldGUID(rangeRow, "RowGUID");
                                var amount            = Shipping.GetShipByWeightAndZoneCharge(SelectedZoneId, shippingMethodId, shippingRangeGuid);
                                var localizedAmount   = Localization.CurrencyStringForDBWithoutExchangeRate(amount);

                                var colName = String.Format("MethodAmount_{0}", shippingMethodId);
                                newRow[colName] = localizedAmount;
                            }

                            gridData.Rows.Add(newRow);
                        }

                        //if we're inserting, add an empty row to the end of the table
                        if (addInsertRow)
                        {
                            var newRow = gridData.NewRow();
                            //add the range data
                            newRow["RowGuid"]   = 0;
                            newRow["LowValue"]  = 0;
                            newRow["HighValue"] = 0;
                            //add shipping method columns to our insert row
                            foreach (DataRow methodAmountsRow in methodAmountsData.Rows)
                            {
                                var shippingMethodId = DB.RowFieldInt(methodAmountsRow, "ShippingMethodID");
                                var amount           = 0;
                                var localizedAmount  = Localization.CurrencyStringForDBWithoutExchangeRate(amount);

                                var colName = String.Format("MethodAmount_{0}", shippingMethodId);
                                newRow[colName] = localizedAmount;
                            }
                            gridData.Rows.Add(newRow);
                            //if we're inserting than we'll want to make the insert row editable
                            ShippingGrid.EditIndex = gridData.Rows.Count - 1;
                        }


                        //add the delete button column
                        ButtonField deleteField = new ButtonField();
                        deleteField.ButtonType            = ButtonType.Link;
                        deleteField.Text                  = "<i class=\"fa fa-times\"></i> Delete";
                        deleteField.CommandName           = "Delete";
                        deleteField.ControlStyle.CssClass = "delete-link";
                        deleteField.ItemStyle.Width       = 94;
                        ShippingGrid.Columns.Add(deleteField);

                        //add the edit button column
                        CommandField commandField = new CommandField();
                        commandField.ButtonType            = ButtonType.Link;
                        commandField.ShowEditButton        = true;
                        commandField.ShowDeleteButton      = false;
                        commandField.ShowCancelButton      = true;
                        commandField.ControlStyle.CssClass = "edit-link";
                        commandField.EditText        = "<i class=\"fa fa-share\"></i> Edit";
                        commandField.CancelText      = "<i class=\"fa fa-reply\"></i> Cancel";
                        commandField.UpdateText      = "<i class=\"fa fa-floppy-o\"></i> Save";
                        commandField.ItemStyle.Width = 84;
                        ShippingGrid.Columns.Add(commandField);

                        ShippingGrid.DataSource = gridData;
                        ShippingGrid.DataBind();
                    }
                }
            }

            btnInsert.Visible = !addInsertRow;                  //Hide the 'add new row' button while editing/inserting to avoid confusion and lost data
        }
 public override void SetStylesAndFormats(BoundField column, string format)
 {
     column.DataFormatString            = format == string.Empty ? "{0:#,###,##0.0###}" : string.Format("{{0:{0}}}", format);
     column.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
     column.ItemStyle.HorizontalAlign   = HorizontalAlign.Right;
 }
Ejemplo n.º 32
0
    private void TestFarmerBinding()
    {
        string    seasonYr        = "2014";
        DataTable dtSeasonDetails = cp.GetSeasonDetails(seasonYr);


        DataTable dt = new DataTable();

        dt.Columns.Add(new DataColumn("Product Id", typeof(int)));
        dt.Columns.Add(new DataColumn("Product Name", typeof(string)));
        foreach (DataRow item in dtSeasonDetails.Rows)
        {
            DataColumn dc = new DataColumn(Convert.ToString(item["SeasonName"]), typeof(string));
            dt.Columns.Add(dc);

            dc = new DataColumn(Convert.ToString(item["SeasonId"]), typeof(string));
            dt.Columns.Add(dc);
        }
        DataTable dtProds = prod.GetProductDetailsNew();

        foreach (DataRow item in dtProds.Rows)
        {
            DataRow newRow = dt.NewRow();
            newRow[0] = Convert.ToInt32(item["ProductId"]);
            newRow[1] = Convert.ToString(item["ProductName"]);
            for (int i = 2; i < dt.Columns.Count; i++)
            {
                if (i % 2 == 0)
                {
                    newRow[i] = bool.FalseString;
                }
                else
                {
                    newRow[i] = Convert.ToString(dt.Columns[i].ColumnName);
                }
            }
            dt.Rows.Add(newRow);
        }
        //dt = dt;
        gvfarmdetails.Columns.Clear();
        for (int i = 0; i < dt.Columns.Count; i++)
        {
            if (i == 1)
            {
                BoundField boundField = new BoundField();
                boundField.DataField  = "Product Name";
                boundField.HeaderText = "";
                gvfarmdetails.Columns.Add(boundField);
            }
            else if (i == 0)
            {
                BoundField boundField = new BoundField();
                boundField.DataField  = "Product Id";
                boundField.HeaderText = "";
                //boundField.Visible = false;
                gvfarmdetails.Columns.Add(boundField);
            }
            else if (i % 2 == 0 && i >= 2)
            {
                TemplateField templateField = new TemplateField();
                templateField.HeaderText = dt.Columns[i].ColumnName;
                gvfarmdetails.Columns.Add(templateField);
            }
            else if (i % 2 == 1 && i >= 2)
            {
                BoundField boundField = new BoundField();
                boundField.DataField  = dt.Columns[i].ColumnName;
                boundField.HeaderText = dt.Columns[i].ColumnName;
                //boundField.Visible = false;
                gvfarmdetails.Columns.Add(boundField);
            }
        }

        gvfarmdetails.DataSource = dt;
        gvfarmdetails.DataBind();
    }
    protected GridView bindDataByCountry(GridView gv, DataSet ds, string header)
    {
        if (ds != null)
        {
            gv.Visible = true;
            gv.Width = Unit.Pixel(650);
            gv.AutoGenerateColumns = false;
            gv.AllowPaging = false;

            for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            {
                BoundField bf = new BoundField();

                bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString();
                bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString();
                bf.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;

                if (i == 0)
                {
                    bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                    bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
                    if (header != "")
                        bf.ItemStyle.Width = 250;
                }

                bf.ReadOnly = true;
                gv.Columns.Add(bf);
            }

            if (header != "")
            {
                gv.Caption = "<br />" + header;
                gv.CaptionAlign = TableCaptionAlign.Left;
                gv.AllowSorting = true;
                gv.DataSource = ds.Tables[0];

                DataRow drSum = ds.Tables[0].NewRow();
                float[] Sum = new float[50];
                for (int j = 1; j < ds.Tables[0].Columns.Count; j++)
                {
                    Sum[j] = 0;
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        Sum[j] += float.Parse(ds.Tables[0].Rows[i][j].ToString());
                    }
                }

                for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
                {
                    if (i == 0)
                    {
                        if (header.Substring(0, 3) != "Tot")
                            drSum[0] = "Total(" + header + ")";
                        else
                            drSum[0] = header;
                    }
                    else
                    {
                        drSum[i] = Sum[i].ToString();
                    }
                }
                ds.Tables[0].Rows.InsertAt(drSum, ds.Tables[0].Rows.Count);

                gv.DataBind();
                return gv;
            }
            else
            {
                gv.Caption = "<br />" + "GROUP REGION";
                gv.CaptionAlign = TableCaptionAlign.Left;
                gv.DataSource = ds.Tables[0];
                gv.DataBind();
                return gv;
            }
        }
        else
        {
            gv.Visible = false;
            return gv;
        }
    }
Ejemplo n.º 34
0
    /// <summary>
    /// Bind the data.
    /// </summary>
    public void Bind()
    {
        if (!string.IsNullOrEmpty(ObjectType))
        {
            pnlGrid.Visible = true;

            // Initialize strings
            btnAllTasks.Text  = GetString("ImportExport.All");
            btnNoneTasks.Text = GetString("export.none");
            lblTasks.Text     = GetString("Export.Tasks");

            // Get object info
            GeneralizedInfo info = ModuleManager.GetReadOnlyObject(ObjectType);
            if (info != null)
            {
                gvTasks.RowDataBound += gvTasks_RowDataBound;
                plcGrid.Visible       = true;
                codeNameColumnName    = info.CodeNameColumn;
                displayNameColumnName = info.DisplayNameColumn;

                // Task fields
                TemplateField taskCheckBoxField = (TemplateField)gvTasks.Columns[0];
                taskCheckBoxField.HeaderText = GetString("General.Export");

                TemplateField titleField = (TemplateField)gvTasks.Columns[1];
                titleField.HeaderText = GetString("Export.TaskTitle");

                BoundField typeField = (BoundField)gvTasks.Columns[2];
                typeField.HeaderText = GetString("general.type");

                BoundField timeField = (BoundField)gvTasks.Columns[3];
                timeField.HeaderText = GetString("Export.TaskTime");

                // Load tasks
                int siteId = (SiteObject ? Settings.SiteId : 0);

                DataSet ds = ExportTaskInfoProvider.SelectTaskList(siteId, ObjectType, null, "TaskTime DESC", 0, null, CurrentOffset, CurrentPageSize, ref pagerForceNumberOfResults);

                // Set correct ID for direct page contol
                pagerElem.DirectPageControlID = ((float)pagerForceNumberOfResults / pagerElem.CurrentPageSize > 20.0f) ? "txtPage" : "drpPage";

                // Call page binding event
                if (OnPageBinding != null)
                {
                    OnPageBinding(this, null);
                }

                if (!DataHelper.DataSourceIsEmpty(ds) && (ValidationHelper.GetBoolean(Settings.GetSettings(ImportExportHelper.SETTINGS_TASKS), true)))
                {
                    plcTasks.Visible   = true;
                    gvTasks.DataSource = ds;
                    gvTasks.DataBind();
                }
                else
                {
                    plcTasks.Visible = false;
                }
            }
            else
            {
                plcGrid.Visible = false;
            }
        }
        else
        {
            pnlGrid.Visible = false;
        }
    }
Ejemplo n.º 35
0
        private string GenerateExportData(string dataFormat)
        {
            border = (dataFormat == "Print" ? "0" : "1");
            DataSet _dsPriceData = Session["PriceAnalysisData"] as DataSet;
            dtExcelData = new DataTable();

            string styleSheet = "<style>.text { mso-number-format:\\@; } </style>";
            string headerContent = string.Empty;
            string footerContent = string.Empty;
            string excelContent = string.Empty;

            dtExcelData = _dsPriceData.Tables[1];

            headerContent = "<table border='" + border + "' width='100%'>";
            headerContent += "<tr><th colspan='14' style='color:blue' align=left><center>Price Analysis Report</center></th></tr>";
            headerContent +=    "<tr>" + 
                                "<td colspan='3'><b>"+ lblBeginDate.Text + "</b></td>" + 
                                "<td colspan='3'><b>" + lblEndDate.Text + "</b></td>" +
                                "<td colspan='3'><b>" + lblBranch.Text + "</b></td>" +
                                "<td colspan='3'><b>" + lblCustomerNumber.Text + "</b></td>" +
                                "<td colspan='2'></td>" +
                                "</tr>";
            headerContent += "<tr>" +
                               "<td colspan='3'><b>" + lblHistExtSell.Text + "</b></td>" +
                               "<td colspan='3'><b>" + lblHistExtGM.Text + "</b></td>" +
                               "<td colspan='3'><b>" + lblHistGMPct.Text + "</b></td>" +
                               "<td colspan='3'><b>" + lblSAvgSuggGMPct.Text + "</b></td>" +
                               "<td colspan='2'><b>" + (hidShowAvgCost.Value == "TRUE" ? lblSuggGMPct.Text : "") + "</b></td>" +
                               "</tr>";

            headerContent += "<tr>" +
                              "<td colspan='3'><b>" + lblHistExtLbs.Text + "</b></td>" +
                              "<td colspan='3'><b>" + lblHistSellPerLb.Text + "</b></td>" +
                              "<td colspan='3'><b>" + lblHistGMPerLb.Text + "</b></td>" +
                              "<td colspan='3'><b>Run By: " + Session["UserName"].ToString() + "&nbsp;&nbsp;  Run Date: " + DateTime.Now.ToShortDateString() + "</b></td>" +
                              "<td colspan='2'></td>" +
                              "</tr>";

             headerContent += "<tr><th colspan='14' style='color:blue' align=left></th></tr>";

            if (dtExcelData.Rows.Count > 0)
            {
                dv.AutoGenerateColumns = false;
                dv.ShowHeader = true;
                dv.ShowFooter = true;                

                BoundField bfExcel = new BoundField();
                bfExcel.HeaderText = "Item No";
                bfExcel.DataField = "ItemNo";
                bfExcel.ItemStyle.HorizontalAlign = HorizontalAlign.Left;                
                dv.Columns.Add(bfExcel);

                bfExcel = new BoundField();
                bfExcel.HeaderText = "Sugg Price Alt";
                bfExcel.DataField = "SuggestedPriceAlt";
                bfExcel.ItemStyle.HorizontalAlign = HorizontalAlign.Right;                
                dv.Columns.Add(bfExcel);

                bfExcel = new BoundField();
                bfExcel.HeaderText = "Hist Sell Price Alt";
                bfExcel.DataField = "SellUM";
                bfExcel.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                dv.Columns.Add(bfExcel);

                bfExcel = new BoundField();
                bfExcel.HeaderText = "Sugg Price Method";
                bfExcel.DataField = "SuggestedPriceMethod";
                bfExcel.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                dv.Columns.Add(bfExcel);

                if (hidShowAvgCost.Value == "TRUE")
                {
                    bfExcel = new BoundField();
                    bfExcel.HeaderText = "Avg Sugg GM Pct";
                    bfExcel.DataField = "AVGSuggGMPct";
                    bfExcel.DataFormatString = "{0:0.0%}";
                    bfExcel.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                    dv.Columns.Add(bfExcel);
                }
                
                bfExcel = new BoundField();
                bfExcel.HeaderText = "SAvg Sugg GM Pct";
                bfExcel.DataField = "SMTHAVGSuggGMPct";
                bfExcel.DataFormatString = "{0:0.0%}";
                bfExcel.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                dv.Columns.Add(bfExcel);
            

                bfExcel = new BoundField();
                bfExcel.HeaderText = "GM Pct";
                bfExcel.DataField = "GMPct";
                bfExcel.DataFormatString = "{0:0.0%}";
                bfExcel.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                dv.Columns.Add(bfExcel);

                bfExcel = new BoundField();
                bfExcel.HeaderText = "Qty Shipped";
                bfExcel.DataField = "QtyShipped";
                bfExcel.DataFormatString = "{0:#,##}";
                bfExcel.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                dv.Columns.Add(bfExcel);

                bfExcel = new BoundField();
                bfExcel.HeaderText = "Ext. Lines";
                bfExcel.DataField = "ExtLines";
                bfExcel.DataFormatString = "{0:#,##}";
                bfExcel.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                dv.Columns.Add(bfExcel);

                bfExcel = new BoundField();
                bfExcel.HeaderText = "Ext. Sell";
                bfExcel.DataField = "ExtSell";
                bfExcel.DataFormatString = "{0:#,##0.00}";
                bfExcel.ItemStyle.HorizontalAlign = HorizontalAlign.Right;                
                dv.Columns.Add(bfExcel);

                bfExcel = new BoundField();
                bfExcel.HeaderText = "Ext. GM";
                bfExcel.DataField = "ExtGM";
                bfExcel.DataFormatString = "{0:#,##0.00}";
                bfExcel.ItemStyle.HorizontalAlign = HorizontalAlign.Right;                
                dv.Columns.Add(bfExcel);

                

                bfExcel = new BoundField();
                bfExcel.HeaderText = "Ext. Lbs";
                bfExcel.DataField = "ExtLbs";
                bfExcel.DataFormatString = "{0:#,##0.00}";
                bfExcel.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                dv.Columns.Add(bfExcel);

                bfExcel = new BoundField();
                bfExcel.HeaderText = "Sell Per Lb";
                bfExcel.DataField = "SellPerLb";
                bfExcel.DataFormatString = "{0:#,##0.000}";
                bfExcel.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                dv.Columns.Add(bfExcel);

                bfExcel = new BoundField();
                bfExcel.HeaderText = "GM Per Lb";
                bfExcel.DataField = "GMPerLb";
                bfExcel.DataFormatString = "{0:#,##0.000}";
                bfExcel.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                dv.Columns.Add(bfExcel);
                               
                dv.DataSource = dtExcelData;
                dv.DataBind();

                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                System.IO.StringWriter sw = new System.IO.StringWriter(sb);
                HtmlTextWriter htw = new HtmlTextWriter(sw);
                dv.RenderControl(htw);
                excelContent = sb.ToString();

            }
            else
            {
                excelContent = "<tr  ><th width='100%' align ='center' colspan='21' > No records found</th></tr> </table>";
            }

            return styleSheet + headerContent + excelContent;
        }
    protected GridView showBookingsByProduct(DataSet ds, GridView gv, string header)
    {
        if (ds != null)
        {
            gv.AutoGenerateColumns = false;
            gv.Width = Unit.Pixel(300);
            gv.Columns.Clear();

            //Calculate the VAR column and Total row of next year.
            try
            {
                ds.Tables[0].Columns.Add("VAR");
                if (ds.Tables[0].Rows[0][0] != DBNull.Value)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        float tmp = 0;
                        if (float.Parse(dr[2].ToString()) != 0)
                        {
                            tmp = (float.Parse(dr[1].ToString()) - float.Parse(dr[2].ToString())) * 100 / float.Parse(dr[2].ToString());
                            dr["VAR"] = Convert.ToInt32(tmp).ToString() + "%";
                        }
                    }
                }
            }
            catch
            {
                log.WriteLog(LogUtility.LogErrorLevel.LOG_ERROR, "Format string to float Error.");
                Response.Redirect("~/Admin/AdminError.aspx");
            }

            for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            {
                BoundField bf = new BoundField();

                bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString();
                bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString();
                bf.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
                if (i == 0)
                {
                    bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                    bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
                }
                bf.ReadOnly = true;

                gv.Columns.Add(bf);
            }
            gv.Caption = header;
            gv.CaptionAlign = TableCaptionAlign.Top;
            gv.DataSource = ds;
            gv.DataBind();
        }
        return gv;
    }
Ejemplo n.º 37
0
        /// <summary>
        /// 绑定Gridview
        /// </summary>
        private void BindGridView()
        {
            using (db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
            {
                BoundField bfColumn;

                foreach (var kvp in Titlelist)
                {
                    bfColumn            = new BoundField();
                    bfColumn.HeaderText = kvp.Split(':')[0];
                    bfColumn.DataField  = kvp.Split(':')[1];
                    this.gv.Columns.Add(bfColumn);
                }


                //添加选择列
                TemplateField tfieldCheckbox = new TemplateField();
                tfieldCheckbox.ItemTemplate   = new CheckBoxTemplate("请选择", DataControlRowType.DataRow, "StorageInID");
                tfieldCheckbox.HeaderTemplate = new CheckBoxTemplate("请选择", DataControlRowType.Header);
                this.gv.Columns.Insert(0, tfieldCheckbox);

                SPMenuField colMenu = new SPMenuField();
                colMenu.HeaderText     = "交货通知单编号";
                colMenu.TextFields     = "StorageInCode";
                colMenu.MenuTemplateId = "actionMenu";

                colMenu.NavigateUrlFields       = "StorageInID";              //定义方式:"列名1,列名2..."
                colMenu.NavigateUrlFormat       = "StorageDetailedManage.aspx?StorageInID={0}";
                colMenu.TokenNameAndValueFields = "curStorageID=StorageInID"; //定义方式:"别名1=列名1,别名2=列名2...."

                MenuTemplate menuItemCollection = new MenuTemplate();
                menuItemCollection.ID = "actionMenu";

                MenuItemTemplate createMenuItem = new MenuItemTemplate("送往物资组", "/_layouts/images/newitem.gif");
                createMenuItem.ClientOnClickNavigateUrl = "QualityControlMessage.aspx?StorageInID=%curStorageID%&&state=物资组员&&storageInType=正常入库";
                //editMenuItem.ClientOnClickScript = "if(!window.confirm('确认删除所选项?')) return false;window.location.href='StorageEdit.aspx?StorageID=%curStorageID%'";//%curStorageID%代表别名curStorageID,而StorageID代表数据库的表中的列名
                //editMenuItem.ClientOnClickScript = "window.location.href='StorageEdit.aspx?StorageID=%curStorageID%&curTime=" + DateTime.Now.ToString() + "'";

                menuItemCollection.Controls.Add(createMenuItem);
                this.Controls.Add(menuItemCollection);
                this.gv.Columns.Insert(1, colMenu);
                //this.gv.Columns.Add(hlTask);

                HyperLinkField hlTask = new HyperLinkField();
                hlTask.HeaderText = "任务详情";
                this.gv.Columns.Insert(5, hlTask);

                //hlTask.DataNavigateUrlFields={}
                // hlTask.DataNavigateUrlFormatString = "javaScript:onClick=window.showModalDialog('../PublicPage/ErrorInfo.aspx?StorageInID={0}')";



                this.gv.DataSource = from a in db.StorageInMain
                                     where a.Creator == UserLoginId
                                     select new
                {
                    a.StorageInID,
                    a.StorageInCode,
                    a.ReceivingTypeInfo.ReceivingTypeName,
                    a.Remark,
                    a.CreateTime
                };
                this.gv.RowDataBound += new GridViewRowEventHandler(gv_RowDataBound);
                this.gv.DataBind();
                this.gv.Columns[6].Visible = false;

                Panel p1 = (Panel)GetControltByMaster("Panel1");
                p1.Controls.Add(this.gv);
            }
        }
    protected void bindDataNextVSThisByDate(GridView gv)
    {
        DataSet ds = getBookingsDataNextYearVSThis(getProductBySegment(getSegmentID()), getSegmentID(), getSalesOrgID());
        if (ds != null)
        {
            gv.Visible = true;
            gv.Width = Unit.Pixel(700);
            gv.AutoGenerateColumns = false;
            gv.AllowPaging = false; ;

            //Calculate the total column of next year.
            ds.Tables[0].Columns.Add("Total");
            try
            {
                if (ds.Tables[0].Rows[0][0] != DBNull.Value)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        float tmp = 0;
                        for (int count2 = 3; count2 < ds.Tables[0].Columns.Count - 1; count2 += 2)
                        {
                            tmp += float.Parse(dr[count2].ToString());
                        }
                        dr["Total"] = tmp.ToString();
                    }
                }
            }
            catch
            {
                log.WriteLog(LogUtility.LogErrorLevel.LOG_ERROR, "Format string to float Error.");
                Response.Redirect("~/Admin/AdminError.aspx");
            }

            for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            {
                BoundField bf = new BoundField();

                bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString();
                bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString();
                bf.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
                if (i == 0)
                {
                    bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                    bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
                }
                bf.ReadOnly = true;
                gv.Columns.Add(bf);
            }

            gv.Caption = "Total" + nextyear.Substring(2, 2) + "(" + year.Substring(2, 2) + ")";
            gv.CaptionAlign = TableCaptionAlign.Top;
            gv.AllowSorting = true;
            gv.DataSource = ds.Tables[0];
            gv.DataBind();
        }
        else
            gv.Visible = false;
    }
Ejemplo n.º 39
0
        /// <summary>
        /// 绑定Gridview
        /// </summary>
        private void BindGridView()
        {
            this.spgviewRelation.Columns.Clear();
            if (this.rbtnBusiness.Checked)
            {
                Tlist[0] = "项目名称:ProjectName";
                Tlist[1] = "项目编码:ProjectCode";
                Tlist[2] = "井性:ProjectProperty";
            }
            else
            {
                Tlist[0] = "施工方名称:BusinessUnitName";
                Tlist[1] = "施工方编码:BusinessUnitCode";
                Tlist[2] = "施工方所属单位:BusinessUnitTypeName";
            }
            using (MMSProDBDataContext db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
            {
                BoundField bfColumn;
                //添加选择列
                TemplateField tfieldCheckbox = new TemplateField();
                if (this.rbtnBusiness.Checked)
                {
                    tfieldCheckbox.ItemTemplate = new CheckBoxTemplate("请选择", DataControlRowType.DataRow, "ProjectID");
                }
                else
                {
                    tfieldCheckbox.ItemTemplate = new CheckBoxTemplate("请选择", DataControlRowType.DataRow, "BusinessUnitID");
                }
                tfieldCheckbox.HeaderTemplate = new CheckBoxTemplate("请选择", DataControlRowType.Header);
                this.spgviewRelation.Columns.Add(tfieldCheckbox);
                foreach (var kvp in Tlist)
                {
                    bfColumn            = new BoundField();
                    bfColumn.HeaderText = kvp.Split(':')[0];
                    bfColumn.DataField  = kvp.Split(':')[1];
                    this.spgviewRelation.Columns.Add(bfColumn);
                }
                if (this.rbtnBusiness.Checked)
                {
                    this.spgviewRelation.DataSource = from a in db.RelationProjectBusiness
                                                      where  a.BusinessUnitID == int.Parse(this.lboxLeft.SelectedValue)
                                                      select new {
                        a.ProjectID,
                        a.ProjectInfo.ProjectCode,
                        a.ProjectInfo.ProjectName,
                        a.ProjectInfo.ProjectProperty
                    };
                }
                else
                {
                    this.spgviewRelation.DataSource = from a in db.RelationProjectBusiness
                                                      where a.ProjectID == int.Parse(this.lboxLeft.SelectedValue)
                                                      select new
                    {
                        a.BusinessUnitID,
                        a.BusinessUnitInfo.BusinessUnitName,
                        a.BusinessUnitInfo.BusinessUnitCode,
                        a.BusinessUnitInfo.BusinessUnitType.BusinessUnitTypeName
                    };
                }

                this.spgviewRelation.DataBind();

                //SPMenuField spm = new SPMenuField();
            }
        }
    protected void bindDataTotalNextVSThisByDate(GridView gv)
    {
        DataSet ds = getBookingDataTotalNextYearVSThis(getProductBySegment(getSegmentID()), getSegmentID(), getSalesOrgID());
        if (ds != null)
        {
            gv.Visible = true;
            gv.Width = Unit.Pixel(700);
            gv.AutoGenerateColumns = false;
            gv.AllowPaging = false;

            //Calculate the total column of next year.
            ds.Tables[0].Columns.Add("Total");
            try
            {
                if (ds.Tables[0].Rows[0][0] != DBNull.Value)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        float tmp = 0;
                        for (int count2 = 1; count2 < ds.Tables[0].Columns.Count - 1; count2++)
                        {
                            tmp += float.Parse(dr[count2].ToString());
                        }
                        dr["Total"] = tmp.ToString();
                    }
                }
            }
            catch
            {
                log.WriteLog(LogUtility.LogErrorLevel.LOG_ERROR, "Format string to float Error.");
                Response.Redirect("~/Admin/AdminError.aspx");
            }

            for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            {
                BoundField bf = new BoundField();

                bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString();
                bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString();
                bf.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
                if (i == 0)
                {
                    bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                    bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
                }
                bf.ReadOnly = true;
                gv.Columns.Add(bf);
            }

            gv.AllowSorting = true;
            gv.DataSource = ds.Tables[0];

            DataRow drSum = ds.Tables[0].NewRow();
            DataRow[] rows = ds.Tables[0].Select();

            float[] Sum = new float[20];
            for (int j = 1; j < ds.Tables[0].Columns.Count; j++)
            {
                Sum[j] = 0;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    Sum[j] += float.Parse(ds.Tables[0].Rows[i][j].ToString());
                }
            }

            for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            {
                if (i == 0)
                {
                    drSum[0] = "TTL/" + getAbbrBySalesOrg(getSalesOrgID());
                }
                else
                {
                    drSum[i] = Sum[i].ToString();
                }
            }
            ds.Tables[0].Rows.InsertAt(drSum, 0);
            gv.DataBind();
        }
        else
            gv.Visible = false;
    }
Ejemplo n.º 41
0
    private void BindGrid()
    {
        BoundField theCol0 = new BoundField();

        theCol0.HeaderText      = "Patientid";
        theCol0.DataField       = "Ptn_Pk";
        theCol0.ItemStyle.Width = Unit.Percentage(3);
        //theCol0.ItemStyle.CssClass = "textstyle";
        theCol0.ReadOnly = true;

        BoundField theCol1 = new BoundField();

        theCol1.HeaderText     = "Last Name";
        theCol1.DataField      = "lastname";
        theCol1.SortExpression = "lastname";
        //theCol1.ItemStyle.CssClass = "textstyle";
        theCol1.ItemStyle.Width = Unit.Percentage(5);
        theCol1.ReadOnly        = true;

        BoundField theCol2 = new BoundField();

        theCol2.HeaderText     = "Middle Name";
        theCol2.DataField      = "middlename";
        theCol2.SortExpression = "middlename";
        //theCol2.ItemStyle.CssClass = "textstyle";
        theCol2.ItemStyle.Width = Unit.Percentage(5);

        theCol2.ReadOnly = true;

        BoundField theCol3 = new BoundField();

        theCol3.HeaderText = "First Name";
        theCol3.DataField  = "firstname";
        //theCol3.ItemStyle.CssClass = "textstyle";
        theCol3.SortExpression           = "firstname";
        theCol3.ItemStyle.Font.Underline = true;
        theCol3.ItemStyle.Width          = Unit.Percentage(5);
        theCol3.ReadOnly = true;

        BoundField theCol4 = new BoundField();

        theCol4.HeaderText = "IQ Number";
        //theCol4.ItemStyle.CssClass = "textstyle";
        theCol4.DataField                 = "PatientID";
        theCol4.SortExpression            = "PatientID";
        theCol4.ItemStyle.Width           = Unit.Percentage(7);
        theCol4.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
        theCol4.ItemStyle.VerticalAlign   = VerticalAlign.Top;
        theCol4.ReadOnly = true;

        BoundField theCol5 = new BoundField();

        theCol5.HeaderText = "Services";
        //theCol5.ItemStyle.CssClass = "textstyle";
        theCol5.DataField                 = "PatientIDType";
        theCol5.SortExpression            = "PatientIDType";
        theCol5.ItemStyle.Width           = Unit.Percentage(30);
        theCol5.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
        theCol5.ItemStyle.VerticalAlign   = VerticalAlign.Top;
        theCol5.ReadOnly = true;

        BoundField theCol6 = new BoundField();

        if (((DataSet)ViewState["FacilityDS"]).Tables[0].Rows.Count > 0)
        {
            theCol6.HeaderText = ((DataSet)ViewState["FacilityDS"]).Tables[0].Rows[1][0].ToString();
        }
        //theCol4.HeaderText = "Existing Hosp/Clinic";
        //theCol6.ItemStyle.CssClass = "textstyle";
        theCol6.DataField       = "PatientClinicID";
        theCol6.SortExpression  = "PatientClinicID";
        theCol5.ItemStyle.Width = Unit.Percentage(7);
        theCol6.ReadOnly        = true;

        BoundField theCol7 = new BoundField();

        theCol7.HeaderText = "Sex";
        //theCol7.ItemStyle.CssClass = "textstyle";
        theCol7.DataField       = "Name";
        theCol7.SortExpression  = "Name";
        theCol7.ItemStyle.Width = Unit.Percentage(3);
        theCol7.ReadOnly        = true;

        BoundField theCol8 = new BoundField();

        theCol8.HeaderText = "DOB";
        theCol8.DataField  = "dob";
        //theCol8.ItemStyle.CssClass = "textstyle";
        theCol8.SortExpression  = "dob";
        theCol8.ItemStyle.Width = Unit.Percentage(5);
        theCol8.ReadOnly        = true;

        ////BoundField theCol8 = new BoundField();
        ////theCol8.HeaderText = "Village";
        ////theCol8.DataField = "VillageName";
        ////theCol8.ItemStyle.CssClass = "textstyle";
        ////theCol8.SortExpression = "VillageName";
        ////theCol8.ReadOnly = true;

        BoundField theCol9 = new BoundField();

        theCol9.HeaderText = "Status";
        theCol9.DataField  = "status";
        //theCol9.ItemStyle.CssClass = "textstyle";
        theCol9.SortExpression  = "status";
        theCol9.ItemStyle.Width = Unit.Percentage(3);
        theCol9.ReadOnly        = true;

        BoundField theCol10 = new BoundField();

        theCol10.HeaderText = "Patient Location";
        //theCol10.ItemStyle.CssClass = "textstyle";
        theCol10.DataField       = "FacilityName";
        theCol10.SortExpression  = "FacilityName";
        theCol10.ItemStyle.Width = Unit.Percentage(3);
        theCol10.ReadOnly        = true;

        BoundField theCol11 = new BoundField();

        theCol11.HeaderText      = "LocationId";
        theCol11.DataField       = "locationID";
        theCol10.ItemStyle.Width = Unit.Percentage(5);
        //theCol11.ItemStyle.CssClass = "textstyle";
        theCol11.ReadOnly = true;

        //ButtonField theBtn = new ButtonField();
        //theBtn.ButtonType = ButtonType.Link;
        //theBtn.CommandName = "Select";
        //theBtn.HeaderStyle.CssClass = "textstylehidden";
        //theBtn.ItemStyle.CssClass = "textstylehidden";

        //grdSearchResult.Columns.Add(theCol);
        grdSearchResult.Columns.Add(theCol0);
        grdSearchResult.Columns.Add(theCol1);
        grdSearchResult.Columns.Add(theCol2);
        grdSearchResult.Columns.Add(theCol3);
        grdSearchResult.Columns.Add(theCol4);
        grdSearchResult.Columns.Add(theCol5);
        grdSearchResult.Columns.Add(theCol6);
        grdSearchResult.Columns.Add(theCol7);
        grdSearchResult.Columns.Add(theCol8);
        grdSearchResult.Columns.Add(theCol9);
        grdSearchResult.Columns.Add(theCol10);
        grdSearchResult.Columns.Add(theCol11);
        //grdSearchResult.Columns.Add(theBtn);

        grdSearchResult.DataBind();
        grdSearchResult.Columns[0].Visible  = false;
        grdSearchResult.Columns[6].Visible  = false;
        grdSearchResult.Columns[11].Visible = false;
        if (Convert.ToString(Session["SystemId"]) == "1")
        {
            grdSearchResult.Columns[2].Visible = false;
        }
    }
Ejemplo n.º 42
0
    protected void bindDataSource()
    {
        bool flag = true;
        lbtn_add.Visible = false;
        DataSet dsPro = getProductInfoBySegmentID(ddlist_segment.SelectedItem.Value);
        if (dsPro.Tables[0].Rows.Count > 0)
        {
            string str_operationID = getOperationInfoByGeneralMarketingID(getGeneralMarketingID());
            if (str_operationID != "")
            {
                DataSet ds = getBacklog(dsPro, str_operationID, ddlist_saleorg.SelectedItem.Value.Trim(), ddlist_segment.SelectedItem.Value.Trim());
                if (ds.Tables[0].Rows.Count == 0)
                {
                    sql.getNullDataSet(ds);
                    flag = false;
                }

                if (ds.Tables[0].Rows.Count < 2)
                {
                    lbtn_add.Visible = true;
                }
                gv_actualBaclog.Width = Unit.Pixel(800);
                gv_actualBaclog.AutoGenerateColumns = false;
                gv_actualBaclog.AllowPaging = true;
                gv_actualBaclog.Visible = true;

                for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
                {
                    BoundField bf = new BoundField();

                    bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString();
                    bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString();
                    bf.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                    bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
                    bf.ReadOnly = false;

                    if (i == 0)
                    {
                        bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                        bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
                        bf.ReadOnly = true;
                    }

                    gv_actualBaclog.Columns.Add(bf);
                }

                //by yyan itemW42 20110621 del start
                //if (flag)
                //{
                //    CommandField cf_Update = new CommandField();
                //    cf_Update.ButtonType = ButtonType.Image;
                //    cf_Update.ShowEditButton = true;
                //    cf_Update.ShowCancelButton = true;
                //    cf_Update.EditImageUrl = "~/images/edit.jpg";
                //    cf_Update.EditText = "Edit";
                //    cf_Update.CausesValidation = false;
                //    cf_Update.CancelImageUrl = "~/images/cancel.jpg";
                //    cf_Update.CancelText = "Cancel";
                //    cf_Update.UpdateImageUrl = "~/images/ok.jpg";
                //    cf_Update.UpdateText = "Update";
                //    gv_actualBaclog.Columns.Add(cf_Update);
                //}
                //by yyan itemW42 20110621 del end
                gv_actualBaclog.AllowSorting = true;
                gv_actualBaclog.DataSource = ds.Tables[0];
                gv_actualBaclog.DataBind();
            }
            else
            {
                label_note.Visible = true;
                label_note.ForeColor = System.Drawing.Color.Red;
                label_note.Text = "The general marketing manager has not managed any operations.";
            }
        }
    }
Ejemplo n.º 43
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["No.Empleado"] == null)
        {
            Response.Redirect("login.aspx");
        }
        //if (Session["permisos"].ToString() != "Admin")
        //{
        //    liUsuario.Visible = false;
        //}

        if (Request["seleccionarVisita"] != null)
        {
            Response.Redirect("Visita.aspx?idVisita=" + Request["seleccionarVisita"]);
        }

        if (!IsPostBack)
        {
            RequisDrop.SelectedValue = "todas";
        }
        if (Session["Permisos"].ToString() == "Requi")
        {
            RequisDrop.Visible = false;
        }

        /*En los siguientes GridView se muestran las visitas que sean registrado filtrandolas entre pendientes y no pendientes
         * colocando todas las requisiciones si es aprobador */

        //GridView1(PENDIENTES)
        string        con      = ConfigurationManager.ConnectionStrings["IDDVisitas"].ConnectionString;
        SqlConnection conexion = new SqlConnection(con);

        conexion.Open();

        string que = @"SET LANGUAGE Spanish
    SELECT IdVisita, 
    ([nombreEmple] + ' ' + [apellido1] + ' ' + [apellido2] + ' (' + [No.Empleado_Requi] + ')') AS [Requisitor],
    [Nombre_Visitante] AS [Visitante],
    [Nombre_compania] AS [Compañia],
    ([Ciudad]+', ' +[Estado])AS [Ciudad-Estado],
    [Proposito_Visita] AS [Proposito de la visita],
    CASE WHEN [Aprobado] = 1
    THEN
    'Aprobado'
    ELSE
    'Rechazado'
    END
    AS [Aprobado],
    DATENAME(DD,Fecha_requi)
    + ' de ' 
    + DATENAME(mm, Fecha_requi) 
    + ' de ' 
    + DATENAME(YYYY,Fecha_requi)
    AS [Fecha] 
    FROM [Visitantes] WHERE [Abierto] = 0  ";

        /*Filtro del DropDownList*/
        if (RequisDrop.SelectedValue == "mias")
        {
            que += " AND [No.Empleado_Requi] = '" + Session["No.Empleado"].ToString() + "'";
        }
        if (RequisDrop.SelectedValue == "ajenas")
        {
            que += " AND [No.Empleado_Requi] != '" + Session["No.Empleado"].ToString() + "'";
        }

        /*Cuando se es requisitor se ejecuta esta condicion para que solamente muuestre las requisiciones que el a realizado esto por medio del numero de empleado*/
        if (Session["permisos"].ToString() == "Requi")
        {
            que += " AND [No.Empleado_Requi] = '" + Session["No.Empleado"].ToString() + "'";
        }

        SqlCommand    conx  = new SqlCommand(que, conexion);
        SqlDataReader slqDR = conx.ExecuteReader();

        GridView1.DataSource = slqDR;
        if (!IsPostBack)
        {
            BoundField columnaSeleccionar = new BoundField();
            columnaSeleccionar.HeaderText = "";
            GridView1.Columns.Add(columnaSeleccionar);
        }
        GridView1.DataBind();
        slqDR.Close();

        slqDR = conx.ExecuteReader();
        var contador0 = 0;

        while (slqDR.Read())
        {
            var celdaSeleccionar = GridView1.Rows[contador0].Cells[0];
            System.Web.UI.HtmlControls.HtmlButton botonSeleccionar = new System.Web.UI.HtmlControls.HtmlButton();
            botonSeleccionar.Attributes.Add("value", slqDR["IdVisita"].ToString());
            botonSeleccionar.Attributes.Add("name", "seleccionarVisita");
            botonSeleccionar.Attributes.Add("class", "fa fa-eye buttonSpecial");
            //botonSeleccionar.InnerHtml = "Ver";
            celdaSeleccionar.Controls.Add(botonSeleccionar);
            contador0++;
        }
        conexion.Close();

        //GridView2 (NO PENDIENTES)
        string        conn      = ConfigurationManager.ConnectionStrings["IDDVisitas"].ConnectionString;
        SqlConnection conexion1 = new SqlConnection(con);

        conexion.Open();
        string que2 = @" SET LANGUAGE Spanish
SELECT IdVisita,
([nombreEmple] + ' ' + [apellido1] + ' ' + [apellido2] + ' (' + [No.Empleado_Requi] + ')') AS [Requisitor],
[Nombre_Visitante] AS [Visitante], [Nombre_compania] AS [Compañia], 
([Ciudad]+', ' +[Estado])AS [Ciudad-Estado],
[Proposito_Visita] AS [Proposito de la visita],
DATENAME(DD,Fecha_requi)
+ ' de ' 
+ DATENAME(mm, Fecha_requi) 
+ ' de ' 
+ DATENAME(YYYY,Fecha_requi)
AS [Fecha] FROM [Visitantes] WHERE [Abierto] = 1 ";

        /*Filtro del DropDownList*/
        if (RequisDrop.SelectedValue == "mias")
        {
            que2 += " AND [No.Empleado_Requi] = '" + Session["No.Empleado"].ToString() + "'";
        }
        if (RequisDrop.SelectedValue == "ajenas")
        {
            que2 += " AND [No.Empleado_Requi] != '" + Session["No.Empleado"].ToString() + "'";
        }

        /*Cuando se es requisitor se ejecuta esta condicion para que solamente muuestre las requisiciones que el a realizado esto por medio del numero de empleado*/
        if (Session["permisos"].ToString() == "Requi")
        {
            que2 += " AND [No.Empleado_Requi] = '" + Session["No.Empleado"].ToString() + "'";
        }
        SqlCommand    con1   = new SqlCommand(que2, conexion);
        SqlDataReader slqDR1 = con1.ExecuteReader();

        GridView2.DataSource = slqDR1;
        if (!IsPostBack)
        {
            BoundField columnaSeleccionar = new BoundField();
            columnaSeleccionar.HeaderText = "";
            GridView2.Columns.Add(columnaSeleccionar);
        }
        GridView2.DataBind();
        slqDR1.Close();

        slqDR1 = con1.ExecuteReader();
        var contadorNp0 = 0;

        while (slqDR1.Read())
        {
            var celdaSeleccionar = GridView2.Rows[contadorNp0].Cells[0];
            System.Web.UI.HtmlControls.HtmlButton botonSeleccionar = new System.Web.UI.HtmlControls.HtmlButton();
            botonSeleccionar.Attributes.Add("value", slqDR1["IdVisita"].ToString());
            botonSeleccionar.Attributes.Add("name", "seleccionarVisita");
            botonSeleccionar.Attributes.Add("class", "fa fa-eye buttonSpecial");
            //botonSeleccionar.InnerHtml = "Ver";
            celdaSeleccionar.Controls.Add(botonSeleccionar);
            contadorNp0++;
        }

        conexion.Close();
    }
Ejemplo n.º 44
0
    protected void LoadHeader()
    {
        grvList.Columns.Clear();
        ButtonField b = new ButtonField();

        b.Text        = " " + "<img border=0 align=absmiddle src=../img/unselected.gif>" + " ";
        b.HeaderText  = GetGlobalResourceObject("WebGlobalResource", "Select").ToString(); //选择
        b.CommandName = "Select";
        b.ItemStyle.HorizontalAlign   = HorizontalAlign.Center;
        b.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
        b.ItemStyle.Width             = new Unit("30px");
        grvList.Columns.Add(b);

        string    _sql = "select NAME,DESCR,OTHER_LANGUAGE_DESCR,CONTROL_LIST_WIDTH,CONTROL_LIST_DISPLAY_FORMAT,CONTROL_LIST_DISPLAY_ALIGN,TYPE from DMIS_SYS_COLUMNS where TABLE_ID=" + Session["MainTableId"].ToString() + " and ISDISPLAY=1 order by ORDER_ID";
        DataTable _dt  = DBOpt.dbHelper.GetDataTable(_sql);

        for (int i = 0; i < _dt.Rows.Count; i++)
        {
            BoundField bf = new BoundField();
            if (Session["Culture"] == null || Session["Culture"].ToString() == "zh-CN")
            {
                bf.HeaderText = _dt.Rows[i]["DESCR"] == Convert.DBNull ? "" : _dt.Rows[i]["DESCR"].ToString();
            }
            else
            {
                bf.HeaderText = _dt.Rows[i]["OTHER_LANGUAGE_DESCR"] == Convert.DBNull ? "" : _dt.Rows[i]["OTHER_LANGUAGE_DESCR"].ToString();
            }
            bf.DataField = _dt.Rows[i]["NAME"].ToString();
            if (_dt.Rows[i]["CONTROL_LIST_WIDTH"] != Convert.DBNull)
            {
                bf.ItemStyle.Width = new Unit(_dt.Rows[i]["CONTROL_LIST_WIDTH"].ToString() + "px");
            }
            if (_dt.Rows[i]["CONTROL_LIST_DISPLAY_FORMAT"] != Convert.DBNull && _dt.Rows[i]["CONTROL_LIST_DISPLAY_FORMAT"].ToString().Trim().Length > 0)
            {
                bf.DataFormatString = _dt.Rows[i]["CONTROL_LIST_DISPLAY_FORMAT"].ToString();
                if (_dt.Rows[i]["TYPE"].ToString() == "Datetime")
                {
                    bf.HtmlEncode = false;
                }
            }
            if (_dt.Rows[i]["CONTROL_LIST_DISPLAY_ALIGN"] != Convert.DBNull)
            {
                if (_dt.Rows[i]["CONTROL_LIST_DISPLAY_ALIGN"].ToString() == "1")
                {
                    bf.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
                }
                else if (_dt.Rows[i]["CONTROL_LIST_DISPLAY_ALIGN"].ToString() == "0")
                {
                    bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                }
                else if (_dt.Rows[i]["CONTROL_LIST_DISPLAY_ALIGN"].ToString() == "2")
                {
                    bf.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                }
                else if (_dt.Rows[i]["CONTROL_LIST_DISPLAY_ALIGN"].ToString() == "3")
                {
                    bf.ItemStyle.HorizontalAlign = HorizontalAlign.Justify;
                }
            }
            grvList.Columns.Add(bf);
        }
    }
    //by yyan item8 20110614 add end
    //by yyan item8 20110614 del start
    //protected GridView bindDataBySalesOrgByOperation(DataSet ds, GridView gv, string header, string salesOrgID)
    //by yyan item8 20110614 del end
    //by yyan item8 20110614 add start
    protected GridView bindDataBySalesOrgByOperation(DataSet ds, GridView gv, string header, string salesOrgID, int flagMoney, bool flag)
    {
        if (ds != null)
        {
            gv.Visible = true;
            gv.AutoGenerateColumns = false;
            gv.Width = Unit.Pixel(600);
            gv.Columns.Clear();

            //Calculate the total column of next year.
            ds.Tables[0].Columns.Add("Total");
            if (ds.Tables[0].Rows[0][0] != DBNull.Value)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    float tmp = 0;
                    for (int count2 = 1; count2 < ds.Tables[0].Columns.Count - 1; count2++)
                    {
                        tmp += float.Parse(dr[count2].ToString());
                    }
                    dr["Total"] = tmp.ToString();
                }
            }

            for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            {
                BoundField bf = new BoundField();

                bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString();
                bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString();
                bf.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;

                if (i == 0)
                {
                    bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                    bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
                    bf.ItemStyle.Width = 100;
                }

                gv.Columns.Add(bf);
            }

            gv.Caption = header;
            gv.CaptionAlign = TableCaptionAlign.Left;
            gv.DataSource = ds;

            DataRow[] rows = new DataRow[2];
            rows[0] = ds.Tables[0].NewRow();
            rows[1] = ds.Tables[0].NewRow();

            float[] Sum1 = new float[20];
            float[] Sum2 = new float[20];
            for (int j = 1; j < ds.Tables[0].Columns.Count - 1; j++)
            {
                string str_productAbbr = ds.Tables[0].Columns[j].ColumnName.Trim();
                string str_productID = getProductIDBySegmentIDByProductAbbr(getSegmentID(), str_productAbbr);
                if (salesOrgID != "")
                {
                    //by yyan item8 20110614 del start
                    //string str_bl = sql.getBackLogBySalesOrgByOperation(ddlist_operation.SelectedItem.Value, getSegmentID(), str_productID, meeting.getyear(), meeting.getmonth(), salesOrgID, meeting.getyear().Substring(2, 2).Trim());
                    //by yyan item8 20110614 del end
                    //by yyan item8 20110614 add start
                    string str_bl = sql.getBackLogBySalesOrgByOperation(ddlist_operation.SelectedItem.Value, getSegmentID(), str_productID, meeting.getyear(), meeting.getmonth(), salesOrgID, meeting.getyear().Substring(2, 2).Trim(), flagMoney);
                    //by yyan item8 20110614 add end

                    if (str_bl == "")
                        str_bl = "0";
                    Sum1[j] = float.Parse(str_bl);
                    //by yyan item8 20110614 del start
                    //string str_blnext = sql.getBackLogBySalesOrgByOperation(ddlist_operation.SelectedItem.Value, getSegmentID(), str_productID, meeting.getyear(), meeting.getmonth(), salesOrgID, meeting.getnextyear().Substring(2, 2).Trim());
                    //by yyan item8 20110614 del end
                    //by yyan item8 20110614 add start
                    string str_blnext = sql.getBackLogBySalesOrgByOperation(ddlist_operation.SelectedItem.Value, getSegmentID(), str_productID, meeting.getyear(), meeting.getmonth(), salesOrgID, meeting.getnextyear().Substring(2, 2).Trim(), flagMoney);
                    //by yyan item8 20110614 add end
                    if (str_blnext == "")
                        str_blnext = "0";
                    Sum2[j] = float.Parse(str_blnext);
                }
                else
                {
                    //by yyan item8 20110614 del start
                    //string str_bl = sql.getBackLogByOperation(ddlist_operation.SelectedItem.Value, getSegmentID(), str_productID, meeting.getyear(), meeting.getmonth(), meeting.getyear().Substring(2, 2).Trim());
                    //by yyan item8 20110614 del end
                    //by yyan item8 20110614 add start
                    string str_bl = sql.getBackLogByOperation(ddlist_operation.SelectedItem.Value, getSegmentID(), str_productID, meeting.getyear(), meeting.getmonth(), meeting.getyear().Substring(2, 2).Trim(), flagMoney);
                    //by yyan item8 20110614 add end
                    if (str_bl == "")
                        str_bl = "0";
                    Sum1[j] = float.Parse(str_bl);
                    //by yyan item8 20110614 del start
                    //string str_blnext = sql.getBackLogByOperation(ddlist_operation.SelectedItem.Value, getSegmentID(), str_productID, meeting.getyear(), meeting.getmonth(), meeting.getnextyear().Substring(2, 2).Trim());
                    //by yyan item8 20110614 del end
                    //by yyan item8 20110614 add start
                    string str_blnext = sql.getBackLogByOperation(ddlist_operation.SelectedItem.Value, getSegmentID(), str_productID, meeting.getyear(), meeting.getmonth(), meeting.getnextyear().Substring(2, 2).Trim(), flagMoney);
                    //by yyan item8 20110614 add end
                    if (str_blnext == "")
                        str_blnext = "0";
                    Sum2[j] = float.Parse(str_blnext);
                }
            }

            for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            {
                if (i == 0)
                {
                    if (meeting.getmonth() == "10")
                        rows[0][0] = meeting.getyear().Substring(2, 2) + "Actual Sales";
                    else
                        rows[0][0] = meeting.getyear().Substring(2, 2) + "Actual Sales+B/L";
                    rows[1][0] = meeting.getnextyear().Substring(2, 2) + "B/L";
                }
                else
                {
                    rows[0][i] = Sum1[i];
                    rows[1][i] = Sum2[i];
                }
            }

            float tempY = 0;
            float tempNY = 0;
            for (int i = 0; i < ds.Tables[0].Columns.Count - 1; i++)
            {
                tempY += Sum1[i];
                tempNY += Sum2[i];
            }
            rows[0][ds.Tables[0].Columns.Count - 1] = tempY;
            rows[1][ds.Tables[0].Columns.Count - 1] = tempNY;
            ds.Tables[0].Rows.InsertAt(rows[0], 0);
            ds.Tables[0].Rows.InsertAt(rows[1], 1);

            if (salesOrgID != "")
            {
                //by yyan item8 20110614 del start
                //getSalesForecast(ds, salesOrgID, meeting.getyear().Substring(2, 2));
                //getSalesForecast(ds, salesOrgID, meeting.getnextyear().Substring(2, 2));
                //by yyan item8 20110614 del end
                //by yyan item8 20110614 add start
                getSalesForecast(ds, salesOrgID, meeting.getyear().Substring(2, 2), flagMoney);
                getSalesForecast(ds, salesOrgID, meeting.getnextyear().Substring(2, 2), flagMoney);
                //by yyan item8 20110614 add end
            }
            else
            {
                //by yyan item8 20110614 del start
                //getSalesForecast(ds, "", meeting.getyear().Substring(2, 2));
                //getSalesForecast(ds, "", meeting.getnextyear().Substring(2, 2));
                //by yyan item8 20110614 del end
                //by yyan item8 20110614 add start
                getSalesForecast(ds, "", meeting.getyear().Substring(2, 2), flagMoney);
                getSalesForecast(ds, "", meeting.getnextyear().Substring(2, 2), flagMoney);
                //by yyan item8 20110614 add end
            }
            //by yyan itemw93 add start
            bool bz = false;
            int k = 0;
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if (ds.Tables[0].Rows[i][0].ToString().Contains("F/C"))
                {
                    bz = true;
                    k = i;
                    break;
                }
            }
            if (bz)
            {
                if (flag)
                {
                    for (int i = ds.Tables[0].Rows.Count - 1; i >= k; i--)
                    {
                        ds.Tables[0].Rows[i].Delete();
                    }
                }
                else
                {
                    for (int i = k - 1; i >= 0; i--)
                    {
                        ds.Tables[0].Rows[i].Delete();
                    }
                }
            }
            //by yyan itemw93 add end
            gv.DataBind();
        }
        else
            gv.Visible = false;
        return gv;
    }
        protected override void CreateChildControls()
        {
            try
            {
                #region Creacion de controles
                pnlFormulario       = new Panel();
                pnlFormulario.ID    = "pnlFormulario";
                pnlAdjuntos         = new Panel();
                pnlAdjuntos.ID      = "pnlAdjuntos";
                pnlAdjuntos.Visible = false;

                lblTipoCarta          = new Label();
                lblTipoCarta.Text     = "Tipo <span class='ms-formvalidation'>*</span>";
                lblDescTipoCarta      = new Label();
                lblDescTipoCarta.Text = "Tipo de correspondencia recibida";
                rblTipoCarta          = new RadioButtonList();
                rblTipoCarta.ID       = "rblTipoCarta";
                rblTipoCarta.Items.Add("INTERNA");
                rblTipoCarta.Items.Add("EXTERNA");
                rfvTipoCarta                   = new RequiredFieldValidator();
                rfvTipoCarta.ID                = "rfvTipoCarta";
                rfvTipoCarta.Text              = "<br/>Tiene que especificar un valor para este campo requerido.";
                rfvTipoCarta.Display           = ValidatorDisplay.Dynamic;
                rfvTipoCarta.ControlToValidate = "rblTipoCarta";
                rfvTipoCarta.SetFocusOnError   = true;

                lblOrigenCarta          = new Label();
                lblOrigenCarta.Text     = "Origen <span class='ms-formvalidation'>*</span>";
                lblDescOrigenCarta      = new Label();
                lblDescOrigenCarta.Text = "Origen de la correspondencia";
                rblOrigenCarta          = new RadioButtonList();
                rblOrigenCarta.ID       = "rblOrigenCarta";
                rblOrigenCarta.Items.Add(new ListItem("", "COMBO"));
                rblOrigenCarta.Items.Add(new ListItem("", "TEXTO"));
                rblOrigenCarta.SelectedIndex = 0;
                ddlOrigenCarta    = new DropDownList();
                ddlOrigenCarta.ID = "ddlOrigenCarta";
                ddlOrigenCarta.Attributes.Add("style", "width:385px;");
                ddlOrigenCarta.DataSource     = ConectorWebPart.RecuperarOrigenesCorrespondencia();
                ddlOrigenCarta.DataTextField  = "text";
                ddlOrigenCarta.DataValueField = "value";
                ddlOrigenCarta.DataBind();
                ddlOrigenCarta.Items.Insert(0, new ListItem("", string.Empty));
                ddlOrigenCarta.SelectedIndex = 0;
                txbOrigenCarta    = new TextBox();
                txbOrigenCarta.ID = "txbOrigenCarta";
                txbOrigenCarta.Attributes.Add("style", "width:385px;");
                ctvOrigenCarta                   = new CustomValidator();
                ctvOrigenCarta.ID                = "ctvOrigenCarta";
                ctvOrigenCarta.Text              = "<br/>Tiene que especificar un valor para este campo requerido.";
                ctvOrigenCarta.Display           = ValidatorDisplay.Dynamic;
                ctvOrigenCarta.ControlToValidate = "rblOrigenCarta";
                ctvOrigenCarta.ServerValidate   += new ServerValidateEventHandler(ctvOrigenCarta_ServerValidate);
                //rfvDdlOrigenCarta = new RequiredFieldValidator();
                //rfvDdlOrigenCarta.ID = "rfvDdlOrigenCarta";
                //rfvDdlOrigenCarta.Text = "<br/>Tiene que especificar un valor para este campo requerido.";
                //rfvDdlOrigenCarta.InitialValue = string.Empty;
                //rfvDdlOrigenCarta.Display = ValidatorDisplay.Dynamic;
                //rfvDdlOrigenCarta.ControlToValidate = "ddlOrigenCarta";
                //rfvDdlOrigenCarta.Enabled = false;
                //rfvTxbOrigenCarta = new RequiredFieldValidator();
                //rfvTxbOrigenCarta.ID = "rfvTxbOrigenCarta";
                //rfvTxbOrigenCarta.Text = "<br/>Tiene que especificar un valor para este campo requerido.";
                //rfvTxbOrigenCarta.Display = ValidatorDisplay.Dynamic;
                //rfvTxbOrigenCarta.ControlToValidate = "txbOrigenCarta";
                //rfvTxbOrigenCarta.Enabled = false;

                lblReferencia          = new Label();
                lblReferencia.Text     = "Referencia <span class='ms-formvalidation'>*</span>";
                lblDescReferencia      = new Label();
                lblDescReferencia.Text = "<br/>Referencia de la carta";
                txbReferencia          = new InputFormTextBox();
                txbReferencia.ID       = "txbReferencia";
                txbReferencia.Attributes.Add("style", "width:385px;");
                txbReferencia.RichText     = false;
                txbReferencia.RichTextMode = SPRichTextMode.Compatible;
                txbReferencia.Rows         = 5;
                txbReferencia.TextMode     = TextBoxMode.MultiLine;
                rfvReferencia                   = new RequiredFieldValidator();
                rfvReferencia.ID                = "rfvReferencia";
                rfvReferencia.Text              = "<br/>Tiene que especificar un valor para este campo requerido.";
                rfvReferencia.Display           = ValidatorDisplay.Dynamic;
                rfvReferencia.ControlToValidate = "txbReferencia";
                rfvReferencia.SetFocusOnError   = true;

                lblFechaCarta                 = new Label();
                lblFechaCarta.Text            = "Fecha origen <span class='ms-formvalidation'>*</span>";
                lblDescFechaCarta             = new Label();
                lblDescFechaCarta.Text        = "Fecha de la correspondencia";
                dtcFechaCarta                 = new DateTimeControl();
                dtcFechaCarta.ID              = "dtcFechaCarta";
                dtcFechaCarta.IsRequiredField = true;
                dtcFechaCarta.DateOnly        = true;

                lblFechaRecibida                 = new Label();
                lblFechaRecibida.Text            = "Fecha recibida <span class='ms-formvalidation'>*</span>";
                lblDescFechaRecibida             = new Label();
                lblDescFechaRecibida.Text        = "Fecha de recepción de la carta";
                dtcFechaRecibida                 = new DateTimeControl();
                dtcFechaRecibida.ID              = "dtcFechaRecibida";
                dtcFechaRecibida.IsRequiredField = true;
                dtcFechaRecibida.SelectedDate    = DateTime.Now;

                lblDestinatario          = new Label();
                lblDestinatario.Text     = "Destinatario <span class='ms-formvalidation'>*</span>";
                lblDescDestinatario      = new Label();
                lblDescDestinatario.Text = "<br/>Destinatario indicado en la carta";
                txbDestinatario          = new TextBox();
                txbDestinatario.ID       = "txbDestinatario";
                txbDestinatario.Attributes.Add("style", "width:385px;");
                rfvDestinatario                   = new RequiredFieldValidator();
                rfvDestinatario.ID                = "rfvDestinatario";
                rfvDestinatario.Text              = "<br/>Tiene que especificar un valor para este campo requerido.";
                rfvDestinatario.Display           = ValidatorDisplay.Dynamic;
                rfvDestinatario.ControlToValidate = "txbDestinatario";
                rfvDestinatario.SetFocusOnError   = true;

                lblDirigidaA             = new Label();
                lblDirigidaA.Text        = "Dirigida a <span class='ms-formvalidation'>*</span>";
                lblDescDirigidaA         = new Label();
                lblDescDirigidaA.Text    = "Usuario(s) al(os) cual(es) será enviada la notificación de correspondencia. El primero usuario definido en este campo será el dueño de esta correspondencia.";
                pedDirigidaA             = new PeopleEditor();
                pedDirigidaA.ID          = "pedDirigidaA";
                pedDirigidaA.AllowEmpty  = false;
                pedDirigidaA.MultiSelect = true;
                pedDirigidaA.Rows        = 1;
                pedDirigidaA.PlaceButtonsUnderEntityEditor = false;
                rfvDirigidaA                   = new RequiredFieldValidator();
                rfvDirigidaA.ID                = "rfvDirigidaA";
                rfvDirigidaA.Text              = "<br/>Tiene que especificar un valor para este campo requerido.";
                rfvDirigidaA.Display           = ValidatorDisplay.Dynamic;
                rfvDirigidaA.ControlToValidate = "pedDirigidaA";
                rfvDirigidaA.SetFocusOnError   = true;

                lblNumCarta          = new Label();
                lblNumCarta.Text     = "Num. ó Cite";
                lblDescNumCarta      = new Label();
                lblDescNumCarta.Text = "<br/>Código de indentificación de la carta";
                txbNumCarta          = new TextBox();
                txbNumCarta.ID       = "txbNumCarta";
                txbNumCarta.Attributes.Add("style", "width:385px;");

                lblAdjunto          = new Label();
                lblAdjunto.Text     = "Adjunto <span class='ms-formvalidation'>*</span>";
                lblDescAdjunto      = new Label();
                lblDescAdjunto.Text = "<br/>Indica si la correspondencia trae documentos adjuntos o no";
                txbAdjunto          = new TextBox();
                txbAdjunto.ID       = "txbAdjunto";
                txbAdjunto.Attributes.Add("style", "width:385px;");
                rfvAdjunto                   = new RequiredFieldValidator();
                rfvAdjunto.ID                = "rfvAdjunto";
                rfvAdjunto.Text              = "<br/>Tiene que especificar un valor para este campo requerido.";
                rfvAdjunto.Display           = ValidatorDisplay.Dynamic;
                rfvAdjunto.ControlToValidate = "txbAdjunto";
                rfvAdjunto.SetFocusOnError   = true;

                lblClase          = new Label();
                lblClase.Text     = "Clase de documento <span class='ms-formvalidation'>*</span>";
                lblDescClase      = new Label();
                lblDescClase.Text = "";
                txbClase          = new TextBox();
                txbClase.ID       = "txbClase";
                txbClase.Attributes.Add("style", "width:385px;");
                rfvClase                   = new RequiredFieldValidator();
                rfvClase.ID                = "rfvClase";
                rfvClase.Text              = "<br/>Tiene que especificar un valor para este campo requerido.";
                rfvClase.Display           = ValidatorDisplay.Dynamic;
                rfvClase.ControlToValidate = "txbClase";
                rfvClase.SetFocusOnError   = true;

                lblPrioridad          = new Label();
                lblPrioridad.Text     = "Prioridad <span class='ms-formvalidation'>*</span>";
                lblDescPrioridad      = new Label();
                lblDescPrioridad.Text = "<br/>Prioridad de la correspondencia";
                ddlPrioridad          = new DropDownList();
                ddlPrioridad.ID       = "ddlPrioridad";
                ddlPrioridad.Attributes.Add("style", "width:150px;");
                ddlPrioridad.Items.Add("NORMAL");
                ddlPrioridad.Items.Add("URGENTE");
                ddlPrioridad.SelectedIndex = 0;

                lblPrivada          = new Label();
                lblPrivada.Text     = "Privada";
                lblDescPrivada      = new Label();
                lblDescPrivada.Text = "<br/>Si se marca, esta carta será leida solo por el(los) usuario(s) indicado(s) en el campo \"Dirigida a\"";
                chkPrivada          = new CheckBox();
                chkPrivada.ID       = "chkPrivada";
                chkPrivada.Checked  = true;

                lblHojaDeRuta          = new Label();
                lblHojaDeRuta.Text     = "Hoja de ruta";
                lblDescHojaDeRuta      = new Label();
                lblDescHojaDeRuta.Text = "<br/>Si se marca, imprime la hoja de ruta";
                chkHojaDeRuta          = new CheckBox();
                chkHojaDeRuta.ID       = "chkHojaDeRuta";
                chkHojaDeRuta.Checked  = true;

                lblArchivo          = new Label();
                lblArchivo.Text     = "Archivo";
                lblDescArchivo      = new Label();
                lblDescArchivo.Text = "<br/>Descripción de la ubicación física final de la correspondencia";
                txbArchivo          = new InputFormTextBox();
                txbArchivo.ID       = "txbArchivo";
                txbArchivo.Attributes.Add("style", "width:385px;");
                txbArchivo.RichText     = false;
                txbArchivo.RichTextMode = SPRichTextMode.Compatible;
                txbArchivo.Rows         = 5;
                txbArchivo.TextMode     = TextBoxMode.MultiLine;

                lblAdjuntos                     = new Label();
                lblAdjuntos.Text                = "Adjuntos";
                lblDescAdjuntos                 = new Label();
                lblDescAdjuntos.Text            = "Seleccione el o los archivos que desea adjuntar a este registro de correspondencia";
                grvAdjuntos                     = new GridView();
                grvAdjuntos.ID                  = "grvAdjuntos";
                grvAdjuntos.GridLines           = GridLines.None;
                grvAdjuntos.ForeColor           = Color.FromArgb(51, 51, 51);
                grvAdjuntos.CellPadding         = 4;
                grvAdjuntos.AutoGenerateColumns = false;
                grvAdjuntos.DataKeyNames        = new string[] { "RutaArchivo" };
                grvAdjuntos.RowStyle.BackColor  = Color.FromArgb(227, 234, 235);
                //grvAdjuntos.HeaderStyle.BackColor = Color.FromArgb(28, 94, 85);
                grvAdjuntos.HeaderStyle.Font.Bold = true;
                //grvAdjuntos.HeaderStyle.ForeColor = Color.FromArgb(255, 255, 255);
                grvAdjuntos.AlternatingRowStyle.BackColor = Color.White;
                grvAdjuntos.Width = Unit.Percentage(100);
                //grvAdjuntos.RowDataBound += new GridViewRowEventHandler(grvAdjuntos_RowDataBound);

                #region Adicion de columnas al Grid
                TemplateField    chkAdjuntar = new TemplateField();
                CheckBoxTemplate chkBox      = new CheckBoxTemplate();
                chkAdjuntar.ItemTemplate = chkBox;

                BoundField bflNombreArchivo = new BoundField();
                bflNombreArchivo.HeaderText = "Nombre archivo";
                bflNombreArchivo.DataField  = "NombreArchivo";

                BoundField bflTipoArchivo = new BoundField();
                bflTipoArchivo.HeaderText = "Tipo";
                bflTipoArchivo.DataField  = "TipoArchivo";

                ImageField imfVistaPrevia = new ImageField();
                imfVistaPrevia.HeaderText        = "Vista Previa";
                imfVistaPrevia.DataImageUrlField = "VistaPrevia";

                BoundField bflRutaArchivo = new BoundField();
                bflRutaArchivo.HeaderText = "URL";
                bflRutaArchivo.DataField  = "RutaArchivo";
                bflRutaArchivo.Visible    = false;

                grvAdjuntos.Columns.Add(chkAdjuntar);
                grvAdjuntos.Columns.Add(bflNombreArchivo);
                grvAdjuntos.Columns.Add(bflTipoArchivo);
                grvAdjuntos.Columns.Add(imfVistaPrevia);
                grvAdjuntos.Columns.Add(bflRutaArchivo);

                grvAdjuntos.DataSource = ConectorWebPart.RecuperarDocumentosEP().Tables["DataTable"];
                grvAdjuntos.DataBind();
                #endregion

                btnAdjuntarArchivos         = new LinkButton();
                btnAdjuntarArchivos.ID      = "btnAdjuntarArchivos";
                btnAdjuntarArchivos.Text    = "Adjuntar Archivos";
                btnAdjuntarArchivos.ToolTip = "Ver el panel de adjuntar archivos.";
                btnAdjuntarArchivos.Attributes.Add("style", "font-size:8.5pt;");
                btnAdjuntarArchivos.Click           += new EventHandler(btnAdjuntarArchivos_Click);
                btnAdjuntarArchivos.CausesValidation = false; //OJO
                btnFinalizarRegistro         = new Button();
                btnFinalizarRegistro.ID      = "btnFinalizarRegistro";
                btnFinalizarRegistro.Text    = "Finalizar";
                btnFinalizarRegistro.ToolTip = "Finalizar el registro de nueva correspondencia.";
                btnFinalizarRegistro.Visible = true;
                btnFinalizarRegistro.Attributes.Add("style", "width:140px; font-size:8.5pt;");
                btnFinalizarRegistro.Click += new EventHandler(btnFinalizarRegistro_Click);
                //btnIrAtras = new Button();
                //btnIrAtras.ID = "btnIrAtras";
                //btnIrAtras.Text = "Ir Atras";
                //btnIrAtras.ToolTip = "Volver al formulario de registro";
                //btnIrAtras.Visible = false;
                //btnIrAtras.Attributes.Add("style", "width:140px; font-size:8.5pt;");
                //btnIrAtras.Click += new EventHandler(btnIrAtras_Click);
                btnCancelar             = new GoBackButton();
                btnCancelar.ID          = "btnCancelar";
                btnCancelar.ControlMode = SPControlMode.New;
                #endregion

                #region Adiccion de controles
                pnlFormulario.Controls.Add(new LiteralControl("<table border='0' cellspacing='0' width='100%'>"));
                pnlFormulario.Controls.Add(new LiteralControl("<tr><td colspan='2' style='border-bottom:1px black solid'><b>Datos de la Correspondencia</b></td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblTipoCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(rblTipoCarta);
                pnlFormulario.Controls.Add(lblDescTipoCarta);
                pnlFormulario.Controls.Add(rfvTipoCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblOrigenCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(new LiteralControl("<table><tr><td>"));
                pnlFormulario.Controls.Add(rblOrigenCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</td><td>"));
                pnlFormulario.Controls.Add(ddlOrigenCarta);
                pnlFormulario.Controls.Add(new LiteralControl("<br/>"));
                pnlFormulario.Controls.Add(txbOrigenCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr></table>"));
                pnlFormulario.Controls.Add(lblDescOrigenCarta);
                pnlFormulario.Controls.Add(ctvOrigenCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblReferencia);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(txbReferencia);
                pnlFormulario.Controls.Add(lblDescReferencia);
                pnlFormulario.Controls.Add(rfvReferencia);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblFechaCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(dtcFechaCarta);
                pnlFormulario.Controls.Add(lblDescFechaCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblFechaRecibida);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(dtcFechaRecibida);
                pnlFormulario.Controls.Add(lblDescFechaRecibida);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblDestinatario);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(txbDestinatario);
                pnlFormulario.Controls.Add(lblDescDestinatario);
                pnlFormulario.Controls.Add(rfvDestinatario);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblDirigidaA);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(pedDirigidaA);
                pnlFormulario.Controls.Add(lblDescDirigidaA);
                pnlFormulario.Controls.Add(rfvDirigidaA);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblNumCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(txbNumCarta);
                pnlFormulario.Controls.Add(lblDescNumCarta);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblAdjunto);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(txbAdjunto);
                pnlFormulario.Controls.Add(lblDescAdjunto);
                pnlFormulario.Controls.Add(rfvAdjunto);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblClase);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(txbClase);
                pnlFormulario.Controls.Add(lblDescClase);
                pnlFormulario.Controls.Add(rfvClase);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblPrioridad);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(ddlPrioridad);
                pnlFormulario.Controls.Add(lblDescPrioridad);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblPrivada);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(chkPrivada);
                pnlFormulario.Controls.Add(lblDescPrivada);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblHojaDeRuta);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(chkHojaDeRuta);
                pnlFormulario.Controls.Add(lblDescHojaDeRuta);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));

                pnlFormulario.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlFormulario.Controls.Add(lblArchivo);
                pnlFormulario.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlFormulario.Controls.Add(txbArchivo);
                pnlFormulario.Controls.Add(lblDescArchivo);
                pnlFormulario.Controls.Add(new LiteralControl("</td></tr>"));
                pnlFormulario.Controls.Add(new LiteralControl("</table>"));

                pnlAdjuntos.Controls.Add(new LiteralControl("<table border='0' cellspacing='0' width='100%'>"));
                pnlAdjuntos.Controls.Add(new LiteralControl("<tr><td colspan='2' style='border-bottom:1px black solid'><b>Archivos Adjuntos</b></td></tr>"));
                pnlAdjuntos.Controls.Add(new LiteralControl("<tr><td width='190px' valign='top' class='ms-formlabel'><H3 class='ms-standardheader'><nobr>"));
                pnlAdjuntos.Controls.Add(lblAdjuntos);
                pnlAdjuntos.Controls.Add(new LiteralControl("</nobr></H3></td><td width='500px' valign='top' class='ms-formbody'>"));
                pnlAdjuntos.Controls.Add(lblDescAdjuntos);
                pnlAdjuntos.Controls.Add(grvAdjuntos);
                pnlAdjuntos.Controls.Add(new LiteralControl("</td></tr>"));
                pnlAdjuntos.Controls.Add(new LiteralControl("</table>"));

                this.Controls.Add(pnlFormulario);
                this.Controls.Add(pnlAdjuntos);
                this.Controls.Add(new LiteralControl("<table border='0' cellspacing='0' width='100%'>"));
                this.Controls.Add(new LiteralControl("<tr><td style='text-align:right' class='ms-toolbar'>"));
                this.Controls.Add(new LiteralControl("<table><tr><td width='99%' class='ms-toolbar'><IMG SRC='/_layouts/images/blank.gif' width='1' height='18'/></td>"));
                this.Controls.Add(new LiteralControl("<td nowrap='nowrap' class='ms-toolbar'>"));
                this.Controls.Add(btnAdjuntarArchivos);
                this.Controls.Add(new LiteralControl("</td><td class='ms-separator'> </td><td class='ms-toolbar' align='right'>"));
                this.Controls.Add(btnFinalizarRegistro);
                this.Controls.Add(new LiteralControl("</td><td class='ms-separator'> </td><td class='ms-toolbar' align='right'>"));
                this.Controls.Add(btnCancelar);
                //this.Controls.Add(btnIrAtras);
                this.Controls.Add(new LiteralControl("</td></tr></table>"));
                this.Controls.Add(new LiteralControl("</td></tr>"));
                this.Controls.Add(new LiteralControl("</table>"));
                #endregion
            }
            catch (Exception ex)
            {
                Literal error = new Literal();
                error.Text = ex.Message;

                this.Controls.Clear();
                this.Controls.Add(error);
            }
        }
Ejemplo n.º 47
0
    //By Lhy 20110505 ITEM 6 ADD End
    protected void bindDataSource(DataSet ds)
    {
        bool notNullFlag = true;
        if (ds.Tables[0].Rows.Count == 0)
        {
            notNullFlag = false;
            sql.getNullDataSet(ds);
        }
        //By Lhy 20110504 ITEM 6 DEL start
             //gv_option.Width = Unit.Pixel(450);
        //By Lhy 20110504 ITEM 6 DEL End

        gv_option.AutoGenerateColumns = false;
        gv_option.AllowPaging = false;
        gv_option.Visible = true;

        for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
        {
            BoundField bf = new BoundField();

            bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString();
            //By Lhy 20110504 ITEM 6 DEL start
                //ds.Tables[0].Columns[i].Caption.ToString();
            //By Lhy 20110504 ITEM 6 DEL End

            //By Lhy 20110504 ITEM 6 ADD start
            bf.HeaderText = ddlist_description.SelectedItem.Text + " Name";
           //By Lhy 20110504 ITEM 6 ADD End
            bf.ItemStyle.Width = 350;
            //By Lhy 20110510 ITEM 6 ADD start
            if (string.Equals(ddlist_description.SelectedValue, "0"))
            {

                this.divflow.Attributes.Add("Style", "overflow: auto; height: 480px; width: 221px; position: relative; padding-top: 22px;");

            }

            else if (string.Equals(ddlist_description.SelectedValue, "1"))
            {

                this.divflow.Attributes.Add("Style", "overflow: auto; height: 480px; width: 221px; position: relative; padding-top: 22px;");

            }

            else if (string.Equals(ddlist_description.SelectedValue, "2"))
            {

                this.divflow.Attributes.Add("Style", "overflow: auto; height: 480px; width: 440px; position: relative; padding-top: 22px;");

            }

            else if (string.Equals(ddlist_description.SelectedValue, "3"))
            {

                this.divflow.Attributes.Add("Style", "overflow: auto; height: 480px; width: 320px; position: relative; padding-top: 22px;");

            }
            //By Lhy 20110504 ITEM 10 ADD End
            bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
            bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
            bf.HeaderStyle.Wrap = false;
            gv_option.Columns.Add(bf);
        }

        gv_option.AllowSorting = true;
        gv_option.DataSource = ds.Tables[0];
        gv_option.DataBind();
        gv_option.Columns[0].Visible = false;
    }
Ejemplo n.º 48
0
        private void AtualizarGrid()
        {
            DataTable dados = M17_Food4U.Models.User.ListarUtilizadores();

            dgv_utilizadores.Columns.Clear();
            dgv_utilizadores.DataSource = null;
            dgv_utilizadores.DataBind();

            dgv_utilizadores.DataSource          = dados;
            dgv_utilizadores.AutoGenerateColumns = false;
            // id,email,name,nif,data_nasc,saldo,estado,perfil

            BoundField bfID = new BoundField();

            bfID.HeaderText = "ID";
            bfID.DataField  = "id";
            dgv_utilizadores.Columns.Add(bfID);

            BoundField bfNome = new BoundField();

            bfNome.HeaderText = "Email";
            bfNome.DataField  = "email";
            dgv_utilizadores.Columns.Add(bfNome);

            BoundField bfDescription = new BoundField();

            bfDescription.HeaderText = "Nome";
            bfDescription.DataField  = "name";
            dgv_utilizadores.Columns.Add(bfDescription);

            BoundField bfEstrelas = new BoundField();

            bfEstrelas.HeaderText = "NIF";
            bfEstrelas.DataField  = "nif";
            dgv_utilizadores.Columns.Add(bfEstrelas);

            BoundField bfStock = new BoundField();

            bfStock.HeaderText       = "Data Nascimento";
            bfStock.DataField        = "data_nasc";
            bfStock.DataFormatString = "{0:d}";
            dgv_utilizadores.Columns.Add(bfStock);

            BoundField bfPreco = new BoundField();

            bfPreco.HeaderText       = "Saldo";
            bfPreco.DataField        = "saldo";
            bfPreco.DataFormatString = "{0:C}";
            dgv_utilizadores.Columns.Add(bfPreco);

            BoundField bfState = new BoundField();

            bfState.HeaderText = "Estado";
            bfState.DataField  = "estado";
            dgv_utilizadores.Columns.Add(bfState);

            BoundField bfPerfil = new BoundField();

            bfPerfil.HeaderText = "Perfil";
            bfPerfil.DataField  = "perfil";
            dgv_utilizadores.Columns.Add(bfPerfil);

            ButtonField dcOpcoes = new ButtonField();

            dcOpcoes.HeaderText = "Opções";
            dcOpcoes.ButtonType = ButtonType.Link;
            dgv_utilizadores.Columns.Add(dcOpcoes);


            DataColumn dcDetalhes = new DataColumn();

            dcDetalhes.ColumnName = "Histórico Pedidos";
            dcDetalhes.DataType   = Type.GetType("System.String");
            dados.Columns.Add(dcDetalhes);

            HyperLinkField hldetalhes = new HyperLinkField();

            hldetalhes.HeaderText    = "Histórico Pedidos";
            hldetalhes.DataTextField = "Histórico Pedidos";
            hldetalhes.Text          = "Histórico Pedidos";
            hldetalhes.DataNavigateUrlFormatString = "~/admin/historicopedidos.aspx?user={0}";
            hldetalhes.DataNavigateUrlFields       = new string[] { "id" };
            dgv_utilizadores.Columns.Add(hldetalhes);

            DataColumn dcDetalhes2 = new DataColumn();

            dcDetalhes2.ColumnName = "Histórico Transações";
            dcDetalhes2.DataType   = Type.GetType("System.String");
            dados.Columns.Add(dcDetalhes2);

            HyperLinkField hldetalhes2 = new HyperLinkField();

            hldetalhes2.HeaderText    = "Histórico Transações";
            hldetalhes2.DataTextField = "Histórico Transações";
            hldetalhes2.Text          = "Histórico Transações";
            hldetalhes2.DataNavigateUrlFormatString = "~/admin/historicotransacoes.aspx?user={0}";
            hldetalhes2.DataNavigateUrlFields       = new string[] { "id" };
            dgv_utilizadores.Columns.Add(hldetalhes2);

            dgv_utilizadores.DataBind();
        }
    protected void bindDataByDateByProduct(GridView gv, string bookingY, string deliverY)
    {
        DataSet ds_product = getProductBySegment(getSegmentID());
        DataSet ds = getBookingDataByDateByProduct(ds_product, getSegmentID(), bookingY, deliverY, getSalesOrgID());

        if (ds != null)
        {
            gv.Width = Unit.Pixel(650);
            gv.AutoGenerateColumns = false;
            gv.AllowPaging = false;
            gv.Visible = true;

            for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            {
                BoundField bf = new BoundField();

                bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString();
                bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString();

                bf.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;

                if (i == 0 || i == 1)
                {
                    bf.ItemStyle.Width = 100;
                    bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                    bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
                }

                gv.Columns.Add(bf);
            }

            if (deliverY == "YTD")
                gv.Caption = bookingY + deliverY;
            else
                gv.Caption = bookingY + " for " + deliverY;
            gv.CaptionAlign = TableCaptionAlign.Top;
            gv.AllowSorting = true;
            gv.DataSource = ds.Tables[0];
            gv.DataBind();
            flag = true;
        }
        else
        {
            flag = false;
            gv.Visible = false;
        }
    }
Ejemplo n.º 50
0
 public void Bind4(GridView G1)
 {
     BoundField  bf11 = G1.Columns[0] as BoundField; bf11.ItemStyle.Font.Bold = true;
     ButtonField bf88 = G1.Columns[9] as ButtonField; bf88.ControlStyle.BorderStyle = BorderStyle.None; bf88.ControlStyle.BackColor = System.Drawing.Color.White;
 }
    protected GridView showTotalByProduct(DataSet ds, GridView gv, string productName)
    {
        if (ds != null)
        {
            gv.AutoGenerateColumns = false;
            gv.Width = Unit.Pixel(300);
            gv.Columns.Clear();

            //Calculate the VAR column and Total row of next year.
            try
            {
                ds.Tables[0].Columns.Add("VAR");
                if (ds.Tables[0].Rows[0][0] != DBNull.Value)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        float tmp = 0;
                        if (float.Parse(dr[2].ToString()) != 0)
                        {
                            tmp = (float.Parse(dr[1].ToString()) - float.Parse(dr[2].ToString())) * 100 / float.Parse(dr[2].ToString());
                            dr["VAR"] = Convert.ToInt32(tmp).ToString() + "%";
                        }
                    }
                }
            }
            catch
            {
                log.WriteLog(LogUtility.LogErrorLevel.LOG_ERROR, "Format string to float Error.");
                Response.Redirect("~/Admin/AdminError.aspx");
            }
            for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            {
                BoundField bf = new BoundField();

                bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString();
                bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString();
                bf.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
                if (i == 0)
                {
                    bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                    bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
                }
                bf.ReadOnly = true;

                bf.ReadOnly = true;
                gv.Columns.Add(bf);
            }

            gv.DataSource = ds;

            DataRow drSum = ds.Tables[0].NewRow();
            DataRow[] rows = ds.Tables[0].Select();

            float[] Sum = new float[20];
            for (int j = 1; j < ds.Tables[0].Columns.Count - 1; j++)
            {
                Sum[j] = 0;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    Sum[j] += float.Parse(ds.Tables[0].Rows[i][j].ToString());
                }
            }

            for (int i = 0; i < ds.Tables[0].Columns.Count - 1; i++)
            {
                if (i == 0)
                {
                    drSum[0] = "TTL/" + getAbbrBySalesOrg(getSalesOrgID());
                }
                else
                {
                    drSum[i] = Sum[i].ToString();
                }
            }

            ds.Tables[0].Rows.InsertAt(drSum, 0);
            if (float.Parse(ds.Tables[0].Rows[0][2].ToString()) != 0)
            {
                ds.Tables[0].Rows[0][3] = (Convert.ToInt32((float.Parse(ds.Tables[0].Rows[0][1].ToString()) - float.Parse(ds.Tables[0].Rows[0][2].ToString())) * 100 / float.Parse(ds.Tables[0].Rows[0][2].ToString()))).ToString() + "%";
            }

            gv.DataBind();
        }
        return gv;
    }
Ejemplo n.º 52
0
        protected void AddDynamicControls(ContentChannel channel)
        {
            // Remove all columns
            gContentChannelItems.Columns.Clear();
            phAttributeFilters.Controls.Clear();

            if (channel != null)
            {
                // Add Reorder column
                var reorderField = new ReorderField();
                gContentChannelItems.Columns.Add(reorderField);

                // Add Title column
                var titleField = new BoundField();
                titleField.DataField      = "Title";
                titleField.HeaderText     = "Title";
                titleField.SortExpression = "Title";
                gContentChannelItems.Columns.Add(titleField);

                // Add Attribute columns
                int    entityTypeId  = EntityTypeCache.Get(typeof(Rock.Model.ContentChannelItem)).Id;
                string channelId     = channel.Id.ToString();
                string channelTypeId = channel.ContentChannelTypeId.ToString();
                foreach (var attribute in AvailableAttributes)
                {
                    var control = attribute.FieldType.Field.FilterControl(attribute.QualifierValues, "filter_" + attribute.Id.ToString(), false, Rock.Reporting.FilterMode.SimpleFilter);
                    if (control != null)
                    {
                        if (control is IRockControl)
                        {
                            var rockControl = (IRockControl)control;
                            rockControl.Label = attribute.Name;
                            rockControl.Help  = attribute.Description;
                            phAttributeFilters.Controls.Add(control);
                        }
                        else
                        {
                            var wrapper = new RockControlWrapper();
                            wrapper.ID    = control.ID + "_wrapper";
                            wrapper.Label = attribute.Name;
                            wrapper.Controls.Add(control);
                            phAttributeFilters.Controls.Add(wrapper);
                        }

                        string savedValue = gfFilter.GetUserPreference(MakeKeyUniqueToChannel(channel.Id, attribute.Key));
                        if (!string.IsNullOrWhiteSpace(savedValue))
                        {
                            try
                            {
                                var values = JsonConvert.DeserializeObject <List <string> >(savedValue);
                                attribute.FieldType.Field.SetFilterValues(control, attribute.QualifierValues, values);
                            }
                            catch
                            {
                                // intentionally ignore
                            }
                        }
                    }

                    string dataFieldExpression = attribute.Key;
                    bool   columnExists        = gContentChannelItems.Columns.OfType <AttributeField>().FirstOrDefault(a => a.DataField.Equals(dataFieldExpression)) != null;
                    if (!columnExists)
                    {
                        AttributeField boundField = new AttributeField();
                        boundField.DataField   = dataFieldExpression;
                        boundField.AttributeId = attribute.Id;
                        boundField.HeaderText  = attribute.Name;
                        boundField.ItemStyle.HorizontalAlign = attribute.FieldType.Field.AlignValue;
                        gContentChannelItems.Columns.Add(boundField);
                    }
                }

                if (channel.ContentChannelType.DateRangeType != ContentChannelDateType.NoDates)
                {
                    RockBoundField startDateTimeField;
                    RockBoundField expireDateTimeField;
                    if (channel.ContentChannelType.IncludeTime)
                    {
                        startDateTimeField  = new DateTimeField();
                        expireDateTimeField = new DateTimeField();
                    }
                    else
                    {
                        startDateTimeField  = new DateField();
                        expireDateTimeField = new DateField();
                    }

                    startDateTimeField.DataField      = "StartDateTime";
                    startDateTimeField.HeaderText     = channel.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange ? "Start" : "Date";
                    startDateTimeField.SortExpression = "StartDateTime";
                    gContentChannelItems.Columns.Add(startDateTimeField);

                    expireDateTimeField.DataField      = "ExpireDateTime";
                    expireDateTimeField.HeaderText     = "Expire";
                    expireDateTimeField.SortExpression = "ExpireDateTime";
                    if (channel.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange)
                    {
                        gContentChannelItems.Columns.Add(expireDateTimeField);
                    }
                }

                if (!channel.ContentChannelType.DisablePriority)
                {
                    // Priority column
                    var priorityField = new BoundField();
                    priorityField.DataField                 = "Priority";
                    priorityField.HeaderText                = "Priority";
                    priorityField.SortExpression            = "Priority";
                    priorityField.DataFormatString          = "{0:N0}";
                    priorityField.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                    gContentChannelItems.Columns.Add(priorityField);
                }

                // Status column
                if (channel.RequiresApproval)
                {
                    var statusField = new BoundField();
                    gContentChannelItems.Columns.Add(statusField);
                    statusField.DataField      = "Status";
                    statusField.HeaderText     = "Status";
                    statusField.SortExpression = "Status";
                    statusField.HtmlEncode     = false;
                }

                // Add occurrences Count column
                var occurrencesField = new BoolField();
                occurrencesField.DataField  = "Occurrences";
                occurrencesField.HeaderText = "Event Occurrences";
                gContentChannelItems.Columns.Add(occurrencesField);

                // Add Created By column
                var createdByPersonNameField = new BoundField();
                createdByPersonNameField.DataField  = "CreatedByPersonName";
                createdByPersonNameField.HeaderText = "Created By";
                createdByPersonNameField.HtmlEncode = false;
                gContentChannelItems.Columns.Add(createdByPersonNameField);

                // Add Tag Field
                if (channel.IsTaggingEnabled)
                {
                    var tagField = new BoundField();
                    gContentChannelItems.Columns.Add(tagField);
                    tagField.DataField          = "Tags";
                    tagField.HeaderText         = "Tags";
                    tagField.ItemStyle.CssClass = "taglist";
                    tagField.HtmlEncode         = false;
                }

                bool canEditChannel = channel.IsAuthorized(Rock.Security.Authorization.EDIT, CurrentPerson);
                gContentChannelItems.Actions.ShowAdd = canEditChannel;
                gContentChannelItems.IsDeleteEnabled = canEditChannel;
                if (canEditChannel)
                {
                    var deleteField = new DeleteField();
                    gContentChannelItems.Columns.Add(deleteField);
                    deleteField.Click += gContentChannelItems_Delete;
                }
            }
        }
    protected void bindDataTotalByDateByProduct(GridView gv, string bookingY, string deliverY)
    {
        DataSet ds_product = getProductBySegment(getSegmentID());
        DataSet ds = getBookingDataTotalByDateByProduct(ds_product, getSegmentID(), getSalesOrgID(), bookingY, deliverY);

        if (ds != null)
        {
            gv.Width = Unit.Pixel(650);
            gv.AutoGenerateColumns = false;
            gv.AllowPaging = false;
            gv.Visible = true;

            for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            {
                BoundField bf = new BoundField();

                bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString();
                bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString();
                bf.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
                if (i == 0)
                {
                    bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                    bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
                    bf.ItemStyle.Width = 200;
                }
                bf.ReadOnly = true;

                gv.Columns.Add(bf);
            }

            gv.AllowSorting = true;
            gv.DataSource = ds.Tables[0];

            DataRow drSum = ds.Tables[0].NewRow();
            DataRow[] rows = ds.Tables[0].Select();

            float[] Sum = new float[20];
            for (int j = 1; j < ds.Tables[0].Columns.Count; j++)
            {
                Sum[j] = 0;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    Sum[j] += float.Parse(ds.Tables[0].Rows[i][j].ToString());
                }
            }

            for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            {
                if (i == 0)
                {
                    drSum[0] = "TTL/" + getAbbrBySalesOrg(getSalesOrgID());
                }
                else
                {
                    drSum[i] = Sum[i].ToString();
                }
            }
            ds.Tables[0].Rows.InsertAt(drSum, 0);
            gv.DataBind();
        }
        else
            gv.Visible = false;
    }
Ejemplo n.º 54
0
    private DataTable ShowGrid()
    {
        DataTable dt = this.bfield.GetModelFieldList(DataConverter.CLng(this.HdnModelID.Value)).Tables[0];

        DetailsView1.AutoGenerateRows = false;
        DataControlFieldCollection dcfc = DetailsView1.Fields;


        dcfc.Clear();


        BoundField bf2 = new BoundField();

        bf2.HeaderText                  = "ID";
        bf2.DataField                   = "ID";
        bf2.HeaderStyle.Width           = Unit.Percentage(15);
        bf2.HeaderStyle.CssClass        = "tdbgleft";
        bf2.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
        bf2.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;

        dcfc.Add(bf2);

        BoundField bf5 = new BoundField();

        bf5.HeaderText                  = "用户名";
        bf5.DataField                   = "PubUserName";
        bf5.HeaderStyle.CssClass        = "tdbgleft";
        bf5.HeaderStyle.Width           = Unit.Percentage(15);
        bf5.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
        bf5.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
        dcfc.Add(bf5);

        BoundField bf1 = new BoundField();

        bf1.HeaderText                  = "标题";
        bf1.DataField                   = "PubTitle";
        bf1.HeaderStyle.CssClass        = "tdbgleft";
        bf1.HeaderStyle.Width           = Unit.Percentage(15);
        bf1.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
        bf1.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
        bf1.HtmlEncode                  = false;
        dcfc.Add(bf1);

        BoundField bfa = new BoundField();

        bfa.HeaderText                  = "内容";
        bfa.DataField                   = "PubContent";
        bfa.HeaderStyle.CssClass        = "tdbgleft";
        bfa.HeaderStyle.Width           = Unit.Percentage(15);
        bfa.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
        bfa.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
        bfa.HtmlEncode                  = false;
        dcfc.Add(bfa);

        BoundField bf3 = new BoundField();

        bf3.HeaderText                  = "IP地址";
        bf3.DataField                   = "PubIP";
        bf3.HeaderStyle.CssClass        = "tdbgleft";
        bf3.HeaderStyle.Width           = Unit.Percentage(15);
        bf3.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
        bf3.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
        bf3.HtmlEncode                  = false;
        dcfc.Add(bf3);

        BoundField bf4 = new BoundField();

        bf4.HeaderText                  = "添加时间";
        bf4.DataField                   = "PubAddTime";
        bf4.HeaderStyle.CssClass        = "tdbgleft";
        bf4.HeaderStyle.Width           = Unit.Percentage(15);
        bf4.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
        bf4.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
        bf4.HtmlEncode                  = false;
        dcfc.Add(bf4);


        foreach (DataRow dr in dt.Rows)
        {
            BoundField bf = new BoundField();
            bf.HeaderText                  = dr["FieldAlias"].ToString();
            bf.DataField                   = dr["FieldName"].ToString();
            bf.HeaderStyle.Width           = Unit.Percentage(15);
            bf.HeaderStyle.CssClass        = "tdbgleft";
            bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
            bf.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
            bf.HtmlEncode                  = false;
            dcfc.Add(bf);
        }
        return(dt);
    }
Ejemplo n.º 55
0
    private void grid()
    {
        Int32 i;
        for (i = 0; i < DropDownList3.Items.Count+2; i++)
        {
            if (i == 0)
            {
                BoundField bf = new BoundField();
                bf.DataField = "s_id";
                bf.HeaderText = "Student ID";
                GridView1.Columns.Add(bf);
            }
            if (i == 1)
            {
                BoundField bf = new BoundField();
                bf.DataField = "s_name";
                bf.HeaderText = "Student Name";
                GridView1.Columns.Add(bf);
            }
           if(i>1)
            {
                BoundField bf = new BoundField();
                //bf.DataField = "NameField";
                bf.HeaderText = DropDownList3.Items[i-2].ToString();
                GridView1.Columns.Add(bf);

            }
        }
    }
Ejemplo n.º 56
0
        /// <summary>
        /// Adds the attribute columns.
        /// </summary>
        private void AddDynamicControls()
        {
            // Clear the filter controls
            phAttributeFilters.Controls.Clear();

            // Remove attribute columns
            foreach (var column in gEventCalendarItems.Columns.OfType <AttributeField>().ToList())
            {
                gEventCalendarItems.Columns.Remove(column);
            }

            // Remove status columns
            foreach (var column in gEventCalendarItems.Columns.OfType <BoundField>()
                     .Where(c =>
                            c.DataField == "Instances" ||
                            c.DataField == "Status" ||
                            c.DataField == "ApprovalStatus")
                     .ToList())
            {
                gEventCalendarItems.Columns.Remove(column);
            }

            // Remove Delete column
            foreach (var column in gEventCalendarItems.Columns.OfType <DeleteField>().ToList())
            {
                gEventCalendarItems.Columns.Remove(column);
            }

            if (AvailableAttributes != null)
            {
                foreach (var attribute in AvailableAttributes)
                {
                    var control = attribute.FieldType.Field.FilterControl(attribute.QualifierValues, "filter_" + attribute.Id.ToString(), false, Rock.Reporting.FilterMode.SimpleFilter);
                    if (control != null)
                    {
                        if (control is IRockControl)
                        {
                            var rockControl = (IRockControl)control;
                            rockControl.Label = attribute.Name;
                            rockControl.Help  = attribute.Description;
                            phAttributeFilters.Controls.Add(control);
                        }
                        else
                        {
                            var wrapper = new RockControlWrapper();
                            wrapper.ID    = control.ID + "_wrapper";
                            wrapper.Label = attribute.Name;
                            wrapper.Controls.Add(control);
                            phAttributeFilters.Controls.Add(wrapper);
                        }

                        string savedValue = rFilter.GetUserPreference(MakeKeyUniqueToEventCalendar(attribute.Key));
                        if (!string.IsNullOrWhiteSpace(savedValue))
                        {
                            try
                            {
                                var values = JsonConvert.DeserializeObject <List <string> >(savedValue);
                                attribute.FieldType.Field.SetFilterValues(control, attribute.QualifierValues, values);
                            }
                            catch { }
                        }
                    }

                    string dataFieldExpression = attribute.Key;
                    bool   columnExists        = gEventCalendarItems.Columns.OfType <AttributeField>().FirstOrDefault(a => a.DataField.Equals(dataFieldExpression)) != null;
                    if (!columnExists)
                    {
                        AttributeField boundField = new AttributeField();
                        boundField.DataField   = dataFieldExpression;
                        boundField.AttributeId = attribute.Id;
                        boundField.HeaderText  = attribute.Name;

                        var attributeCache = Rock.Web.Cache.AttributeCache.Get(attribute.Id);
                        if (attributeCache != null)
                        {
                            boundField.ItemStyle.HorizontalAlign = attributeCache.FieldType.Field.AlignValue;
                        }

                        gEventCalendarItems.Columns.Add(boundField);
                    }
                }
            }

            // Add occurrences Count column
            var occurrencesField = new BadgeField();

            occurrencesField.DangerMin  = int.MaxValue;
            occurrencesField.WarningMin = 0;
            occurrencesField.WarningMax = 0;
            occurrencesField.InfoMin    = 1;
            occurrencesField.InfoMax    = int.MaxValue;
            occurrencesField.DataField  = "Occurrences";
            occurrencesField.HeaderText = "Occurrences";
            occurrencesField.HtmlEncode = false;
            gEventCalendarItems.Columns.Add(occurrencesField);

            // Add Status column
            var statusField = new BoundField();

            statusField.DataField      = "Status";
            statusField.SortExpression = "EventItem.IsActive";
            statusField.HeaderText     = "Status";
            statusField.HtmlEncode     = false;
            gEventCalendarItems.Columns.Add(statusField);

            // Add Approval Status column
            var approvalStatusField = new BoundField();

            approvalStatusField.DataField      = "ApprovalStatus";
            approvalStatusField.SortExpression = "EventItem.IsApproved";
            approvalStatusField.HeaderText     = "Approval Status";
            approvalStatusField.HtmlEncode     = false;
            gEventCalendarItems.Columns.Add(approvalStatusField);

            // Add delete column
            if (_canEdit)
            {
                var deleteField = new DeleteField();
                gEventCalendarItems.Columns.Add(deleteField);
                deleteField.Click += DeleteEventCalendarItem_Click;
            }
        }
Ejemplo n.º 57
0
    protected void bound(string nombreCampo, string nombreLabel)
    {
        if (dt.Rows[0][nombreCampo].ToString() != "0" && dt.Rows[0][nombreCampo] != null && dt.Rows[0][nombreCampo].ToString() != "")
        {
            ////if (nombreCampo == "PrecioAlquiler")
            ////{

            ////    dt.Rows[0].BeginEdit();
            ////    dt.Rows[0][nombreCampo] = Moneda(dt.Rows[0]["MonedaAlquiler"].ToString()) + " " + precio(dt.Rows[0][nombreCampo].ToString());
            ////    dt.Rows[0].EndEdit();
            ////}
            ////else if (nombreCampo == "PrecioVenta")
            ////{
            ////    dt.Rows[0].SetModified();
            ////    dt.Rows[0][nombreCampo] = Moneda(dt.Rows[0]["MonedaVenta"].ToString()) + " " + precio(dt.Rows[0][nombreCampo].ToString());

            ////}

            BoundField bound = new BoundField();

            HiddenFieldimagen.Value = IdInmueble;
            HiddenFieldFechaAlta.Value = dt.Rows[0]["FechaAlta"].ToString();
            HiddenFieldFechaActualiza.Value = dt.Rows[0]["FechaActualiza"].ToString();
            HiddenFieldNombreInmobiliaria.Value = dt.Rows[0]["NombreInmobiliaria"].ToString();
            HiddenFieldNombreUsuario.Value = dt.Rows[0]["NombreUsuario"].ToString();
            HiddenFieldApellidoUsuario.Value = dt.Rows[0]["ApellidoUsuario"].ToString();
            HiddenFieldTelefonoUsuario.Value = dt.Rows[0]["TelefonoUsuario"].ToString();
            HiddenFieldCelularUsuario.Value = dt.Rows[0]["CelularUsuario"].ToString();
            HiddenFieldMailUsuario.Value = dt.Rows[0]["MailUsuario"].ToString();
            HiddenFieldObservaciones.Value = dt.Rows[0]["Observaciones"].ToString();
            HiddenFieldimagen.Value = this.Page.ResolveClientUrl(IdInmueble + "-" + "01" + "_thumb.jpg");
            HiddenFieldgooglemapsimage.Value = "http://maps.googleapis.com/maps/api/staticmap?markers=" + GoogleMap1.Latitude.ToString().Replace(",", ".") + "," + GoogleMap1.Longitude.ToString().Replace(",", ".") + "&amp;zoom=15&amp;size=260x194&amp;sensor=false";

            if (nombreCampo == "PrecioVenta")
            {
                if (dt.Rows[0]["MonedaVenta"].ToString() == "P")
                {
                    bound.HeaderText = nombreLabel + " (ARS$)";
                }
                else if (dt.Rows[0]["MonedaVenta"].ToString() == "D")
                {
                    bound.HeaderText = nombreLabel + " (US$)";
                }

                precioVentaMoneda = bound.HeaderText.ToString();
            }
            else if (nombreCampo == "PrecioVenta2")
            {
                if (dt.Rows[0]["MonedaVenta2"].ToString() == "P")
                {
                    bound.HeaderText = nombreLabel + " (ARS$)";
                }
                else if (dt.Rows[0]["MonedaVenta2"].ToString() == "D")
                {
                    bound.HeaderText = nombreLabel + " (US$)";
                }

                precioVenta2Moneda = bound.HeaderText.ToString();
            }
            else if (nombreCampo == "PrecioAlquiler")
            {
                if (dt.Rows[0]["MonedaAlquiler"].ToString() == "P")
                {
                    bound.HeaderText = nombreLabel + " (ARS$)";
                }
                else if (dt.Rows[0]["MonedaAlquiler"].ToString() == "D")
                {
                    bound.HeaderText = nombreLabel + " (US$)";
                }

                precioAlquilerMoneda = bound.HeaderText.ToString();
                HiddenFieldPrecioAlquiler.Value = dt.Rows[0]["PrecioAlquiler"].ToString();
                HiddenFieldPrecioAlquilerLabel.Value = precioAlquilerMoneda.ToString();
            }
            else
            {
                bound.HeaderText = nombreLabel;
            }

            bound.DataField = nombreCampo;

            bound.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
            bound.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
            DetailsView1.Fields.Add(bound);
        }
    }
Ejemplo n.º 58
0
    private void BindGrid()
    {
        BoundField theCol0 = new BoundField();

        theCol0.HeaderText         = "Appointment Date";
        theCol0.DataField          = "Appointment Date";
        theCol0.SortExpression     = "Appointment Date";
        theCol0.ItemStyle.CssClass = "textstyle";
        theCol0.ReadOnly           = true;

        BoundField theCol1 = new BoundField();

        theCol1.HeaderText         = "Met Date";
        theCol1.DataField          = "Met Date";
        theCol1.SortExpression     = "Met Date";
        theCol1.ItemStyle.CssClass = " textstyle";
        theCol1.ReadOnly           = true;

        BoundField theCol2 = new BoundField();

        theCol2.HeaderText               = "Status";
        theCol2.DataField                = "Status";
        theCol2.ItemStyle.CssClass       = "textstyle";
        theCol2.SortExpression           = "Status";
        theCol2.ItemStyle.Font.Underline = true;
        theCol2.ReadOnly = true;

        BoundField theCol3 = new BoundField();

        theCol3.HeaderText         = "Purpose";
        theCol3.ItemStyle.CssClass = "Purpose";
        theCol3.DataField          = "Purpose";
        theCol3.SortExpression     = "Purpose";
        theCol3.ReadOnly           = true;


        BoundField theCol4 = new BoundField();

        theCol4.HeaderText         = "Appdate";
        theCol4.ItemStyle.CssClass = "textstyle";
        theCol4.DataField          = "Appdate";
        theCol4.SortExpression     = "Appdate";
        theCol4.ReadOnly           = true;

        BoundField theCol5 = new BoundField();

        theCol5.HeaderText         = "LocationName";
        theCol5.ItemStyle.CssClass = "textstyle";
        theCol5.DataField          = "LocationName";
        theCol5.SortExpression     = "LocationName";
        theCol5.ReadOnly           = true;

        ButtonField theBtn = new ButtonField();

        theBtn.ButtonType           = ButtonType.Link;
        theBtn.CommandName          = "Select";
        theBtn.HeaderStyle.CssClass = "textstylehidden";
        theBtn.ItemStyle.CssClass   = "textstylehidden";


        grdSearchResult.Columns.Add(theCol0);
        grdSearchResult.Columns.Add(theCol1);
        grdSearchResult.Columns.Add(theCol2);
        grdSearchResult.Columns.Add(theCol3);
        grdSearchResult.Columns.Add(theCol4);
        grdSearchResult.Columns.Add(theCol5);


        grdSearchResult.Columns.Add(theBtn);

        grdSearchResult.DataBind();
        grdSearchResult.Columns[4].Visible = false;
    }
    protected GridView bindDataByOperation(DataSet ds, GridView gv, string header, DataSet ds_budget)
    {
        if (ds != null && ds.Tables[0].Rows.Count > 0)
        {
            gv.Visible = true;
            gv.AutoGenerateColumns = false;
            gv.Width = Unit.Pixel(600);
            gv.Columns.Clear();

            //Calculate the total column of next year.
            ds.Tables[0].Columns.Add("Total");
            if (ds.Tables[0].Rows[0][0] != DBNull.Value)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    float tmp = 0;
                    for (int count2 = 1; count2 < ds.Tables[0].Columns.Count - 1; count2++)
                    {
                        tmp += float.Parse(dr[count2].ToString());
                    }
                    dr["Total"] = tmp.ToString();
                }
            }

            for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            {
                BoundField bf = new BoundField();

                bf.DataField = ds.Tables[0].Columns[i].ColumnName.ToString();
                bf.HeaderText = ds.Tables[0].Columns[i].Caption.ToString();
                bf.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;

                if (i == 0)
                {
                    bf.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
                    bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
                    bf.ItemStyle.Width = 150;
                }

                gv.Columns.Add(bf);
            }
            gv.Caption = header;
            gv.CaptionAlign = TableCaptionAlign.Left;
            gv.DataSource = ds;

            if (header == "")
            {
                DataRow drSum = ds.Tables[0].NewRow();
                DataRow[] rows = ds.Tables[0].Select();

                float[] Sum = new float[20];
                for (int j = 1; j < ds.Tables[0].Columns.Count - 1; j++)
                {
                    if (ds_budget.Tables[0].Rows.Count != 0)
                        Sum[j] = float.Parse(ds_budget.Tables[0].Rows[0][j].ToString().Trim());
                    else
                        Sum[j] = 0;
                }

                float tmp = 0;
                for (int i = 0; i < ds.Tables[0].Columns.Count - 1; i++)
                {
                    if (i == 0)
                    {
                        drSum[0] = meeting.getnextyear() + "-BDGT";
                    }
                    else
                    {
                        drSum[i] = Sum[i];
                        tmp += Sum[i];
                    }
                }
                drSum[ds.Tables[0].Columns.Count - 1] = tmp.ToString().Trim();
                ds.Tables[0].Rows.InsertAt(drSum, ds.Tables[0].Rows.Count);
            }
            gv.DataBind();
        }
        else
            gv.Visible = false;
        return gv;
    }
Ejemplo n.º 60
0
        private void AtualizaGrelhaJogos()
        {
            gvJogos.Columns.Clear();
            gvJogos.DataSource = null;
            gvJogos.DataBind();

            DataTable dados = BaseDados.Instance.ListaJogos();

            if (dados == null || dados.Rows.Count == 0)
            {
                return;
            }

            DataColumn dcRemover = new DataColumn();

            dcRemover.ColumnName = "Remover";
            dcRemover.DataType   = Type.GetType("System.String");
            dados.Columns.Add(dcRemover);

            DataColumn dcEditar = new DataColumn();

            dcEditar.ColumnName = "Editar";
            dcEditar.DataType   = Type.GetType("System.String");
            dados.Columns.Add(dcEditar);


            gvJogos.DataSource          = dados;
            gvJogos.AutoGenerateColumns = false;

            HyperLinkField hlRemover = new HyperLinkField();

            hlRemover.HeaderText    = "Remover";
            hlRemover.DataTextField = "Remover";
            hlRemover.Text          = "Remover jogo";
            hlRemover.DataNavigateUrlFormatString = "removerjogo.aspx?id_jogo={0}";
            hlRemover.DataNavigateUrlFields       = new string[] { "id_jogo" };
            gvJogos.Columns.Add(hlRemover);

            HyperLinkField hlEditar = new HyperLinkField();

            hlEditar.HeaderText    = "Editar";
            hlEditar.DataTextField = "Editar";
            hlEditar.Text          = "Editar jogo";
            hlEditar.DataNavigateUrlFormatString = "editarjogo.aspx?id_jogo={0}";
            hlEditar.DataNavigateUrlFields       = new string[] { "id_jogo" };
            gvJogos.Columns.Add(hlEditar);

            BoundField bfIdJogo = new BoundField();

            bfIdJogo.DataField  = "id_jogo";
            bfIdJogo.HeaderText = "NºJogo";
            gvJogos.Columns.Add(bfIdJogo);

            BoundField bfNome = new BoundField();

            bfNome.DataField  = "nome";
            bfNome.HeaderText = "Nome";
            gvJogos.Columns.Add(bfNome);

            BoundField bfPreco = new BoundField();

            bfPreco.DataField  = "preco";
            bfPreco.HeaderText = "Preço";
            gvJogos.Columns.Add(bfPreco);

            BoundField bfDescricao = new BoundField();

            bfDescricao.DataField  = "descricao";
            bfDescricao.HeaderText = "Descrição";
            gvJogos.Columns.Add(bfDescricao);

            BoundField bfAvaliacao = new BoundField();

            bfAvaliacao.DataField  = "avaliacao";
            bfAvaliacao.HeaderText = "Avaliação";
            gvJogos.Columns.Add(bfAvaliacao);

            BoundField bfSo = new BoundField();

            bfSo.DataField  = "sistema_operativo";
            bfSo.HeaderText = "Sistema Operativo";
            gvJogos.Columns.Add(bfSo);

            BoundField bfTag = new BoundField();

            bfTag.DataField  = "tag";
            bfTag.HeaderText = "Tag";
            gvJogos.Columns.Add(bfTag);

            BoundField bfEmpresa = new BoundField();

            bfEmpresa.DataField  = "empresa";
            bfEmpresa.HeaderText = "Empresa";
            gvJogos.Columns.Add(bfEmpresa);

            BoundField bfStock = new BoundField();

            bfStock.DataField  = "stock";
            bfStock.HeaderText = "Stock";
            gvJogos.Columns.Add(bfStock);

            BoundField bfAno = new BoundField();

            bfAno.DataField  = "ano";
            bfAno.HeaderText = "Ano";
            gvJogos.Columns.Add(bfAno);

            BoundField bfEstado = new BoundField();

            bfEstado.DataField  = "estado";
            bfEstado.HeaderText = "Estado";
            gvJogos.Columns.Add(bfEstado);

            //capa
            ImageField ifCapa = new ImageField();

            ifCapa.HeaderText = "Capa";
            int rand = new Random().Next(999999999);

            ifCapa.DataImageUrlFormatString = "~/Imagens/{0}.jpg?" + rand;
            ifCapa.DataImageUrlField        = "id_jogo";
            ifCapa.ControlStyle.Width       = 100;
            gvJogos.Columns.Add(ifCapa);

            //databind
            gvJogos.DataBind();
        }