private void GridConfig_CurrentCellValidating(object sender, CurrentCellValidatingEventArgs e)
        {
            try
            {
                var reflector   = this.GridConfig.View.GetPropertyAccessProvider();
                int columnIndex = (sender as SfDataGrid).SelectionController.CurrentCellManager.CurrentRowColumnIndex.RowIndex;
                var rowData     = GridConfig.GetRecordAtRowIndex(columnIndex);
                //{
                //        dynamic ww = SiaWin.WindowExt(9326, "InBuscarReferencia");  //carga desde sql
                //        ww.Conexion = SiaWin.Func.DatosEmp(idemp);
                //        ww.idEmp = idemp;
                //        ww.idBod = tx_bodega.Text;
                //        ww.UltBusqueda = "";
                //        ww.ShowInTaskbar = false;
                //        ww.Owner = Application.Current.MainWindow;
                //        ww.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                //        ww.Height = 400;
                //        ww.ShowDialog();
                //        string code = ww.Codigo;
                //        reflector.SetValue(rowData, "cod_ref", code);
                //        GridConfig.UpdateDataRow(columnIndex);
                //        GridConfig.UpdateLayout();
                //        GridConfig.Columns["cod_ref"].AllowEditing = true;
                //    }
                //    else
                //    {
                //        string refe = reflector.GetValue(rowData, "cod_ref").ToString().Trim();

                //        if (string.IsNullOrEmpty(refe))
                //        {
                //            dynamic ww = SiaWin.WindowExt(9326, "InBuscarReferencia");  //carga desde sql
                //            ww.Conexion = SiaWin.Func.DatosEmp(idemp);
                //            ww.idEmp = idemp;
                //            ww.idBod = tx_bodega.Text;
                //            ww.UltBusqueda = "";
                //            ww.ShowInTaskbar = false;
                //            ww.Owner = Application.Current.MainWindow;
                //            ww.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                //            ww.Height = 400;
                //            ww.ShowDialog();
                //            string code = ww.Codigo;
                //            reflector.SetValue(rowData, "cod_ref", code);
                //            GridConfig.UpdateDataRow(columnIndex);
                //            GridConfig.UpdateLayout();
                //            GridConfig.Columns["cod_ref"].AllowEditing = true;
                //        }
                //    }
            }
            catch (Exception w)
            {
                SiaWin.Func.SiaExeptionGobal(w);
                MessageBox.Show("error Activiting:" + w);
            }
        }
