Click here to Skip to main content
15,887,821 members
Home / Discussions / C#
   

C#

 
AnswerRe: Sentimental analysis and plotting charts with C# Pin
Mycroft Holmes20-Nov-14 23:31
professionalMycroft Holmes20-Nov-14 23:31 
GeneralRe: Sentimental analysis and plotting charts with C# Pin
Richard MacCutchan20-Nov-14 23:57
mveRichard MacCutchan20-Nov-14 23:57 
GeneralRe: Sentimental analysis and plotting charts with C# Pin
BillWoodruff21-Nov-14 9:35
professionalBillWoodruff21-Nov-14 9:35 
GeneralRe: Sentimental analysis and plotting charts with C# Pin
Mycroft Holmes21-Nov-14 13:10
professionalMycroft Holmes21-Nov-14 13:10 
AnswerRe: Sentimental analysis and plotting charts with C# Pin
BillWoodruff21-Nov-14 9:40
professionalBillWoodruff21-Nov-14 9:40 
GeneralI want to know whether mycode is right Pin
fengyuchun8820-Nov-14 16:45
fengyuchun8820-Nov-14 16:45 
QuestionRe: I want to know whether mycode is right Pin
Richard MacCutchan20-Nov-14 21:51
mveRichard MacCutchan20-Nov-14 21:51 
QuestionWPF Controls Binding to Object doesn't work Pin
jerryeagle20-Nov-14 11:34
jerryeagle20-Nov-14 11:34 
I have a Grid inside another Grid, both Binded to a Model, the Parent Grid works well, but the child Grid Binding doesn't, I can't find the error, this is the object:

<pre lang="c#">using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Schema;
using System.Xml.Serialization;

namespace SAE_Connector
{
[XmlRoot("Configuracion")]
public class clsConfig
{
    [XmlElement]
    public Config config { get; set; }

    [XmlArrayItem]
    public List<PrePoliza> PrePolizas { get; set; }

    public clsConfig()
    {
        config = new Config();
        PrePolizas = new List<PrePoliza>();
    }
}

public class Config
{
    [XmlAttribute]
    public string RutaDB { get; set; }

    public Config()
    {
        Impuestos = new clsImpuestos();
    }

    private string _numEmp = "";
    [XmlAttribute]
    public string NumEmp 
    { 
        get
        {
            return NumeroEmpresaGet();
        }
        set
        {
            _numEmp = NumEmp;
        }
    }

    [XmlAttribute]
    public string InstanciaCompacSQL { get; set; }

    [XmlAttribute]
    public string EmpresaContPAQ { get; set; }

    [XmlAttribute]
    public string PassWord { get; set; }

    [XmlElement("Impuestos")]
    public clsImpuestos Impuestos { get; set; }

    private string NumeroEmpresaGet()
    {
        string _result = "";
        string _emp = string.IsNullOrEmpty(RutaDB) == false ? Path.GetFileNameWithoutExtension(RutaDB) : string.Empty;
        if(string.IsNullOrEmpty(_emp)==false)
        {
            //SAE50EMPRE02
            _result = _emp.Substring(_emp.Length - 2);
        }
        return _result;
    }
}

#region impuestos
    public class clsImpuestos
    {
    [XmlElement("Impuesto1")]    
    public clsImpuesto1 impuesto1 { get; set; }
    [XmlElement("Impuesto2")]
    public clsImpuesto2 impuesto2 { get; set; }
    [XmlElement("Impuesto3")]
    public clsImpuesto3 impuesto3 { get; set; }
    [XmlElement("Impuesto4")]
    public clsImpuesto4 impuesto4 { get; set; }

    public clsImpuestos()
    {
        impuesto1 = new clsImpuesto1();
        impuesto2 = new clsImpuesto2();
        impuesto3 = new clsImpuesto3();
        impuesto4 = new clsImpuesto4();
    }
    }

    public class clsImpuesto1
    {
        [XmlAttribute]
        public string Nombre { get; set; }
        [XmlAttribute]
        public double Tasa { get; set; }
    }    
    public class clsImpuesto2
    {
        [XmlAttribute]
        public string Nombre { get; set; }
        [XmlAttribute]
        public double Tasa { get; set; }
    }    
    public class clsImpuesto3
    {
        [XmlAttribute]
        public string Nombre { get; set; }
        [XmlAttribute]
        public double Tasa { get; set; }
    }    
    public class clsImpuesto4
    {
        [XmlAttribute]
        public string Nombre { get; set; }
        [XmlAttribute]
        public double Tasa { get; set; }
    }
#endregion

public enum eTipoPol { Ingresos, Egresos, Diario }

public class PrePoliza
{
    [XmlAttribute]
    public int Id { get; set; }
    [XmlAttribute]
    public eTipoPol tipoPol { get; set; }
    [XmlAttribute]
    public string Nombre { get; set; }
    [XmlAttribute]
    public string Concepto { get; set; }
    [XmlArrayItem]
    public List<Cuenta> Cuentas { get; set; }

