private void ButtonRemoveBudget_Click(object sender, RoutedEventArgs e)
        {
            if (BudgetsDataGrid.SelectedItem != null && BudgetsDataGrid.SelectedItem.ToString() != "{NewItemPlaceholder}")
            {
                if (MessageBox.Show("Do you want to remove this budget?", "", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No) == MessageBoxResult.Yes)
                {
                    selRow = BudgetsDataGrid.SelectedIndex;

                    clsPresupuestos obj = new clsPresupuestos()
                    {
                        Id_presupuesto = dt_presupuestos.Rows[selRow].Field <int>(0)
                    };

                    obj.BorrarPresupuesto();

                    dt_presupuestos = obj.CargarPresupuestos(index_proyecto);

                    dt_presupuestos.Columns[0].ColumnName = "BUDGET ID";
                    dt_presupuestos.Columns[1].ColumnName = "DESCRIPTION";
                    dt_presupuestos.Columns[2].ColumnName = "STATE";
                    dt_presupuestos.Columns[3].ColumnName = "PROJECT ID";

                    BudgetsDataGrid.ItemsSource = dt_presupuestos.DefaultView;
                }
            }
        }
        private void ProjectsDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            selRow = ProjectsDataGrid.SelectedIndex;

            if (selRow < dt_proyectos.Rows.Count && selRow != -1)
            {
                index_proyecto = dt_proyectos.Rows[selRow].Field <int>(0);

                clsPresupuestos obj = new clsPresupuestos();
                dt_presupuestos = obj.CargarPresupuestos(index_proyecto);

                dt_presupuestos.Columns[0].ColumnName = "BUDGET ID";
                dt_presupuestos.Columns[1].ColumnName = "DESCRIPTION";
                dt_presupuestos.Columns[2].ColumnName = "STATE";
                dt_presupuestos.Columns[3].ColumnName = "PROJECT ID";

                BudgetsDataGrid.ItemsSource = dt_presupuestos.DefaultView;
            }
            else
            {
                dt_presupuestos.Rows.Clear();
                dt_capitulos.Rows.Clear();
                dt_unitarios.Rows.Clear();
            }
        }