Exemple #2
0
        private void GridConfig_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                GridColumn Colum = ((SfDataGrid)sender).CurrentColumn as GridColumn;
                if (Colum.MappingName == "cod_ref" && e.Key == Key.F8)
                {
                    if (GridConfig.SelectedIndex == -1)
                        this.GridConfig.SelectionController.CurrentCellManager.BeginEdit();

                    int idr = 0; string code = ""; string nom = "";
                    dynamic winb = SiaWin.WindowBuscar("inmae_ref", "cod_ref", "nom_ref", "cod_ref", "idrow", "Maestra de referencia", SiaWin.Func.DatosEmp(idemp), false, "", idEmp: idemp);
                    winb.ShowInTaskbar = false;
                    winb.Owner = System.Windows.Application.Current.MainWindow;
                    winb.Height = 300;
                    winb.Width = 400;
                    winb.ShowDialog();
                    idr = winb.IdRowReturn;
                    code = winb.Codigo;
                    nom = winb.Nombre;
                    if (!string.IsNullOrEmpty(code))
                    {
                        var func = refe(code);
                        if (func.Item1)
                        {
                            var reflector = this.GridConfig.View.GetPropertyAccessProvider();
                            int columnIndex = (sender as SfDataGrid).SelectionController.CurrentCellManager.CurrentRowColumnIndex.RowIndex;
                            var rowData = GridConfig.GetRecordAtRowIndex(columnIndex);
                                                        

                            reflector.SetValue(rowData, "cod_ref", func.Item2.Rows[0]["cod_ref"].ToString().Trim());

                            if (DBNull.Value.Equals(reflector.GetValue(rowData, "can_rec")))
                                reflector.SetValue(rowData, "can_rec", 0);

                            if (DBNull.Value.Equals(reflector.GetValue(rowData, "cantidad")))
                                reflector.SetValue(rowData, "cantidad", 0);

                            if (DBNull.Value.Equals(reflector.GetValue(rowData, "cant_nr")))
                                reflector.SetValue(rowData, "cant_nr", 0);

                            reflector.SetValue(rowData, "obs", "Ninguna");

                            if (DBNull.Value.Equals(reflector.GetValue(rowData, "r_h")))
                                reflector.SetValue(rowData, "r_h", 0);
                            if (DBNull.Value.Equals(reflector.GetValue(rowData, "r_r")))
                                reflector.SetValue(rowData, "r_r", 0);
                            if (DBNull.Value.Equals(reflector.GetValue(rowData, "r_t")))
                                reflector.SetValue(rowData, "r_t", 0);
                            if (DBNull.Value.Equals(reflector.GetValue(rowData, "r_o")))
                                reflector.SetValue(rowData, "r_o", 0);                            

                            GridConfig.UpdateDataRow(columnIndex);
                            GridConfig.UpdateLayout();
                            GridConfig.Columns["cod_ref"].AllowEditing = true;
                            GridConfig.Columns["can_rec"].AllowEditing = true;
                            GridConfig.Columns["cantidad"].AllowEditing = true;
                            GridConfig.Columns["cant_nr"].AllowEditing = true;
                            GridConfig.Columns["obs"].AllowEditing = true;
                            GridConfig.Columns["r_h"].AllowEditing = true;
                            GridConfig.Columns["r_r"].AllowEditing = true;
                            GridConfig.Columns["r_t"].AllowEditing = true;
                            GridConfig.Columns["r_o"].AllowEditing = true;
                        }
                    }
                }
            }
            catch (Exception w)
            {
                SiaWin.Func.SiaExeptionGobal(w);
                MessageBox.Show("error en el producto f8:" + w);
            }
        }