    public enum eCargoAbono { Cargo, Abono }
    public enum eProporcion { SubTotal, Impuesto1, Impuesto2, Impuesto3, Impuesto4, Total }
    public enum eReferenciaConcepto { Vacio, Observaciones, Folio, Texto }

    public PrePoliza()
    {
        Cuentas = new List<Cuenta>();
    }

    public class Cuenta
    {
        [XmlAttribute]
        public int Id { get; set; }
        [XmlAttribute]
        public string CuentaCod { get; set; }
        [XmlAttribute]
        public string Descripcion { get; set; }
        [XmlAttribute]
        public bool EsCuentaCte { get; set; }
        [XmlAttribute]
        public eCargoAbono CargoAbono { get; set; }
        [XmlAttribute]
        public eProporcion Proporcion { get; set; }
        [XmlAttribute]
        public eReferenciaConcepto Referencia { get; set; }
        [XmlAttribute]
        public string RefText { get; set; }
        [XmlAttribute]
        public eReferenciaConcepto Concepto { get; set; }
        [XmlAttribute]
        public string ConcText { get; set; }
    }
}
}


This is the complete XAML
<pre lang="c#"><Window x:Class="wpfSaePolizas.xWindows.wPrePolizas"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Pre-Polizas" Height="600" Width="1000" Background="{StaticResource brBlue}" WindowState="Maximized" Loaded="Window_Loaded" >
<Grid>
    <Grid.Resources>
        <Style TargetType="TextBlock" BasedOn="{StaticResource xTextBlockWhiteS}" >
            <Setter Property="FontWeight" Value="Normal" />
        </Style>
        <Style TargetType="TextBox">
            <Setter Property="Template" Value="{StaticResource TextBoxRoundCorners}" />
        </Style>
        <Style TargetType="Border">
            <Setter Property="CornerRadius" Value="5" />
        </Style>
    </Grid.Resources>
    <Grid.RowDefinitions>
        <RowDefinition Height="70" />
        <RowDefinition />
    </Grid.RowDefinitions>

    <Border Grid.Row="0" BorderThickness="2" BorderBrush="{StaticResource brBorder}" Margin="5" >
        <Border.Resources>
            <Style TargetType="StackPanel" >
                <Setter Property="Orientation" Value="Horizontal" />
            </Style>
            <Style TargetType="Image">
                <Setter Property="Height" Value="20" />
            </Style>
        </Border.Resources>
        <ToolBar Margin="5" Background="Transparent">
            <Button Name="btnNva" Background="#FFFFD801" Width="90" Height="30" Click="btnNva_Click" >
                <Button.Content>
                    <StackPanel>
                        <Image Source="..\img\Add1.png" />
                        <TextBlock Text="Nueva" />
                    </StackPanel>
                </Button.Content>
            </Button>

            <Button Name="btnEliminar" Background="#FFFFD801" Width="90" Height="30" Click="btnEliminar_Click" >
                <Button.Content>
                    <StackPanel>
                        <Image Source="..\img\Del.png" />
                        <TextBlock Text="Eliminar" />
                    </StackPanel>
                </Button.Content>
            </Button>

            <Button Name="btnGuardar" Background="#FFFFD801" Width="90" Height="30" Click="btnGuardar_Click" >
                <Button.Content>
                    <StackPanel>
                        <Image Source="..\img\Save.png" />
                        <TextBlock Text="Guardar" />
                    </StackPanel>
                </Button.Content>
            </Button>

            <Button Name="btnSalir" Background="{StaticResource gradGris}" Width="90" Height="30" Click="btnSalir_Click">
                <Button.Content>
                    <StackPanel>
                        <TextBlock Text="Salir" />
                    </StackPanel>
                </Button.Content>
            </Button>
        </ToolBar>
    </Border>

    <Grid Grid.Row="1">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="400" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <DataGrid Name="dgCuentas" Grid.Column="1" Background="Transparent" AutoGenerateColumns="True" ></DataGrid>

        <Border Name="brConfig" Grid.Column="0" BorderThickness="2" BorderBrush="{StaticResource brBorder}" Margin="5" >
            <Viewbox VerticalAlignment="Top" Margin="5">
                <Grid Name="gridPrePoliza">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="1" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>

                    <TextBlock Text="Pre-Póliza:" Grid.Row="0" Grid.Column="0" />
                    <ComboBox Name="cmbPrePolizas" Grid.Row="0" Grid.Column="1" Margin="5" SelectionChanged="cmbPrePolizas_SelectionChanged" >
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Nombre}" />
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>

                    <TextBlock Text="Nombre:" Grid.Row="1" Grid.Column="0" />
                    <TextBox Name="txtNombre" Grid.Row="1" Grid.Column="1" Text="{Binding Nombre, UpdateSourceTrigger=PropertyChanged}" />

                    <TextBlock Text="Tipo de Póliza:" Grid.Row="2" Grid.Column="0" />
                    <ComboBox Name="cmbTiposPoliza" Grid.Row="2" Grid.Column="1" Margin="5" >
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding }" />
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>

                    <TextBlock Text="Concepto Póliza:" Grid.Row="3" Grid.Column="0" />
                    <TextBox Name="txtConceptoPol" Grid.Row="3" Grid.Column="1" Text="{Binding Concepto, UpdateSourceTrigger=PropertyChanged}" />

                    <Grid Name="gridCuenta" Grid.Row="4" Grid.ColumnSpan="2" Margin="0, 20" IsEnabled="False">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="90" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition Height="Auto" />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>

                       <TextBlock Text="Cuenta:" Grid.Row="0" Grid.Column="0" />
                        <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="1">
                            <TextBox Name="Cuenta" Width="157" Text="{Binding Path=CuentaCod, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" TextChanged="Cuenta_TextChanged"/>
                            <Button Name="btnCuentaBuscar" Content="..." Style="{StaticResource MetroButton}" Width="35" Click="btnCuentaBuscar_Click" Margin="0,0,0,3" VerticalAlignment="Bottom" />
                        </StackPanel>
                        <TextBlock Name="lblCuentaNombre" Text="{Binding Path=Descripcion, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Grid.Row="1" Grid.ColumnSpan="2" TextWrapping="Wrap" HorizontalAlignment="Center" />
                        <CheckBox Name="chbEsCteProv" Grid.Row="2" Grid.ColumnSpan="2">
                            <CheckBox.Content>
                                <TextBlock Text="Es Cuenta de Cliente/Proveedor" />
                            </CheckBox.Content>
                        </CheckBox>

                        <TextBlock Text="Cargo/Abono:" Grid.Row="3" Grid.Column="0" />
                        <ComboBox Name="cmbCargoAbono" Grid.Row="3" Grid.Column="1" Margin="5" SelectionChanged="cmbCargoAbono_SelectionChanged" >
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding}" />
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>

                        <TextBlock Text="Proporción:" Grid.Row="4" Grid.Column="0" />
                        <ComboBox Name="cmbProporcion" Grid.Row="4" Grid.Column="1" Margin="5" SelectionChanged="cmbProporcion_SelectionChanged" >
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding}" />
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>

                        <TextBlock Text="Referencia:" Grid.Row="5" Grid.Column="0" />
                        <ComboBox Name="cmbRefer" Grid.Row="5" Grid.Column="1" Margin="5" SelectionChanged="cmbRefer_SelectionChanged" >
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding}" />
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                        <TextBox Name="txtRefer" Grid.Row="6" Grid.ColumnSpan="2" IsEnabled="False" 
                                 Text="{Binding Path=RefText, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />

                        <TextBlock Text="Concepto:" Grid.Row="7" Grid.Column="0" />
                        <ComboBox Name="cmbConcepto" Grid.Row="7" Grid.Column="1" Margin="5" SelectionChanged="cmbConcepto_SelectionChanged" >
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding}" />
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                        <TextBox Name="txtConcepto" Grid.Row="8" Grid.ColumnSpan="2" IsEnabled="False" 
                                 Text="{Binding Path=ConcText, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />

                    </Grid>

                    <Border Name="brCtasBotones" Grid.Row="5" Grid.ColumnSpan="2" BorderThickness="2" BorderBrush="{StaticResource brBorder}" 
                            Padding="5" CornerRadius="5">
                        <StackPanel Name="stackBotones" Orientation="Horizontal" HorizontalAlignment="Center" IsEnabled="False" >

                            <Button Name="btnNvaCta" Background="#FFFFD801" Width="80" Height="30" Grid.Row="4" Click="btnNvaCta_Click" >
                                <Button.Content>
                                    <StackPanel Orientation="Horizontal">
                                        <Image Source="..\img\Nvo.png" Width="18" />
                                        <TextBlock Text="Nueva" />
                                    </StackPanel>
                                </Button.Content>                                    
                            </Button>

                            <Button Name="btnEliminarCta" Background="#FFFFD801" Width="80" Height="30" Grid.Row="4" Click="btnEliminarCta_Click" >
                                <Button.Content>
                                    <StackPanel Orientation="Horizontal">
                                        <Image Source="..\img\Del.png" Width="18" />
                                        <TextBlock Text="Borrar" />
                                    </StackPanel>
                                </Button.Content>
                            </Button>

                            <Button Name="btnGuardarCta" Background="#FFFFD801" Width="80" Height="30" Grid.Row="4" Click="btnGuardarCta_Click" >
                                <Button.Content>
                                    <StackPanel Orientation="Horizontal">
                                        <Image Source="..\img\Save.png" Width="18" />
                                        <TextBlock Text="Guardar" />
                                    </StackPanel>
                                </Button.Content>
                            </Button>

                        </StackPanel>
                    </Border>

                </Grid>
            </Viewbox>
        </Border>
    </Grid>