Exemple #3
0
        private void GuardarPresupuesto(clsPresupuestos pPresupuesto)
        {
            //INSERT A LA TABLA DE PEDIDOS
            string myCadena = "";

            try
            {
                //Alta de Articulos
                myCadena = "INSERT INTO Presupuestos (IdPresupuesto," +
                           " IdCliente," +
                           " IdFormaPago," +
                           " Punto," +
                           " Nro," +
                           " PuntoNro," +
                           " IdTransporte," +
                           " Fecha," +
                           " Comentario," +
                           " Dto," +
                           " Flete," +
                           " Activo," +
                           " Facturado," +
                           " Excel," +
                           " Pendiente," +
                           " Codigo_Correo" +
                           ") values (" + pPresupuesto.IdPresupuesto + ","
                           + pPresupuesto.IdCliente + ","
                           + pPresupuesto.IdFormaPago + ","
                           + pPresupuesto.Punto + ","
                           + pPresupuesto.Nro + ",'"
                           + pPresupuesto.PuntoNro + "',"
                           + pPresupuesto.IdTransporte + ",'"
                           + pPresupuesto.Fecha.ToShortDateString() + "','"
                           + pPresupuesto.Comentario + "',"
                           + pPresupuesto.Dto.ToString().Replace(",", ".") + ","
                           + pPresupuesto.Flete.ToString().Replace(",", ".") + ","
                           + pPresupuesto.Activo + ","
                           + pPresupuesto.Facturado + ","
                           + pPresupuesto.Excel + ","
                           + pPresupuesto.Pendiente + ",'"
                           + pPresupuesto.Codigo_Correo + "')";

                //GUARDAR EN PRESUPUESTOS
                clsDataBD.GetSql(myCadena);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.StackTrace, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Exemple #4
0
        private void ButtonSave_Click(object sender, RoutedEventArgs e)
        {
            if (edit)
            {
                if (description_TB.Text != "" && state_TB.Text != "")
                {
                    if (description_TB.Text == edit_presupuesto.Descripcion_presupuesto && state_TB.Text == edit_presupuesto.Estado_del_presupuesto)
                    {
                        MessageBox.Show("No changes have been made", "", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        if (MessageBox.Show("Do you want to save the changes?", "", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
                        {
                            edit_presupuesto.Descripcion_presupuesto = description_TB.Text;
                            edit_presupuesto.Estado_del_presupuesto  = state_TB.Text;

                            edit_presupuesto.ActualizarPresupuesto();
                            this.Close();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("You must complete all the data!", "", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
            else
            {
                if (description_TB.Text != "" && state_TB.Text != "")
                {
                    if (MessageBox.Show("Do you want to add this budget?", "", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
                    {
                        clsPresupuestos nuevo_presupuesto = new clsPresupuestos
                        {
                            Descripcion_presupuesto = description_TB.Text,
                            Estado_del_presupuesto  = state_TB.Text
                        };

                        nuevo_presupuesto.AgregarPresupuesto(index_proyecto);
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("You must complete all the data!", "", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
        }
        private void ButtonAddBudget_Click(object sender, RoutedEventArgs e)
        {
            if (ProjectsDataGrid.SelectedItem != null && ProjectsDataGrid.SelectedItem.ToString() != "{NewItemPlaceholder}")
            {
                this.edit = false;
                BudgetWindow budgetWindow = new BudgetWindow(edit, selRow, index_proyecto);
                budgetWindow.ShowDialog();

                clsPresupuestos obj = new clsPresupuestos();
                dt_presupuestos = obj.CargarPresupuestos(index_proyecto);

                dt_presupuestos.Columns[0].ColumnName = "BUDGET ID";
                dt_presupuestos.Columns[1].ColumnName = "DESCRIPTION";
                dt_presupuestos.Columns[2].ColumnName = "STATE";
                dt_presupuestos.Columns[3].ColumnName = "PROJECT ID";

                BudgetsDataGrid.ItemsSource = dt_presupuestos.DefaultView;
            }
        }
Exemple #6
0
        public BudgetWindow(bool ed, int selr, int id_p)
        {
            InitializeComponent();
            this.edit           = ed;
            this.selRow         = selr;
            this.index_proyecto = id_p;

            if (edit)
            {
                clsPresupuestos obj = new clsPresupuestos();
                dt = obj.CargarPresupuestos(index_proyecto);

                this.edit_presupuesto.Id_presupuesto          = dt.Rows[selRow].Field <int>(0);
                this.edit_presupuesto.Descripcion_presupuesto = dt.Rows[selRow].Field <string>(1);
                this.edit_presupuesto.Estado_del_presupuesto  = dt.Rows[selRow].Field <string>(2);

                description_TB.Text = edit_presupuesto.Descripcion_presupuesto;
                state_TB.Text       = edit_presupuesto.Estado_del_presupuesto;

                titleLabel.Content = "Edit budget";
            }
        }
Exemple #7
0
        private void btnPresu_Click(object sender, EventArgs e)
        {
            DataTable myDataPresu   = new DataTable();
            DataTable myDataDetalle = new DataTable();

            string PedNro   = dgvComprobantes.CurrentRow.Cells["Numero"].Value.ToString();
            string myCadena = "";

            //Timer
            TriggerTime.Stop();
            //CERRAR EL PRESUPUESTO ACTUAL
            DialogResult dlResult = MessageBox.Show("Desea CERRAR el PEDIDO N° " + PedNro + " ?. Esta acción < NO > se pude deshacer!", "Confirmar!!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            // Si confirma... cambiar estado
            if (dlResult == DialogResult.Yes)
            {
                //Pasar Pedido a Presupuestos //// ....
                myCadena    = "Select * from Pedidos Where IdPedido = " + IdPedido;
                myDataPresu = clsDataBD.GetSql(myCadena);

                //NUEVO OBJETO PRESUPUESTOS
                clsPresupuestos myPresu = new clsPresupuestos();

                //RECORRER GRILLA Y GUARDAR EN EL OBJETO
                foreach (DataRow filas in myDataPresu.Rows)
                {
                    /*Guardar en Matriz*/
                    myPresu.IdPresupuesto = clsDataBD.RetornarUltimoId("Presupuestos", "IdPresupuesto") + 1;
                    myPresu.IdCliente     = Convert.ToInt32(filas["IdCliente"].ToString());
                    myPresu.IdFormaPago   = Convert.ToInt32(filas["IdFormaPago"].ToString());
                    myPresu.Punto         = Convert.ToInt32(filas["Punto"].ToString());
                    // ** 29/05
                    // myPresu.Nro = clsDataBD.RetornarMax("Presupuestos","Nro")+1;
                    // **
                    myPresu.Nro = clsDataBD.getUltComp("Ult_Presupuesto", clsGlobales.cParametro.PtoVtaPorDefecto, 0) + 1;  //
                    // **
                    myPresu.PuntoNro      = myPresu.Punto.ToString("D4") + "-" + myPresu.Nro.ToString("D8");
                    myPresu.IdTransporte  = Convert.ToInt32(filas["IdTransporte"].ToString());
                    myPresu.Fecha         = DateTime.Now;
                    myPresu.Comentario    = filas["Comentario"].ToString();
                    myPresu.Dto           = Convert.ToDouble(filas["Dto"].ToString());
                    myPresu.Flete         = Convert.ToDouble(filas["Flete"].ToString());
                    myPresu.Facturado     = 0;
                    myPresu.Activo        = 1;
                    myPresu.Excel         = Convert.ToInt32(filas["Excel"].ToString());
                    myPresu.Pendiente     = 0;
                    myPresu.Codigo_Correo = "No establecido";
                }

                //Guardar el Presupuesto
                GuardarPresupuesto(myPresu);

                //Actualizar el numero de presupuesto en Tabla AFIP
                string mySQL = "UPDATE PuntosVentaAFIP SET Ult_Presupuesto = " + myPresu.Nro + " WHERE Punto = " + clsGlobales.cParametro.PtoVtaPorDefecto;
                clsDataBD.GetSql(mySQL);

                //GUARDAR EL DETALLE
                myCadena      = "Select * from Vista_Detalle_Pedido_ABM where IdPedido = " + IdPedido;
                myDataDetalle = clsDataBD.GetSql(myCadena);

                clsDetallePresupuestos myDetallePresupuesto = new clsDetallePresupuestos();

                foreach (DataRow filas in myDataDetalle.Rows)
                {
                    myDetallePresupuesto.IdDetPresupuesto = clsDataBD.RetornarUltimoId("DetallePresupuestos", "IdDetPresupuesto") + 1;
                    myDetallePresupuesto.IdPresupuesto    = myPresu.IdPresupuesto;
                    myDetallePresupuesto.IdArticulo       = Convert.ToInt32(filas["IdArticulo"].ToString());
                    myDetallePresupuesto.Codigo_Articulo  = filas["CodigoArticulo"].ToString();
                    myDetallePresupuesto.Cantidad         = Convert.ToInt32(filas["Cantidad"].ToString());
                    myDetallePresupuesto.Descripcion      = filas["Articulo"].ToString();
                    myDetallePresupuesto.PrecioUnitario   = Convert.ToDouble(filas["Precio"].ToString());
                    myDetallePresupuesto.Activo           = 1;
                    myDetallePresupuesto.Excel            = Convert.ToInt32(filas["Excel"].ToString());
                    myDetallePresupuesto.Orden            = Convert.ToInt32(filas["Orden"].ToString());

                    //GUARDAR DETALLE DEL PRESUPUESTO
                    GuardarDetallePresupuesto(myDetallePresupuesto);
                }

                //Quitar el PEDIDO
                myCadena = "DELETE FROM Pedidos WHERE IdPedido =" + IdPedido;
                clsDataBD.GetSql(myCadena);
                //Quitar el DETALLE
                myCadena = "DELETE FROM DetallePedidos WHERE IdPedido =" + IdPedido;
                clsDataBD.GetSql(myCadena);
                //Timer
                TriggerTime.Start();
                //Refrescar grilla
                this.CargarGrilla("", "");
                //Posicionar en grilla
                this.PosicionarFocoFila();
            }
        }