Exemple #3
0
        private void GridConfig_CurrentCellEndEdit(object sender, Syncfusion.UI.Xaml.Grid.CurrentCellEndEditEventArgs e)
        {
            try
            {

                var reflector = this.GridConfig.View.GetPropertyAccessProvider();
                var rowData = GridConfig.GetRecordAtRowIndex(e.RowColumnIndex.RowIndex);
                string refer = reflector.GetValue(rowData, "cod_ref").ToString();
                var func = refe(refer);

                if (func.Item1)
                {

                    if (DBNull.Value.Equals(reflector.GetValue(rowData, "can_rec")))
                        reflector.SetValue(rowData, "can_rec", 0);

                    if (DBNull.Value.Equals(reflector.GetValue(rowData, "cantidad")))
                        reflector.SetValue(rowData, "cantidad", 0);

                    if (DBNull.Value.Equals(reflector.GetValue(rowData, "cant_nr")))
                        reflector.SetValue(rowData, "cant_nr", 0);

                    if (DBNull.Value.Equals(reflector.GetValue(rowData, "obs")))
                        reflector.SetValue(rowData, "obs", "Ninguna");

                    if (DBNull.Value.Equals(reflector.GetValue(rowData, "r_h")))
                        reflector.SetValue(rowData, "r_h", 0);
                    if (DBNull.Value.Equals(reflector.GetValue(rowData, "r_r")))
                        reflector.SetValue(rowData, "r_r", 0);
                    if (DBNull.Value.Equals(reflector.GetValue(rowData, "r_t")))
                        reflector.SetValue(rowData, "r_t", 0);
                    if (DBNull.Value.Equals(reflector.GetValue(rowData, "r_o")))
                        reflector.SetValue(rowData, "r_o", 0);


                    GridConfig.UpdateDataRow(e.RowColumnIndex.RowIndex);
                    GridConfig.UpdateLayout();
                    GridConfig.Columns["cod_ref"].AllowEditing = true;
                    GridConfig.Columns["can_rec"].AllowEditing = true;
                    GridConfig.Columns["cantidad"].AllowEditing = true;
                    GridConfig.Columns["cant_nr"].AllowEditing = true;
                    GridConfig.Columns["obs"].AllowEditing = true;
                    GridConfig.Columns["r_h"].AllowEditing = true;
                    GridConfig.Columns["r_r"].AllowEditing = true;
                    GridConfig.Columns["r_t"].AllowEditing = true;
                    GridConfig.Columns["r_o"].AllowEditing = true;
                }
                else
                {
                    reflector.SetValue(rowData, "cod_ref", "");
                    reflector.SetValue(rowData, "can_rec", 0);
                    reflector.SetValue(rowData, "cantidad", 0);
                    reflector.SetValue(rowData, "cant_nr", 0);
                    reflector.SetValue(rowData, "obs", "");
                    reflector.SetValue(rowData, "r_h", 0);
                    reflector.SetValue(rowData, "r_r", 0);
                    reflector.SetValue(rowData, "r_t", 0);
                    reflector.SetValue(rowData, "r_o", 0);

                    GridConfig.UpdateDataRow(e.RowColumnIndex.RowIndex);
                    GridConfig.UpdateLayout();
                    GridConfig.Columns["cod_ref"].AllowEditing = true;
                    GridConfig.Columns["can_rec"].AllowEditing = true;
                    GridConfig.Columns["cantidad"].AllowEditing = true;
                    GridConfig.Columns["cant_nr"].AllowEditing = true;
                    GridConfig.Columns["obs"].AllowEditing = true;
                    GridConfig.Columns["r_h"].AllowEditing = true;
                    GridConfig.Columns["r_r"].AllowEditing = true;
                    GridConfig.Columns["r_t"].AllowEditing = true;
                    GridConfig.Columns["r_o"].AllowEditing = true;
                }
            }
            catch (Exception w)
            {
                SiaWin.Func.SiaExeptionGobal(w);
                MessageBox.Show("error al editar:" + w);
            }
        }
        private void GridConfig_CurrentCellActivated(object sender, CurrentCellActivatedEventArgs e)
        {
            try
            {
                bool t = this.GridConfig.View.IsAddingNew;

                if (!t)
                {
                    if ((e.CurrentRowColumnIndex.RowIndex) > GridConfig.View.Records.Count)
                    {
                        if (e.CurrentRowColumnIndex.ColumnIndex > 0)
                        {
                            this.GridConfig.SelectionController.CurrentCellManager.BeginEdit();
                        }
                    }
                    else
                    {
                        GridConfig.UpdateLayout();
                        var    reflector   = this.GridConfig.View.GetPropertyAccessProvider();
                        int    columnIndex = (sender as SfDataGrid).SelectionController.CurrentCellManager.CurrentRowColumnIndex.RowIndex;
                        var    rowData     = GridConfig.GetRecordAtRowIndex(columnIndex);
                        string refe        = reflector.GetValue(rowData, "cod_ref").ToString().Trim();

                        if (string.IsNullOrEmpty(refe))
                        {
                            this.GridConfig.SelectionController.CurrentCellManager.BeginEdit();
                        }
                    }
                }

                if (Keyboard.IsKeyDown(Key.Tab) || Keyboard.IsKeyDown(Key.Right) || Keyboard.IsKeyDown(Key.Return))
                {
                    var reflector   = this.GridConfig.View.GetPropertyAccessProvider();
                    int columnIndex = (sender as SfDataGrid).SelectionController.CurrentCellManager.CurrentRowColumnIndex.RowIndex;
                    var rowData     = GridConfig.GetRecordAtRowIndex(columnIndex);
                    if (DBNull.Value.Equals(reflector.GetValue(rowData, "cod_ref")))
                    {
                        dynamic ww = SiaWin.WindowExt(9326, "InBuscarReferencia");  //carga desde sql
                        ww.Conexion              = SiaWin.Func.DatosEmp(idemp);
                        ww.idEmp                 = idemp;
                        ww.idBod                 = tx_bodega.Text;
                        ww.UltBusqueda           = "";
                        ww.ShowInTaskbar         = false;
                        ww.Owner                 = Application.Current.MainWindow;
                        ww.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                        ww.Height                = 400;
                        ww.ShowDialog();
                        string code = ww.Codigo;

                        if (string.IsNullOrEmpty(code))
                        {
                            return;
                        }

                        var func = refe(code);
                        reflector.SetValue(rowData, "cod_ref", func.Item2.Rows[0]["cod_ref"].ToString().Trim());
                        reflector.SetValue(rowData, "nom_ref", func.Item2.Rows[0]["nom_ref"].ToString().Trim());
                        double getCant = 1;
                        if (DBNull.Value.Equals(reflector.GetValue(rowData, "cantidad")))
                        {
                            reflector.SetValue(rowData, "cantidad", 1);
                        }

                        double saldoin = Convert.ToDouble(SiaWin.Func.SaldoInv(func.Item2.Rows[0]["cod_ref"].ToString().Trim(), tx_bodega.Text, cod_empresa));
                        reflector.SetValue(rowData, "saldo", saldoin);
                        double fal = saldoin - getCant;
                        reflector.SetValue(rowData, "faltantes", fal >= 0 ? 0 : fal);
                        reflector.SetValue(rowData, "val_ref", Convert.ToDouble(func.Item2.Rows[0]["val_ref"].ToString()));
                        double sub = Convert.ToDouble(func.Item2.Rows[0]["val_ref"]) * getCant;
                        reflector.SetValue(rowData, "subtotal", sub);


                        GridConfig.UpdateDataRow(columnIndex);
                        GridConfig.UpdateLayout();
                        GridConfig.Columns["cod_ref"].AllowEditing = true;
                    }

                    else
                    {
                        string referen = reflector.GetValue(rowData, "cod_ref").ToString().Trim();

                        if (string.IsNullOrEmpty(referen))
                        {
                            dynamic ww = SiaWin.WindowExt(9326, "InBuscarReferencia");  //carga desde sql
                            ww.Conexion              = SiaWin.Func.DatosEmp(idemp);
                            ww.idEmp                 = idemp;
                            ww.idBod                 = tx_bodega.Text;
                            ww.UltBusqueda           = "";
                            ww.ShowInTaskbar         = false;
                            ww.Owner                 = Application.Current.MainWindow;
                            ww.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                            ww.Height                = 400;
                            ww.ShowDialog();
                            string code = ww.Codigo;

                            if (string.IsNullOrEmpty(code))
                            {
                                return;
                            }

                            var func = refe(code);

                            reflector.SetValue(rowData, "cod_ref", func.Item2.Rows[0]["cod_ref"].ToString().Trim());
                            reflector.SetValue(rowData, "nom_ref", func.Item2.Rows[0]["nom_ref"].ToString().Trim());
                            double getCant = 1;
                            if (DBNull.Value.Equals(reflector.GetValue(rowData, "cantidad")))
                            {
                                reflector.SetValue(rowData, "cantidad", 1);
                            }

                            double saldoin = Convert.ToDouble(SiaWin.Func.SaldoInv(func.Item2.Rows[0]["cod_ref"].ToString().Trim(), tx_bodega.Text, cod_empresa));
                            reflector.SetValue(rowData, "saldo", saldoin);
                            double fal = saldoin - getCant;
                            reflector.SetValue(rowData, "faltantes", fal >= 0 ? 0 : fal);
                            reflector.SetValue(rowData, "val_ref", Convert.ToDouble(func.Item2.Rows[0]["val_ref"].ToString()));
                            double sub = Convert.ToDouble(func.Item2.Rows[0]["val_ref"]) * getCant;
                            reflector.SetValue(rowData, "subtotal", sub);

                            GridConfig.UpdateDataRow(columnIndex);
                            GridConfig.UpdateLayout();
                            GridConfig.Columns["cod_ref"].AllowEditing = true;
                        }
                    }
                }
            }
            catch (Exception w)
            {
                SiaWin.Func.SiaExeptionGobal(w);
                MessageBox.Show("QQQ:" + w);
            }
        }
        private void GridConfig_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                GridColumn Colum = ((SfDataGrid)sender).CurrentColumn as GridColumn;

                if (Colum.MappingName == "cod_ref")
                {
                    if ((e.Key == Key.Enter || e.Key == Key.F8))
                    {
                        if (GridConfig.SelectedIndex == -1)
                        {
                            this.GridConfig.SelectionController.CurrentCellManager.BeginEdit();
                        }

                        dynamic ww = SiaWin.WindowExt(9326, "InBuscarReferencia");  //carga desde sql
                        ww.Conexion              = SiaWin.Func.DatosEmp(idemp);
                        ww.idEmp                 = idemp;
                        ww.idBod                 = tx_bodega.Text;
                        ww.UltBusqueda           = "";
                        ww.ShowInTaskbar         = false;
                        ww.Owner                 = Application.Current.MainWindow;
                        ww.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                        ww.Height                = 400;
                        ww.ShowDialog();

                        string code = ww.Codigo;

                        if (!string.IsNullOrEmpty(code))
                        {
                            var func = refe(code);
                            if (func.Item1)
                            {
                                var reflector   = this.GridConfig.View.GetPropertyAccessProvider();
                                int columnIndex = (sender as SfDataGrid).SelectionController.CurrentCellManager.CurrentRowColumnIndex.RowIndex;
                                var rowData     = GridConfig.GetRecordAtRowIndex(columnIndex);


                                reflector.SetValue(rowData, "cod_ref", func.Item2.Rows[0]["cod_ref"].ToString().Trim());
                                reflector.SetValue(rowData, "nom_ref", func.Item2.Rows[0]["nom_ref"].ToString().Trim());
                                double getCant = 1;
                                if (DBNull.Value.Equals(reflector.GetValue(rowData, "cantidad")))
                                {
                                    reflector.SetValue(rowData, "cantidad", 1);
                                }
                                getCant = Convert.ToDouble(reflector.GetValue(rowData, "cantidad"));
                                double saldoin = Convert.ToDouble(SiaWin.Func.SaldoInv(func.Item2.Rows[0]["cod_ref"].ToString().Trim(), tx_bodega.Text, cod_empresa));
                                reflector.SetValue(rowData, "saldo", saldoin);
                                double fal = saldoin - getCant;
                                reflector.SetValue(rowData, "faltantes", fal >= 0 ? 0 : fal);
                                reflector.SetValue(rowData, "val_ref", Convert.ToDouble(func.Item2.Rows[0]["val_ref"].ToString()));
                                double sub = Convert.ToDouble(func.Item2.Rows[0]["val_ref"]) * getCant;
                                reflector.SetValue(rowData, "subtotal", sub);

                                GridConfig.UpdateDataRow(columnIndex);
                                GridConfig.UpdateLayout();
                                GridConfig.Columns["cod_ref"].AllowEditing = true;

                                updateTot();
                            }
                        }
                    }
                }
            }
            catch (Exception w)
            {
                SiaWin.Func.SiaExeptionGobal(w);
                MessageBox.Show("error en el producto f8:" + w);
            }
        }
        private void GridConfig_CurrentCellEndEdit(object sender, Syncfusion.UI.Xaml.Grid.CurrentCellEndEditEventArgs e)
        {
            try
            {
                var reflector = this.GridConfig.View.GetPropertyAccessProvider();

                //if (GridConfig.View.IsCurrentBeforeFirst == true)return;

                if (Keyboard.IsKeyDown(Key.Up))
                {
                    return;
                }



                if (Keyboard.IsKeyDown(Key.Right) || Keyboard.IsKeyDown(Key.Tab) || Keyboard.IsKeyDown(Key.Return) || Keyboard.IsKeyDown(Key.Enter))
                {
                    if (GridConfig.View.IsCurrentBeforeFirst == true)
                    {
                        return;
                    }
                }



                var rowData = GridConfig.GetRecordAtRowIndex(e.RowColumnIndex.RowIndex);
                if (DBNull.Value.Equals(reflector.GetValue(rowData, "cod_ref")))
                {
                    return;
                }

                string refer = reflector.GetValue(rowData, "cod_ref").ToString();


                var func = refe(refer);
                if (func.Item1)
                {
                    reflector.SetValue(rowData, "nom_ref", func.Item2.Rows[0]["nom_ref"].ToString().Trim()).ToString();
                    double getCant = 1;

                    if (DBNull.Value.Equals(reflector.GetValue(rowData, "cantidad")))
                    {
                        reflector.SetValue(rowData, "cantidad", 1);
                    }

                    getCant = Convert.ToDouble(reflector.GetValue(rowData, "cantidad"));
                    //if (getCant ==0) reflector.SetValue(rowData, "cantidad", 1);
                    double saldoin = Convert.ToDouble(SiaWin.Func.SaldoInv(func.Item2.Rows[0]["cod_ref"].ToString().Trim(), tx_bodega.Text, cod_empresa));
                    reflector.SetValue(rowData, "saldo", saldoin);
                    double fal = saldoin - getCant;
                    reflector.SetValue(rowData, "faltantes", fal >= 0 ? 0 : fal);
                    reflector.SetValue(rowData, "val_ref", Convert.ToDouble(func.Item2.Rows[0]["val_ref"].ToString()));
                    double sub = Convert.ToDouble(func.Item2.Rows[0]["val_ref"]) * getCant;
                    reflector.SetValue(rowData, "subtotal", sub);
                    GridConfig.UpdateDataRow(e.RowColumnIndex.RowIndex);
                    GridConfig.UpdateLayout();
                    GridConfig.Columns["nom_ref"].AllowEditing   = false;
                    GridConfig.Columns["cantidad"].AllowEditing  = true;
                    GridConfig.Columns["saldo"].AllowEditing     = false;
                    GridConfig.Columns["faltantes"].AllowEditing = false;
                    GridConfig.Columns["val_ref"].AllowEditing   = false;
                    GridConfig.Columns["subtotal"].AllowEditing  = false;
                    updateTot();
                    return;
                }
                else
                {
                    reflector.SetValue(rowData, "cod_ref", "");
                    reflector.SetValue(rowData, "nom_ref", "");
                    reflector.SetValue(rowData, "cantidad", 0);
                    reflector.SetValue(rowData, "saldo", 0);
                    reflector.SetValue(rowData, "faltantes", 0);
                    reflector.SetValue(rowData, "subtotal", 0);

                    GridConfig.UpdateDataRow(e.RowColumnIndex.RowIndex);
                    GridConfig.UpdateLayout();
                    GridConfig.Columns["nom_ref"].AllowEditing   = false;
                    GridConfig.Columns["cantidad"].AllowEditing  = true;
                    GridConfig.Columns["saldo"].AllowEditing     = false;
                    GridConfig.Columns["faltantes"].AllowEditing = false;
                    GridConfig.Columns["val_ref"].AllowEditing   = false;
                    GridConfig.Columns["subtotal"].AllowEditing  = false;
                    updateTot();
                    return;
                }
            }
            catch (Exception w)
            {
                SiaWin.Func.SiaExeptionGobal(w);
                MessageBox.Show("error al editar:" + w);
            }
        }