</Grid>


This is for setting DataContext to Child Grid
C#
PrePoliza.Cuenta _cta = new PrePoliza.Cuenta();
gridCuenta.DataContext = _cta;


And this is for setting DataContext to DataGrid
C#
dgCuentas.ItemsSource = _prepoliza.Cuentas;


This is the Window of the UI:
http://postimg.org/image/ik94x4iwd/
AnswerRe: WPF Controls Binding to Object doesn't work Pin
Richard MacCutchan20-Nov-14 21:49
mveRichard MacCutchan20-Nov-14 21:49 
QuestionAutomated fetch of data from SQL database using C# Pin
Member 1113303420-Nov-14 9:06
Member 1113303420-Nov-14 9:06 
AnswerRe: Automated fetch of data from SQL database using C# Pin
Mycroft Holmes20-Nov-14 11:44
professionalMycroft Holmes20-Nov-14 11:44 
Questionhow to pass values to different master page in asp.net? Pin
iamvinod3420-Nov-14 5:07
iamvinod3420-Nov-14 5:07 
Questionhow to solve error related to the PInvoke Stack Imbalance Pin
RahulAhire2620-Nov-14 0:49
RahulAhire2620-Nov-14 0:49 
AnswerRe: how to solve error related to the PInvoke Stack Imbalance Pin
Pete O'Hanlon20-Nov-14 1:00
mvePete O'Hanlon20-Nov-14 1:00 
GeneralRe: how to solve error related to the PInvoke Stack Imbalance Pin
RahulAhire2620-Nov-14 1:57
RahulAhire2620-Nov-14 1:57 
AnswerRe: how to solve error related to the PInvoke Stack Imbalance Pin
OriginalGriff20-Nov-14 2:30
mveOriginalGriff20-Nov-14 2:30 
GeneralRe: how to solve error related to the PInvoke Stack Imbalance Pin
RahulAhire2620-Nov-14 2:00
RahulAhire2620-Nov-14 2:00 
GeneralRe: how to solve error related to the PInvoke Stack Imbalance Pin
Richard MacCutchan20-Nov-14 2:32
mveRichard MacCutchan20-Nov-14 2:32 
QuestionC sharp design principle Pin
Sarita S19-Nov-14 19:08
Sarita S19-Nov-14 19:08 
AnswerRe: C sharp design principle Pin
Pete O'Hanlon19-Nov-14 21:09
mvePete O'Hanlon19-Nov-14 21:09 
GeneralRe: C sharp design principle Pin
Sarita S20-Nov-14 0:05
Sarita S20-Nov-14 0:05 
GeneralRe: C sharp design principle Pin
Pete O'Hanlon20-Nov-14 0:34
mvePete O'Hanlon20-Nov-14 0:34 
AnswerRe: C sharp design principle Pin
V.20-Nov-14 3:43
professionalV.20-Nov-14 3:43 
AnswerRe: C sharp design principle Pin
BillWoodruff20-Nov-14 4:21
professionalBillWoodruff20-Nov-14 4:21 
QuestionData at the root level is invalid. Line 1, position 1. Pin
ASPnoob19-Nov-14 4:05
ASPnoob19-Nov-14 4:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.