Beispiel #1
0
        public void CrearColumnas(string strTipoDato, string strColumna, ASPxGridView grvGrilla, bool bolVisible, DataTable dtbCombo,
                                  string strCampoClave, string strCampoTexto, string srEtiqueta, string strFormato)
        {
            switch (strTipoDato)
            {
            case "String":
                // columna normal
                GridViewDataTextColumn colText = new GridViewDataTextColumn();
                colText.FieldName = strColumna;
                colText.Visible   = bolVisible;
                //colText.Caption = srEtiqueta;
                grvGrilla.Columns.Add(colText);
                break;

            case "Int32":
                // columna normal
                if (!bolVisible)
                {
                    GridViewDataTextColumn colInt = new GridViewDataTextColumn();
                    colInt.FieldName = strColumna;
                    //colInt.Caption = srEtiqueta;
                    colInt.Visible = false;
                    grvGrilla.Columns.Add(colInt);
                }
                else
                {
                    GridViewDataSpinEditColumn colInt1 = new GridViewDataSpinEditColumn();
                    colInt1.FieldName = strColumna;
                    //colInt1.Caption = srEtiqueta;
                    colInt1.Visible = bolVisible;
                    colInt1.PropertiesSpinEdit.SpinButtons.ShowIncrementButtons = false;
                    colInt1.PropertiesEdit.DisplayFormatString = "N0";
                    grvGrilla.Columns.Add(colInt1);
                }
                break;

            case "Double":
                GridViewDataSpinEditColumn colDouble = new GridViewDataSpinEditColumn();
                colDouble.FieldName = strColumna;
                //colDouble.Caption = srEtiqueta;
                colDouble.Visible = bolVisible;
                colDouble.PropertiesSpinEdit.SpinButtons.ShowIncrementButtons = false;
                colDouble.PropertiesEdit.DisplayFormatString = "N4";
                grvGrilla.Columns.Add(colDouble);
                break;

            case "Time":
                GridViewDataTimeEditColumn colTime = new GridViewDataTimeEditColumn();
                colTime.FieldName = strColumna;
                //colTime.Caption = srEtiqueta;
                colTime.Visible = bolVisible;
                colTime.PropertiesTimeEdit.DisplayFormatString = "HH:mm";
                colTime.PropertiesTimeEdit.EditFormat          = EditFormat.Custom;
                colTime.PropertiesTimeEdit.EditFormatString    = "HH:mm";
                colTime.PropertiesTimeEdit.SpinButtons.ShowIncrementButtons = false;
                colTime.PropertiesTimeEdit.DisplayFormatInEditMode          = true;
                grvGrilla.Columns.Add(colTime);

                break;

            case "Date":
                // columna normal
                GridViewDataDateColumn colDate = new GridViewDataDateColumn();
                colDate.FieldName = strColumna;
                //colDate.Caption = srEtiqueta;
                colDate.Visible = bolVisible;
                colDate.PropertiesDateEdit.DisplayFormatString = "dd-MM-yyyy";
                //colDate.PropertiesDateEdit.ValidationSettings.RequiredField.IsRequired = ValidationSettings.;
                grvGrilla.Columns.Add(colDate);
                break;

            case "DateTime":
                // columna normal
                GridViewDataDateColumn colDateTime = new GridViewDataDateColumn();
                colDateTime.FieldName = strColumna;
                //colDateTime.Caption = srEtiqueta;
                colDateTime.Visible = bolVisible;
                colDateTime.PropertiesDateEdit.DisplayFormatString = "dd-MM-yyyy HH:mm";
                grvGrilla.Columns.Add(colDateTime);
                break;

            case "ComboBox":
                GridViewDataComboBoxColumn colCbo = new GridViewDataComboBoxColumn();
                colCbo.FieldName = strColumna;
                //colCbo.Caption = srEtiqueta;
                colCbo.PropertiesComboBox.ValueType        = typeof(int);
                colCbo.PropertiesComboBox.ValueField       = strCampoClave;
                colCbo.PropertiesComboBox.TextField        = strCampoTexto;
                colCbo.PropertiesComboBox.TextFormatString = "{0}";     // imprime la columna con indice 0
                                                                        //colCbo.PropertiesComboBox.EnableSynchronization = DevExpress.Utils.DefaultBoolean.True;
                colCbo.PropertiesComboBox.DataSource = dtbCombo;
                grvGrilla.Columns.Add(colCbo);
                break;
            }
        }
        protected override void SetDetailColumn()
        {
            GridViewEditDataColumn column;
            GridViewCommandColumn  commandColumn = new GridViewCommandColumn()
            {
                Name = "Action", Caption = "Action", ButtonType = ButtonType.Image
            };
            GridViewCommandColumnCustomButton btnView = new GridViewCommandColumnCustomButton()
            {
                ID = "btnView"
            };

            btnView.Image.Url           = "~/Images/led_icon/view_detail.png";
            btnView.Image.AlternateText = "View Detail";
            btnView.Visibility          = GridViewCustomButtonVisibility.BrowsableRow;
            commandColumn.CustomButtons.Add(btnView);
            detailGrid.Columns.Add(commandColumn);

            detailGrid.Columns.Add(new GridViewDataTextColumn()
            {
                Caption = "ID", FieldName = "TransactionID",
            });
            detailGrid.Columns.Add(new GridViewDataTextColumn()
            {
                Caption = "หมายเลขธุรกรรม", FieldName = "TransactionNo",
            });
            detailGrid.Columns.Add(new GridViewDataTextColumn()
            {
                Caption = "ประเภทธุรกรรม", FieldName = "TransactionType",
            });
            detailGrid.Columns.Add(new GridViewDataTextColumn()
            {
                Caption = "รหัสบัญชีหน่วย", FieldName = "AccountNo",
            });
            detailGrid.Columns.Add(new GridViewDataTextColumn()
            {
                Caption = "กองทุน", FieldName = "FundCode"
            });
            detailGrid.Columns.Add(new GridViewDataTextColumn()
            {
                Caption = "จำนวนเงิน", FieldName = "Amount"
            });
            detailGrid.Columns.Add(new GridViewDataTextColumn()
            {
                Caption = "จำนวนหน่วย", FieldName = "Units"
            });
            detailGrid.Columns.Add(new GridViewDataTextColumn()
            {
                Caption = "ต้นทุน", FieldName = "UnitCost"
            });
            detailGrid.Columns.Add(new GridViewDataTextColumn()
            {
                Caption = "ราคาซื้อ", FieldName = "UnitPrice"
            });
            detailGrid.Columns.Add(new GridViewDataTextColumn()
            {
                Caption = "Applicable Amount", FieldName = "ApplicableAmount"
            });
            detailGrid.Columns.Add(new GridViewDataTextColumn()
            {
                Caption = "Applicable Units", FieldName = "ApplicableUnits"
            });
            detailGrid.Columns.Add(new GridViewDataTextColumn()
            {
                Caption = "ภาษี", FieldName = "TaxAmount"
            });
            column = new GridViewDataTimeEditColumn()
            {
                Caption = "งวดวันที่", FieldName = "TradeDate"
            };
            column.PropertiesEdit.DisplayFormatString = "dd MMM yyyy";
            detailGrid.Columns.Add(column);
            column = new GridViewDataTimeEditColumn()
            {
                Caption = "วันที่มีผล", FieldName = "EffectiveDate"
            };
            column.PropertiesEdit.DisplayFormatString = "dd MMM yyyy";
            detailGrid.Columns.Add(column);
            column = new GridViewDataTimeEditColumn()
            {
                Caption = "วันที่ทำธุรกรรม", FieldName = "TransactionTS"
            };
            column.PropertiesEdit.DisplayFormatString = "dd MMM yyyy HH:mm";
            detailGrid.Columns.Add(column);
        }