//for pagar column void repositoryItemCheckEdit2_CheckedChanged(object sender, EventArgs e) { DataRow r = gridViewReservas.GetDataRow(gridViewReservas.FocusedRowHandle); DevExpress.XtraEditors.CheckEdit chBtn = (sender as DevExpress.XtraEditors.CheckEdit); if (chBtn.Checked) { formReservasPagar = new Form(); PnlVentas ventas = new PnlVentas(); // ventas.InitializeDataTable(); CommonUtils.Cliente cliente = new CommonUtils.Cliente(int.Parse(r[10].ToString()), r[6].ToString(), r[8].ToString(), r[9].ToString(), r[7].ToString(), int.Parse(r[12].ToString())); ventas.Cliente = cliente; ventas.StartButtonsReserva(new string[] { r[8].ToString(), r[7].ToString(), r[3].ToString(), r[5].ToString() }); chBtn.Checked = false; ventas.PedidoId = r[0].ToString(); ventas.ReservasPanel = this; ventas.Chbtn = chBtn; ventas.LlamadoDePnlReservas = true; formReservasPagar.Size = new Size(1046, 738); getPedidosDescripcion(r[0].ToString(), ventas); ventas.Dock = DockStyle.Fill; formReservasPagar.Controls.Add(ventas); formReservasPagar.MaximizeBox = false; formReservasPagar.Text = "Pagar reserva"; formReservasPagar.ShowDialog(); formReservasPagar.Refresh(); } // chBtn.Checked = false; }
public CalculadoraVentas(CommonUtils.ActualizarGrids IUpdateGrids, DataTable table, Form parentForm, double totalDinero, bool reserva, bool sePago, CommonUtils.Cliente _client) { InitializeComponent(); InitializePrintSettings( ); dbLog = new CommonUtils.DataBaseLog(); log4net.Config.XmlConfigurator.Configure( ); dataTable = table; total = totalDinero; txtCuenta.Text = total.ToString(); txtTotal.Text = total.ToString(); pagado = sePago; esReserva = reserva; cliente = _client; // ventasPanel = ventasPnl; UpdateGrids = IUpdateGrids; InitConexionDB(); if (parentForm != null) { Left = parentForm.Left + (parentForm.Width - Width) / 2; Top = parentForm.Top + (parentForm.Height - Height) / 2; } }
private void registrarReserva(CommonUtils.Cliente cliente1) { string entregado = "False"; string tipoPedido = "Reserva"; string pagado = "False"; string fechaEntrega = dateEditFechaEntrega.DateTime.ToString(); double total = double.Parse(columnTotal.SummaryItem.SummaryValue.ToString()); this.manageClient(cliente1); string sqlQuery = "Insert into Pedido(FechaPedidoText,FechaEntregaText,Descuento,TipoPedido,Pagado,FechaEntrega,Entregado,ClienteId,TotalVenta,FechaPedido,NombreCliente,Direccion,Telefono,NIT,NumeroPedido) values('" + DateTime.Now.ToString("yyyy-MM-dd H:mm:ss.fff") + "','" + dateEditFechaEntrega.DateTime.ToString("yyyy-MM-dd H:mm:ss.fff") + "','" + 0 + "','" + tipoPedido + "','" + pagado + "','" + fechaEntrega + "','" + entregado + "','" + cliente1.IdCliente + "','" + total + "','" + DateTime.Now + "','" + cliente1.Nombre + "','" + cliente1.Direccion + "','" + cliente1.Telefono + "','" + cliente1.NIT + "','" + cliente1.NumeroPedido + "')"; decimal idPedido = CommonUtils.ConexionBD.ActualizarRetornandoId(sqlQuery); List <DataRow> listaPedidos = dataTable.AsEnumerable().ToList(); foreach (DataRow item in listaPedidos) { string costoReceta = CalculadoraVentas.obtenerCostoReceta(item); //this.obtenerCostoReceta(item); sqlQuery = "insert into Pedido_Producto(PedidoId,ProductoId,Cantidad,Total,CostoReceta,PrecioProducto,Descripcion) values('" + idPedido + "','" + item["Id"] + "','" + item["Cantidad"] + "','" + item["Subtotal"] + "','" + costoReceta + "','" + item["Precio"] + "','" + item["Descripcion"] + "')"; CommonUtils.ConexionBD.Actualizar(sqlQuery); } }
private void manageClient(CommonUtils.Cliente newCliente) { //string sql = "SELECT ClienteId from Cliente where NIT='" + cliente.NIT + "'"; Int64 clienteNitTemp = 0; Int64.TryParse(newCliente.NIT, out clienteNitTemp); if (clienteNitTemp == 0) { newCliente.IdCliente = -1; newCliente.NIT = clienteNitTemp.ToString(); return; } string sql = "SELECT ClienteId from Cliente where NIT='" + newCliente.NIT + "'"; CommonUtils.ConexionBD.AbrirConexion(); SqlDataReader reader = CommonUtils.ConexionBD.EjecutarConsultaReader(sql); int numberOfElements = 0; int idClient = 0; while (reader.Read()) { numberOfElements++; idClient = (int)reader.GetDecimal(0); } CommonUtils.ConexionBD.CerrarConexion(); if (numberOfElements == 0) { sql = "INSERT INTO Cliente (Nombre,NIT,Telefono,Direccion) VALUES (N'" + newCliente.Nombre + "','" + newCliente.NIT + "','" + CommonUtils.StringUtils.EscapeSQL(newCliente.Telefono) + "','" + CommonUtils.StringUtils.EscapeSQL(newCliente.Direccion) + "')"; // CommonUtils.ConexionBD.Actualizar(sql); decimal value = CommonUtils.ConexionBD.ActualizarRetornandoId(sql); newCliente.IdCliente = (int)value; } else//there is a client with that nit, { sql = "UPDATE Cliente set Nombre='" + newCliente.Nombre + "' where clienteId='" + idClient + "'"; CommonUtils.ConexionBD.Actualizar(sql); newCliente.IdCliente = idClient; } }
/* private void View_CellValueChanging( object sender , DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e ) * { * DataRow row=gridViewItems.GetFocusedDataRow(); * if (e.Column.Caption != "Descripcion") * { * if (Convert.ToDecimal(e.Value) < 1) * { * this.gridViewItems.SetRowCellValue(e.RowHandle, this.gridViewItems.Columns[1].FieldName, CANTIDAD_MINIMA); * return; * } * * double subTotal = Convert.ToDouble(e.Value) * Convert.ToDouble(row[3].ToString());// gridProducto.ventas.Precio; * this.gridViewItems.SetRowCellValue(e.RowHandle, this.gridViewItems.Columns[3].FieldName, subTotal); * * gridViewItems.UpdateTotalSummary(); * } * } */ private void btnVenta_Click(object sender, EventArgs e) { this.calcularNumeroPedido(); // string sql = "INSERT INTO Cliente (Nombre,NIT,Telefono,Direccion) VALUES ('" + // mruCliente.Text + "','" + mruNIT.Text + "','" +CommonUtils.StringUtils.EscapeSQL( txtTelefono.Text) + "','" +CommonUtils.StringUtils.EscapeSQL( txtDireccion.Text) + "')"; // CommonUtils.ConexionBD.Actualizar( sql ); if (dataTable.Rows.Count == 0) { //no hay nada para vender return; } else if (llamadoDePnlReservas) { CalculadoraVentas calculadora = new CalculadoraVentas(reservasPanel, dataTable, this.ParentForm, float.Parse(columnTotal.SummaryItem.SummaryValue.ToString()), true, false, cliente); calculadora.PedidoId = pedidoId; calculadora.Ventas = reservasPanel.FormReservasPagar; calculadora.checkBtn = this.chbtn; calculadora.ShowDialog(); calculadora.Refresh(); } else if (txtTipoPedido.SelectedItem.ToString() == "Inmediato") { CommonUtils.Cliente cliente = new CommonUtils.Cliente(0, /*mruCliente.Text*/ txtCliente.Text, txtTelefono.Text, txtNIT.Text, txtDireccion.Text, int.Parse(txtNumPedido.Text)); CalculadoraVentas calculadora = new CalculadoraVentas(this, dataTable, this.ParentForm, double.Parse(columnTotal.SummaryItem.SummaryValue.ToString()), false, true, cliente); calculadora.ShowDialog(); calculadora.Refresh(); } else if (txtEstadoPedido.SelectedItem.ToString() == "Pagado" && txtTipoPedido.SelectedItem.ToString() == "Reserva")//mostramos calculadora { if (!dxErrorProvider.HasErrors) { CommonUtils.Cliente cliente = new CommonUtils.Cliente(0, txtCliente.Text, txtTelefono.Text, txtNIT.Text, txtDireccion.Text, int.Parse(txtNumPedido.Text)); CalculadoraVentas calculadora = new CalculadoraVentas(this, dataTable, this.ParentForm, float.Parse(columnTotal.SummaryItem.SummaryValue.ToString()), true, true, cliente); calculadora.FechaEntrega = dateEditFechaEntrega.DateTime.ToString("yyyy-MM-dd H:mm:ss.fff"); calculadora.FechaEntregaNoFormat = dateEditFechaEntrega.DateTime.ToString( ); calculadora.ShowDialog(); calculadora.Refresh(); } else { this.GetErrorProviderMessages(); } } else //hacemos reserva directamente. { if (!dxErrorProvider.HasErrors) { try { CommonUtils.Cliente client = new CommonUtils.Cliente(0, txtCliente.Text, txtTelefono.Text, txtNIT.Text, txtDireccion.Text, int.Parse(txtNumPedido.Text)); this.registrarReserva(client); this.ResetFields(); MessageBarValue = "La reserva fue creada satisfactoriamente."; // MessageBox.Show(this, "Reserva Realizada correctamente", "Reserva ", MessageBoxButtons.OK); } catch (Exception ex) { log.Error(ex.Message, ex); MessageBarValue = "No se pudo registrar reserva sin pagar. Hubo un error: " + ex.Message; } finally { alertControlPnlVentas.Show(this.FindForm(), "Reserva.", MessageBarValue, Image); } } else { this.GetErrorProviderMessages(); } } }
public CalculadoraVentas(CommonUtils.ActualizarGrids IUpdateGrids,DataTable table,Form parentForm,double totalDinero,bool reserva,bool sePago,CommonUtils.Cliente _client) { InitializeComponent(); InitializePrintSettings( ); dbLog = new CommonUtils.DataBaseLog(); log4net.Config.XmlConfigurator.Configure( ); dataTable = table; total = totalDinero; txtCuenta.Text = total.ToString(); txtTotal.Text = total.ToString(); pagado = sePago; esReserva = reserva; cliente = _client; // ventasPanel = ventasPnl; UpdateGrids = IUpdateGrids; InitConexionDB(); if (parentForm != null) { Left = parentForm.Left + (parentForm.Width - Width) / 2; Top = parentForm.Top + (parentForm.Height - Height) / 2; } }
//for pagar column void repositoryItemCheckEdit2_CheckedChanged(object sender, EventArgs e) { DataRow r = gridViewReservas.GetDataRow(gridViewReservas.FocusedRowHandle); DevExpress.XtraEditors.CheckEdit chBtn = (sender as DevExpress.XtraEditors.CheckEdit); if (chBtn.Checked) { formReservasPagar = new Form(); PnlVentas ventas = new PnlVentas(); // ventas.InitializeDataTable(); CommonUtils.Cliente cliente = new CommonUtils.Cliente(int.Parse(r[10].ToString()), r[6].ToString(), r[8].ToString(), r[9].ToString(), r[7].ToString(), int.Parse(r[12].ToString())); ventas.Cliente = cliente; ventas.StartButtonsReserva(new string[] { r[8].ToString(), r[7].ToString(), r[3].ToString(), r[5].ToString() }); chBtn.Checked = false; ventas.PedidoId = r[0].ToString(); ventas.ReservasPanel = this; ventas.Chbtn = chBtn; ventas.LlamadoDePnlReservas = true; formReservasPagar.Size=new Size(1046, 738); getPedidosDescripcion(r[0].ToString(),ventas); ventas.Dock = DockStyle.Fill; formReservasPagar.Controls.Add(ventas); formReservasPagar.MaximizeBox = false; formReservasPagar.Text = "Pagar reserva"; formReservasPagar.ShowDialog(); formReservasPagar.Refresh(); } // chBtn.Checked = false; }
/* private void View_CellValueChanging( object sender , DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e ) { DataRow row=gridViewItems.GetFocusedDataRow(); if (e.Column.Caption != "Descripcion") { if (Convert.ToDecimal(e.Value) < 1) { this.gridViewItems.SetRowCellValue(e.RowHandle, this.gridViewItems.Columns[1].FieldName, CANTIDAD_MINIMA); return; } double subTotal = Convert.ToDouble(e.Value) * Convert.ToDouble(row[3].ToString());// gridProducto.ventas.Precio; this.gridViewItems.SetRowCellValue(e.RowHandle, this.gridViewItems.Columns[3].FieldName, subTotal); gridViewItems.UpdateTotalSummary(); } } */ private void btnVenta_Click( object sender , EventArgs e ) { this.calcularNumeroPedido(); // string sql = "INSERT INTO Cliente (Nombre,NIT,Telefono,Direccion) VALUES ('" + // mruCliente.Text + "','" + mruNIT.Text + "','" +CommonUtils.StringUtils.EscapeSQL( txtTelefono.Text) + "','" +CommonUtils.StringUtils.EscapeSQL( txtDireccion.Text) + "')"; // CommonUtils.ConexionBD.Actualizar( sql ); if (dataTable.Rows.Count == 0) { //no hay nada para vender return; } else if (llamadoDePnlReservas) { CalculadoraVentas calculadora = new CalculadoraVentas(reservasPanel, dataTable, this.ParentForm, float.Parse(columnTotal.SummaryItem.SummaryValue.ToString()), true, false, cliente); calculadora.PedidoId = pedidoId; calculadora.Ventas = reservasPanel.FormReservasPagar; calculadora.checkBtn = this.chbtn; calculadora.ShowDialog(); calculadora.Refresh(); } else if (txtTipoPedido.SelectedItem.ToString() == "Inmediato") { CommonUtils.Cliente cliente = new CommonUtils.Cliente(0, /*mruCliente.Text*/txtCliente.Text, txtTelefono.Text, txtNIT.Text, txtDireccion.Text,int.Parse(txtNumPedido.Text)); CalculadoraVentas calculadora = new CalculadoraVentas(this, dataTable, this.ParentForm, double.Parse(columnTotal.SummaryItem.SummaryValue.ToString()) , false, true, cliente); calculadora.ShowDialog(); calculadora.Refresh(); } else if (txtEstadoPedido.SelectedItem.ToString() == "Pagado" && txtTipoPedido.SelectedItem.ToString() == "Reserva")//mostramos calculadora { if (!dxErrorProvider.HasErrors) { CommonUtils.Cliente cliente = new CommonUtils.Cliente(0, txtCliente.Text, txtTelefono.Text, txtNIT.Text, txtDireccion.Text,int.Parse(txtNumPedido.Text)); CalculadoraVentas calculadora = new CalculadoraVentas(this, dataTable, this.ParentForm, float.Parse(columnTotal.SummaryItem.SummaryValue.ToString()), true, true, cliente); calculadora.FechaEntrega = dateEditFechaEntrega.DateTime.ToString("yyyy-MM-dd H:mm:ss.fff"); calculadora.FechaEntregaNoFormat = dateEditFechaEntrega.DateTime.ToString( ); calculadora.ShowDialog(); calculadora.Refresh(); } else { this.GetErrorProviderMessages(); } } else //hacemos reserva directamente. { if (!dxErrorProvider.HasErrors) { try { CommonUtils.Cliente client = new CommonUtils.Cliente(0, txtCliente.Text, txtTelefono.Text, txtNIT.Text, txtDireccion.Text, int.Parse(txtNumPedido.Text)); this.registrarReserva(client); this.ResetFields(); MessageBarValue="La reserva fue creada satisfactoriamente."; // MessageBox.Show(this, "Reserva Realizada correctamente", "Reserva ", MessageBoxButtons.OK); } catch (Exception ex) { log.Error(ex.Message, ex); MessageBarValue = "No se pudo registrar reserva sin pagar. Hubo un error: " + ex.Message; } finally { alertControlPnlVentas.Show(this.FindForm(), "Reserva.", MessageBarValue, Image); } } else { this.GetErrorProviderMessages(); } } }