protected void Page_Load(object sender, EventArgs e)
        {

            try
            {
                Session["Respuesta"] = false; //[TODO: Hacer mensaje de confirmación que se muestra una sola vez, al querer eliminar algo en control ABM]
                this.tipo = typeof(Entidades.Entity_comprobanteVenta);
                this.Titulo = "Lista de Comprobantes Habilitados";

                Valores = new SqlValor[] 
            { 
                new SqlValor("habilitado", 1),
                new SqlValor("empresa_idempresa", 1)
            };


                // Datagrid
                Storer st = new Storer(typeof(Entidades.Entity_comprobanteVenta));
                st.ObjectToSqlDataSource(ref SqlDataSource1);
                OnShow();
                Store1.DataBind();



            }
            catch (Exception ex)
            {
                UIHelper.MostrarExcepcionSimple(ex, "Error");
            }

        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Session["Respuesta"] = false; //[TODO: Hacer mensaje de confirmación que se muestra una sola vez, al querer eliminar algo en control ABM]
                this.tipo = typeof(Entidades.Entity_talonario);
                this.Titulo = "Talonario";

                // Datagrid
                Storer st = new Storer(typeof(Entidades.Entity_talonario));
                st.ObjectToSqlDataSource(ref SqlDataSource1);                
                                
                OnShow();
                Store1.DataBind();

                //Combo Causa de emision
                Storer stcombo = new Storer(typeof(Entidades.Entity_tipocomprobante));
                OnshowTipo(stcombo);
                
            }
            catch (Exception ex)
            {
                UIHelper.MostrarExcepcionSimple(ex, "Error");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Session["Respuesta"] = false; //[TODO: Hacer mensaje de confirmación que se muestra una sola vez, al querer eliminar algo en control ABM]
                this.tipo = typeof(Entidades.Entity_talonario);
                this.Titulo = "Talonario";

            

                // Datagrid
                Storer st = new Storer(typeof(Entidades.Entity_talonario));
                st.ObjectToSqlDataSource(ref SqlDataSource1);                
            
            
              
                this.valoresCombo = new SqlValor[] { new SqlValor("tiposcomprobante_empresa_idempresa", Global.CodEmpresa) };
                OnShow();
                Store1.DataBind();
                /* Storer combo = new Storer(typeof(Entidades.Entity_tipocomprobante));   
               
                combo.ObjectToSqlDataSource(ref SqlDataSource2);                              
                Store2.DataBind();
                OnShowCombo();*/
            }
            catch (Exception ex)
            {
                UIHelper.MostrarExcepcionSimple(ex, "Error");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Session["Respuesta"] = false; //[TODO: Hacer mensaje de confirmación que se muestra una sola vez, al querer eliminar algo en control ABM]
                this.tipo = typeof(Entidades.Entity_causasEmision);
                this.Titulo = "Causas de emision";

                Valores = new SqlValor[] 
            { 
                new SqlValor("empresa_idempresa", Global.CodEmpresa)
            };

                // Datagrid
                Storer st = new Storer(typeof(Entidades.Entity_causasEmision));
                st.ObjectToSqlDataSource(ref SqlDataSource1);
                OnShow();
                



            }
            catch (Exception ex)
            {
                UIHelper.MostrarExcepcionSimple(ex, "Error");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Session["Respuesta"] = false; //[TODO: Hacer mensaje de confirmación que se muestra una sola vez, al querer eliminar algo en control ABM]
                this.tipo = typeof(Entidades.Entity_concepto);
                this.Titulo = "Conceptos de facturacion";

                                

                // Datagrid
                Storer st = new Storer(typeof(Entidades.Entity_concepto));
                st.ObjectToSqlDataSource(ref SqlDataSource1);
                OnShow();
                Store1.DataBind();
              

                //ComboBox
                 
                tipoCombo = typeof(Entidades.Entity_tasaiva);
                ComboBoxObjetos.Width = ComboBoxObjetos.Width;
                ValoresCombo = new SqlValor[] 
            { 
                new SqlValor("empresa_idempresa", ModuloSoporte.Global.CodEmpresa)
            };
                OnShowComboBox();

            
            }
            catch (Exception ex)
            {
                UIHelper.MostrarExcepcionSimple(ex, "Error");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!ContabilidadGlobal.Admin.Permisos.Alta)
            {
                Session["Mensaje"] = "Usted no tiene los permisos para acceder a esta sección.";
                Session["Titulo"] = "Acceso denegado";
                Response.Redirect("../../Mensaje.aspx");
            }
            else
            if (!X.IsAjaxRequest)
            {
                SelectedItem = null;
                TempId = 0;

                Storer st = new Storer(typeof(PreMovimiento));
                st.ObjectToStore(ref Store1);

                TextFieldMonto.DecimalSeparator = TraductorHelper.GetSeparador();
                TextFieldMonto.Note = string.Format("Ej.: {0}", Movimiento.ObtenerValorFormateado(150, 25));

                DateFieldAsiento.Value = DateTime.Today;
                CargarDatosEnCombo();
                CargarDatosEnComboMovs();
                Movimientos = new List<PreMovimiento>();
                CargarDatosEnGrid();

                CheckBoxHabilitado.Checked = true;

                /* Bugfixer: al hacer varios clicks en aceptar te agrega muchas veces un mov. */
                Session["CanClick"] = true;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session[var] == null || Session[var].ToString().Equals(""))
            {
                if (!X.IsAjaxRequest)
                {
                    PrepararClienteCompensacion.PrepararCliente(var, "CompensacionComprobante.aspx", this);
                    Response.Redirect("PrepararClienteCompensacion.aspx");
                }
            }
            var codCliente = (int)Session[var];
           


            this.Tipo = typeof(Entity_comprobanteVenta);
            Valores = new SqlValor[] 
            { 
                new SqlValor("habilitado", 1),
                new SqlValor("empresa_idempresa", ContabilidadGlobal.Admin.CodEmpresa),
                new SqlValor("cliente_codCliente",codCliente)
            };


            // Datagrid
            Storer st = new Storer(typeof(Entidades.Entity_comprobanteVenta));
            st.ObjectToSqlDataSource(ref SqlDataSource1);
            OnShow();
            Store1.DataBind();


           
        }
        private void OnshowTipo(Storer storeCombo)
        {
            if (StringConnection.Equals(""))
                StringConnection = CapaDatos.Datos.ConnectionString;
           
            Select = storeCombo.GetSelect();


            this.SqlDataSource3.ProviderName = "MySql.Data.MySqlClient";
            this.SqlDataSource3.ConnectionString = StringConnection;
            this.SqlDataSource3.SelectCommand = Select;
        }
        protected void Page_Load(object sender, EventArgs e)
        {

           //ComboClientes
            Storer stcli = new Storer(typeof(Entity_cliente));           
            OnshowCli(stcli);
           //Combo moneda
            Storer stmon = new Storer(typeof(Entity_moneda));
            OnshowMoneda(stmon);            
            //Combo Causa de emision
            Storer stca = new Storer(typeof(Entity_causasEmision));
            OnshowCausa(stca);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            configurarColores(Titulo);

            st = new WebHelper.Storer(Tabla);
           
            cargarFiltros(st);
            chart = new ColumnChart();
            chart.Fill.Color = Color.FromArgb(50, Color.SteelBlue);
            chart.Line.Color = Color.SteelBlue;
            chart.Line.Width = 4;
            chart.Legend = Leyenda;

            chart.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {

            Session["Respuesta"] = false; //[TODO: Hacer mensaje de confirmación que se muestra una sola vez, al querer eliminar algo en control ABM]
            this.tipo = typeof(Entidades.Entity_concepto);
            this.Titulo = "Conceptos de facturacion";
            
            // Datagrid
            Storer st = new Storer(typeof(Entidades.Entity_concepto));
            st.ObjectToSqlDataSource(ref SqlDataSource1);
            OnShow();
            Store1.DataBind();
            
            #warning terminar tema de los combobox
            
            //ComboTasaIva
            Storer sttasaiva = new Storer(typeof(Entity_tasaiva));
            OnshowTasaIva(sttasaiva);
            
            //ComboMonedas
            Storer stMonedas = new Storer(typeof(Entity_moneda));
            OnshowMoneda(stMonedas);
        }
        public void OnShowComboBox()
        {
            try
            {
                if (StringConnection.Equals(""))
                    StringConnection = CapaDatos.Datos.ConnectionString;

                Storer stc = new WebHelper.Storer(tipoCombo);
                stc.Valores = ValoresCombo;

                if (Select.Equals(""))
                    Select = stc.GetSelect();

                this.SqlDataSource1.ProviderName = "MySql.Data.MySqlClient";
                this.SqlDataSource1.ConnectionString = StringConnection;
                this.SqlDataSource1.SelectCommand = Select;

                stc.ObjectToSqlDataSource(ref SqlDataSource1);
                stc.ObjectToStore(ref Store3);
            }
            catch (Exception ex)
            {
                UIHelper.MostrarExcepcionSimple(ex, "Error en " + this.ID);
            }
        }
        public void OnShow()
        {
            try
            {
                if (StringConnection.Equals(""))
                    StringConnection = CapaDatos.Datos.ConnectionString;

                Storer st = new WebHelper.Storer(Tipo);       

                if (Insert.Equals(""))
                    Insert = st.GetInsert();
                if (Select.Equals(""))
                    Select = st.GetSelect();
                if (Update.Equals(""))
                    Update = st.GetUpdate();
                if (Delete.Equals(""))
                    Delete = st.GetDelete();

                this.SqlDataSource1.ProviderName = "MySql.Data.MySqlClient";
                this.SqlDataSource1.ConnectionString = StringConnection;
                this.SqlDataSource1.InsertCommand = Insert;
                this.SqlDataSource1.SelectCommand = Select;
                this.SqlDataSource1.UpdateCommand = Update;
                this.SqlDataSource1.DeleteCommand = Delete;

                st.ObjectToSqlDataSource(ref SqlDataSource1);
                st.ObjectToStore(ref Store1);
                      
            }
            catch (Exception ex)
            {
                UIHelper.MostrarExcepcionSimple(ex, "Error");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
          

           /* if (!ContabilidadGlobal.Admin.Permisos.Alta)
            { 
                Session["Mensaje"] = "Usted no tiene los permisos para acceder a esta sección.";
                Session["Titulo"] = "Acceso denegado";
                Response.Redirect("../../Mensaje.aspx");
            }*/
          //  else if (!X.IsAjaxRequest)
           // {
                SelectedItem = null;

                // Datagrid
                Storer st = new Storer(typeof(ItemComprobante));
                st.ObjectToStore(ref StoreItems);
                st.ObjectToGridPanel(ref GridPanelItems);
                ItemsComprobante = new List<ItemComprobante>();
                CargarDatosEnGrid();

                /* Bugfixer [Ver ingreso de asientos]. */
                Session[sessionCanClick] = true;
                //            }

                ComboMonedas.Tipo = typeof(Entidades.Entity_moneda);
                ComboMonedas.Width = 300;
                ComboMonedas.OnShow();

                ComboClasesCliente.Tipo = typeof(Entidades.Entity_cliente);
                ComboClasesCliente.Width = ComboMonedas.Width;
                ComboClasesCliente.Valores = new SqlValor[]
            {
                new SqlValor("Empresa_idempresa", ContabilidadGlobal.Admin.CodEmpresa)
            };
                ComboClasesCliente.OnShow();


                ComboClasesCondicionVenta.Tipo = typeof(Entidades.Entity_condicionesventa);
                ComboClasesCondicionVenta.Width = ComboClasesCondicionVenta.Width;
                ComboClasesCondicionVenta.Valores = new SqlValor[]
            {
            
           new SqlValor ("empresa_idempresa", ContabilidadGlobal.Admin.CodEmpresa) 
            };
                ComboClasesCondicionVenta.OnShow();


                //ComboClasesPunto.Tipo = typeof(Entidades.Entity_puntoregistracion);
                //ComboClasesPunto.Width = ComboMonedas.Width;
                //ComboClasesPunto.OnShow();

                ComboClasesProvincia.Tipo = typeof(Entidades.Entity_provincia);
                ComboClasesProvincia.Width = ComboMonedas.Width;
                ComboClasesProvincia.OnShow();

                ComboClasesTipoOperacion.Width = ComboMonedas.Width;

                ComboTipoLista.Tipo = typeof(Entidades.Entity_tipolista);
                ComboTipoLista.Width = ComboMonedas.Width;
                ComboTipoLista.OnShow();

                // if (Checkbox2.Checked == true) pregunto a la hora de calcular los totales

                ComboClases1.Tipo = typeof(Entidades.Entity_descuentoscomerciales);
                ComboClases1.Width = ComboClases1.Width;
                ComboClases1.OnShow();



                //if (Checkbox1.Checked == true) pregunto a la hora de calcular los totales

                ComboClases2.Tipo = typeof(Entidades.Entity_descuentosfinancieros);
                ComboClases2.Width = ComboClases1.Width;
                ComboClases2.OnShow();

        //    }
        }
        protected void OnRowSelect_Event(object sender, DirectEventArgs e)
        {
            SelectedItem = null;
            try
            {
                string json = e.ExtraParams["Values"];
                Dictionary<string, string>[] rows = JSON.Deserialize<Dictionary<string, string>[]>(json);
                Storer st = new Storer(typeof(ItemComprobante));
                SelectedId = rows[0][st.Armador.Atributos[0].Nombre];
                SelectedItem = st.MakeObjectFromRow(rows);
            }
            catch { }

            // TODO
        }
        public void OnShowRegimenesEspeciales()
        {
            try
            {
                if (StringConnection.Equals(""))
                    StringConnection = CapaDatos.Datos.ConnectionString;

                Storer st = new WebHelper.Storer(typeof(Entity_regimenesEspeciales));
                st.Valores = Valores;
                //st.ValoresCombo = ValoresCombo;

              //  if (Select.Equals(""))
                    Select = st.GetSelect();

                this.SqlDataSource1.ProviderName = "MySql.Data.MySqlClient";
                this.SqlDataSource1.ConnectionString = StringConnection;
                this.SqlDataSource1.SelectCommand = Select;


                st.ObjectToSqlDataSource(ref SqlDataSource1);
                st.ObjectToStore(ref Store3);
                st.ObjectToGridPanel(ref GridPanelRegimenesEspeciales);
                cargarFiltros(st);
            }
            catch (Exception ex)
            {
                UIHelper.MostrarExcepcionSimple(ex, "Error");
            }
        }
        /// <summary>
        /// Actualiza las consultas si se modificaron los sqlvalor.
        /// </summary>
        public void ActualizarConsultas()
        {
            try
            {
                Storer st = new WebHelper.Storer(Tipo);
                st.Valores = Valores;

                Insert = st.GetInsert();
                Select = st.GetSelect();
                Update = st.GetUpdate();
                Delete = st.GetDelete();

                this.SqlDataSource1.InsertCommand = Insert;
                this.SqlDataSource1.SelectCommand = Select;
                this.SqlDataSource1.UpdateCommand = Update;
                this.SqlDataSource1.DeleteCommand = Delete;

                //Solución mágica
                this.Store1.DataBind(); // Linea mágica que trae los nuevos registros
                this.GridPanel1.Reconfigure();
            }
#if DEBUG
            catch(Exception ex)
            {
                UIHelper.MostrarExcepcionSimple(ex, "Error al actualizar referencias");
            }
#else
            catch
            {
                UIHelper.MostrarError("Por favor, recargue la página para solucionar el problema. Si este persiste, por favor, comuníquese con el área de soporte técnico.", "Error al actualizar referencias");
            }
#endif
        }
        public void cargarFiltros(Storer st)
        {
            List<object[]> names = new List<object[]>();

            foreach (Atributos s in st.Armador.Atributos)
            {
                //Si no se definió una columna, o si se configuró una columna visible
                //entonces, agregamos el atributo.
                if (s.Columna == null)
                {
                    names.Add(new object[] { s.Nombre, s.Nombre });
                }
                else if (s.Columna.Visible)
                {
                    names.Add(new object[] { s.Nombre, s.Columna.Titulo });
                }
            }

            Store2.DataSource = names;
            Store2.DataBind();

            st.ObjectToFilters(ref this.GridFilters1);
        }
        protected void OnRowSelect_EventItems(object sender, DirectEventArgs e)
        {


            string json = e.ExtraParams["values1"];

            Dictionary<string, string>[] lista = JSON.Deserialize<Dictionary<string, string>[]>(json);

            Entity_lineaVenta linea = new Entity_lineaVenta();
            linea.Codigo = int.Parse(lista[0]["Codigo"]);
            linea.Concepto_codConcepto = int.Parse(lista[0]["Concepto_codConcepto"]);
            linea.Cantidad = int.Parse(lista[0]["Cantidad"]);
            linea.ImporteNeto = double.Parse(lista[0]["ImporteNeto"]);
            linea.TasaIva = double.Parse(lista[0]["TasaIva"]);
            linea.Importe = double.Parse(lista[0]["Importe"]);
            linea.Concepto_moneda_idmoneda = int.Parse(lista[0]["Concepto_moneda_idmoneda"]);

            //"[{\"id\":-69,\"Codigo\":1,\"Concepto_codConcepto\":3,\"Concepto_moneda_idmoneda\":1,\"Cantidad\":43,\"TasaIva\":21,\"ImporteNeto\":100,\"Importe\":182062}]"


            SelectedId = lista[0]["id"];
            Storer st = new Storer(typeof(Entity_lineaVenta));
            SelectedItem = (object)linea;
            //       Entidades.Entity_concepto concept = (Entidades.Entity_concepto)SelectedItem;   


            // TODO
        }
        protected void buttonFiltro_OnClick(object sender, DirectEventArgs e)
        {
            string name = comboBox1.Text;
            Atributos a = (new WebHelper.Storer(Tipo)).GetAtributosFromColumna(name);
            Storer st = new WebHelper.Storer(Tipo);
            string valor = Text.Text;
            GridFilter gf = Storer.GetFilter(GridFilters1, a.Nombre);
            try
            {
                switch (Storer.GetBasicType(a.Tipo))
                {
                    case WebHelper.Storer.BasicType.Number:
                        {
                            NumericFilter filtro = (NumericFilter)gf;
                            filtro.SetValue(float.Parse(valor));
                        }
                        break;
                    case WebHelper.Storer.BasicType.Text:
                        {
                            StringFilter filtro = (StringFilter)gf;
                            filtro.SetValue(valor);
                        }
                        break;
                    case WebHelper.Storer.BasicType.Date:
                        {
                            DateFilter filtro = (DateFilter)gf;
                            filtro.SetValue(DateTime.Parse(valor));
                        }
                        break;
                    case WebHelper.Storer.BasicType.Bool:
                        {
                            BooleanFilter filtro = (BooleanFilter)gf;
                            filtro.SetValue(bool.Parse(valor));
                        }
                        break;
                }

                gf.SetActive(true);
            }
            catch (Exception ex)
            {
                UIHelper.MostrarExcepcionSimple(ex, "Error");
            }
        }
Example #21
0
        protected void OnRowSelect_Event(object sender, DirectEventArgs e)
        {
            SelectedItem = null;
            try
            {
                string json = e.ExtraParams["Values"];
                Dictionary<string, string>[] rows = JSON.Deserialize<Dictionary<string, string>[]>(json);
                SelectedId = rows[0]["id"];
                Storer st = new Storer(typeof(PreMovimiento));
                SelectedItem = st.MakeObjectFromRow(rows);
            }
            catch { }

            // TODO
        }
        protected void OnRowSelect_Event(object sender, DirectEventArgs e)
        {
           
            SelectedItem = null;
            try
            {
                string json = e.ExtraParams["Values"];
                Dictionary<string, string>[] rows = JSON.Deserialize<Dictionary<string, string>[]>(json);

                Storer st = new Storer(Tipo);
                st.Valores = Valores;
                SelectedItem = st.MakeObjectFromRow(rows);
            }
            catch { }

            if (AlSeleccionar != null)
            {
                AlSeleccionar.Invoke(this, EventArgs.Empty);
            }
        }
        protected void OnRowSelect_Event(object sender, DirectEventArgs e)
        {

            string json = e.ExtraParams["Values"];
            Dictionary<string, string>[] lista = JSON.Deserialize<Dictionary<string, string>[]>(json);

            Entidades.Entity_concepto conceptoNuevo = new Entity_concepto();

            conceptoNuevo.Codconcepto = int.Parse(lista[0]["Codconcepto"]);
            conceptoNuevo.Descripcion = lista[0]["Descripcion"];
            conceptoNuevo.Clase = lista[0]["Clase"];
            conceptoNuevo.Observaciones = lista[0]["Observaciones"];
            conceptoNuevo.Tipo = lista[0]["Tipo"];
            conceptoNuevo.Tasaiva = double.Parse(lista[0]["Tasaiva"]);
            conceptoNuevo.PrecioNeto = double.Parse(lista[0]["PrecioNeto"]);
            conceptoNuevo.PrecioFinal = double.Parse(lista[0]["PrecioFinal"]);
            //conceptoNuevo.Empresa_idempresa = int.Parse(lista[0]["Empresa_idempresa"]);
            //conceptoNuevo.Moneda_idmoneda = int.Parse(lista[0]["Moneda_idmoneda"]);


            Storer st = new Storer(typeof(Entity_concepto));
            SelectedItem = (object)conceptoNuevo;
            //   Entidades.Entity_concepto concept = (Entidades.Entity_concepto)SelectedItem;       
        }
        protected void DeleteRow()
        {
            try
            {
                string json = Session["json"].ToString();
                Dictionary<string, string>[] companies = JSON.Deserialize<Dictionary<string, string>[]>(json);

                Storer st = new Storer(Tipo);
                st.Valores = Valores;
                string consulta = st.MakeDeleteRow(companies);
                Datos.ConsultarEx(consulta);
            }
            catch { }
            //Store1.WarningOnDirty = false;
            GridPanel1.Reload();
            //Store1.WarningOnDirty = true;
        }
        protected void DeleteRow()
        {

            bool respu = (bool)Session["Respuesta"];
            if (respu == true)
            {
                string json = Session["json"].ToString();
                Dictionary<string, string>[] companies = JSON.Deserialize<Dictionary<string, string>[]>(json);

                Storer st = new Storer(Tipo);
                st.Valores = ValoresCombo;
                string consulta = st.MakeDeleteRow(companies);
                Datos.ConsultarEx(consulta);
                GridPanel1.Reload();
            }

        }
        public void OnShow()
        {
            try
            {
                //Harcoded here
                if (StringConnection.Equals(""))
                    StringConnection = CapaDatos.Datos.ConnectionString;
                //End hard

                Storer st = new WebHelper.Storer(Tipo);
                st.Valores = Valores;
                st.ValoresCombo = ValoresCombo;

                if (Insert.Equals(""))
                    Insert = st.GetInsert();
                if (Select.Equals(""))
                    Select = st.GetSelect();
                if (Update.Equals(""))
                    Update = st.GetUpdate();
                if (Delete.Equals(""))
                    Delete = st.GetDelete();

                this.SqlDataSource1.ProviderName = "MySql.Data.MySqlClient";
                this.SqlDataSource1.ConnectionString = StringConnection;
                this.SqlDataSource1.InsertCommand = Insert;
                this.SqlDataSource1.SelectCommand = Select;
                this.SqlDataSource1.UpdateCommand = Update;
                this.SqlDataSource1.DeleteCommand = Delete;

                st.ObjectToSqlDataSource(ref SqlDataSource1);
                st.ObjectToStore(ref Store1);
                st.ObjectToGridPanel(ref GridPanel1);

                //Aplicar cuestiones de seguridad
                if (Permisos == null)
                {
                    Permisos = Permisos.PermisosAdmin;
                }

                if (!Permisos.Alta)
                {
                    this.btnInsert.Enabled = false;
                    if (!Permisos.Modif)
                    {
                        this.btnSave.Enabled = false;
                    }
                }
                if (!Permisos.Baja)
                {
                    this.btnDelete.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                UIHelper.MostrarExcepcionSimple(ex, "Error");
            }
        }
        public void OnShow()
        {
            try
            {
                if (StringConnection.Equals(""))
                    StringConnection = CapaDatos.Datos.ConnectionString;

                Storer st = new WebHelper.Storer(Tipo);
                st.Valores = ValoresCombo;
                st.ValoresCombo = ValoresCombo;

                if (Insert.Equals(""))
                    Insert = st.GetInsert();
                if (Select.Equals(""))
                    Select = st.GetSelect();
                if (Update.Equals(""))
                    Update = st.GetUpdate();
                if (Delete.Equals(""))
                    Delete = st.GetDelete();

                this.SqlDataSource1.ProviderName = "MySql.Data.MySqlClient";
                this.SqlDataSource1.ConnectionString = StringConnection;
                this.SqlDataSource1.InsertCommand = Insert;
                this.SqlDataSource1.SelectCommand = Select;
                this.SqlDataSource1.UpdateCommand = Update;
                this.SqlDataSource1.DeleteCommand = Delete;

                st.ObjectToSqlDataSource(ref SqlDataSource1);
                st.ObjectToStore(ref Store1);
                // st.ObjectToGridPanel(ref GridPanel1);

                // Permisos de la tabla
                if (Permisos == null)
                    Permisos = ContabilidadGlobal.Admin.Permisos;

                if (!Permisos.Alta)
                {
                    this.btnInsert.Enabled = false;
                    this.btnInsert.Hide();
                    if (!Permisos.Modif)
                    {
                        this.btnSave.Enabled = false;
                        this.btnSave.Hide();
                    }
                }
                if (!Permisos.Baja)
                {
                    this.btnDelete.Enabled = false;
                    this.btnDelete.Hide();
                }

                cargarFiltros(st);
            }
            catch (Exception ex)
            {
                UIHelper.MostrarExcepcionSimple(ex, "Error");
            }
        }
        public void OnShowCredito()
        {
            try
            {
                if (StringConnection.Equals(""))
                    StringConnection = CapaDatos.Datos.ConnectionString;

                Storer st = new WebHelper.Storer(typeof(Entidades.Entity_ComprobanteCompra));
                st.Valores = Valores;
                st.ValoresCombo = ValoresCombo;

                //  if (Select.Equals(""))
                Select = st.GetSelect();

                this.SqlDataSource1.ProviderName = "MySql.Data.MySqlClient";
                this.SqlDataSource1.ConnectionString = StringConnection;
                this.SqlDataSource1.SelectCommand = Select;

                st.ObjectToSqlDataSource(ref SqlDataSource1);
                st.ObjectToStore(ref Store1);
          //      st.ObjectToGridPanel(ref GridPanelCredito);
            }
            catch (Exception ex)
            {
                UIHelper.MostrarExcepcionSimple(ex, "Error");
            }
        }
        /// <summary>
        /// Ejecuta el evento antes de modificar un registro en la base de datos.
        /// </summary>
        /// <param name="e"></param>
        protected void AlModificarRecord(ref BeforeRecordUpdatedEventArgs e)
        {
            // Seguridad
            IDictionary test = e.NewValues;
            var companies = new Dictionary<string, string>[1];
            companies[0] = new Dictionary<string, string>();

            try
            {
                foreach (object o in test.Keys)
                {
                    var value = test[o].ToString();
                    SQLInjection.AplicarSeguridad(ref value);
                    if (SQLInjection.IsSqlSentence(value))
                    {
                        throw new Exception("Uno de los valores ingresados no cumple con las reglas de seguridad del sistema. La operación será cancelada.");
                    }
                    else
                    {
                        companies[0].Add(o.ToString(), value);
                    }
                }
            }
            catch (Exception ex)
            {
                UIHelper.MostrarExcepcionSimple(ex, "Error de seguridad");
                e.Cancel = true;
            }

            // Evento al modificar
            if (AlModificar != null)
            {
                object obj;
                try
                {
                    Storer st = new Storer(Tipo);
                    st.Valores = ValoresCombo;

                    obj = st.MakeObjectFromRow(companies);
                }
                catch (Exception ex)
                {
                    obj = null;
                    UIHelper.MostrarExcepcionSimple(ex, "Error");
                }
                CallAlModificar(obj, ref e);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
        


           /* if (!ContabilidadGlobal.Admin.Permisos.Alta)
            { 
                Session["Mensaje"] = "Usted no tiene los permisos para acceder a esta sección.";
                Session["Titulo"] = "Acceso denegado";
                Response.Redirect("../../Mensaje.aspx");
            }*/
          //  else 
            if (!X.IsAjaxRequest)
           {
                SelectedItem = null;

                
                TotalDescuentos.Text = "0";
                TotalNeto.Text = "0";
                TotalOtros.Text = "0";
                Total.Text = "0";
                IVA.Text = "0";
                TotalRecargos.Text = "0";

                // Datagrid
                Storer st = new Storer(typeof(Entity_lineaVenta));
                st.ObjectToStore(ref StoreItems);
                st.ObjectToGridPanel(ref GridPanelItems);
                ItemsComprobante = new List<Entity_lineaVenta>();
                CargarDatosEnGrid();

                /* Bugfixer [Ver ingreso de asientos]. */
                Session[sessionCanClick] = true;
                //            }

                ComboMonedas.Tipo = typeof(Entity_moneda);
                ComboMonedas.Width = 300;
                ComboMonedas.OnShow();

                //ComboClientes
                Storer stcli = new Storer(typeof(Entity_cliente));
                OnshowCli(stcli);
                               
                       
                ComboClasesCondicionVenta.Tipo = typeof(Entidades.Entity_condicionesventa);
                ComboClasesCondicionVenta.Width = ComboClasesCondicionVenta.Width;
                ComboClasesCondicionVenta.Valores = new SqlValor[]
            {
            
           new SqlValor ("empresa_idempresa", ContabilidadGlobal.Admin.CodEmpresa) 
            };
                ComboClasesCondicionVenta.OnShow();

                ComboClasesProvincia.Tipo = typeof(Entidades.Entity_provincia);
                ComboClasesProvincia.Width = ComboMonedas.Width;
                ComboClasesProvincia.OnShow();

                ComboClasesTipoOperacion.Width = ComboMonedas.Width;

                ComboTipoLista.Tipo = typeof(Entity_tipolista);
                ComboTipoLista.Width = ComboMonedas.Width;
                ComboTipoLista.OnShow();

                // if (Checkbox2.Checked == true) pregunto a la hora de calcular los totales


                //ComboDescuentoFinanciero
                Storer stdesFinan = new Storer(typeof(Entity_descuentosfinancieros));
                OnshowDescF(stdesFinan);

                //ComboDescuentoComercial
                Storer stdesComercial = new Storer(typeof(Entity_descuentoscomerciales));
                OnshowDescComercial(stdesComercial);

             
               // Datagrid conceptos
                Storer sto = new Storer(typeof(Entity_concepto));
               
                //sto.ObjectToSqlDataSource(ref SqlDataSource1);
                OnShow();
                Store1.DataBind();

                //Datagrid regimenes especiales
                OnShowRegimenesEspeciales();
              


           }
        }