コード例 #1
0
        private Int32 DetalleVenta(string NoVenta)
        {
            Decimal TotalIVA = 0.0m;
            string  str      = "";
            int     cont     = 0;

            for (int i = 0; i < grvVenta.Rows.Count; i++)
            {
                decimal IVA;
                if (Convert.ToBoolean(grvVenta.Rows[i].Cells["IVA"].Value))
                {
                    IVA = Convert.ToDecimal(grvVenta.Rows[i].Cells["IVA"].Value);
                }
                else
                {
                    IVA = 0.0m;
                }
                TotalIVA += IVA;
                string cod = ConexionSQL.ConsultaUnica(string.Format("Select isnull(max(Cod),0)+1 from DetalleVenta where Venta={0}", NoVenta));
                str = string.Format(@"Insert into DetalleVenta(Cod,Venta,Producto,Descripcion,Cantidad,Precio,IVA,Descuento,Fecha,Estado) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',default,1)", cod, NoVenta, grvVenta.Rows[i].Cells["NoSeq"].Value, grvVenta.Rows[i].Cells["Descripcion"].Value, grvVenta.Rows[i].Cells["Cantidad"].Value, grvVenta.Rows[i].Cells["Precio"].Value, grvVenta.Rows[i].Cells["IVA"].Value, grvVenta.Rows[i].Cells["Descuento"].Value);
                try
                {
                    if (ConexionSQL.DML(str) > 0)
                    {
                        cont++;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            return(cont);
        }
コード例 #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         string NoSeq    = ConexionSQL.ConsultaUnica("Select isnull(max(Cod),0)+1 from Compra");
         string osql     = string.Format("set dateformat dmy;insert into Compra values ({0},'{1}','{2}','{3}','{4}','{5}','{6}',{7});", NoSeq, dtpFecha.Value.ToString("dd/MM/yyyy"), dtpVencimiento.Value.ToString("dd/MM/yyyy"), txtNumFact.Text, txtSubTotal.Text, txtDesc.Text, txtIVA.Text, cboProveedor.SelectedValue);
         int    i        = ConexionSQL.DML(osql);
         int    qty      = dataGridView1.Rows.Count;
         int    contador = 0;
         if (i > 0)
         {
             foreach (DataGridViewRow dr in dataGridView1.Rows)
             {
                 string j = ConexionSQL.ConsultaUnica(string.Format("Select isnull(max(NoSeq),0)+1 from DetalleCompra where Compra={0}", NoSeq));
                 osql = string.Format("insert into DetalleCompra values ({0},{1},{2},{3},{4});", j, NoSeq, dr.Cells["NoSeq"].Value, dr.Cells["Cantidad"].Value, dr.Cells["Precio"].Value);
                 i    = ConexionSQL.DML(osql);
                 if (i > 0)
                 {
                     contador++;
                 }
             }
             if (contador == qty)
             {
                 MessageBox.Show("Compra procesada satisfactoriamente", "Registro de Compra", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #3
0
ファイル: Gasto.cs プロジェクト: luismbm89/SOZ-v3
        private void button1_Click(object sender, EventArgs e)
        {
            string NoSeq = ConexionSQL.ConsultaUnica("Select isnull(max(Cod),0)+1 from Gasto");

            if (ConexionSQL.DML(String.Format("insert into Gasto values ({0},default,'{1}','{2}','{3}','{4}',1,default)", NoSeq, textBox4.Text, textBox1.Text, textBox2.Text, textBox5.Text)) > 0)
            {
                CargarGastos();
            }
        }
コード例 #4
0
 private void btnVenta_Click(object sender, EventArgs e)
 {
     try
     {
         if (grvVenta.Rows.Count > 0 && txtCancela.Text.Length > 0 && (txtCancela.Text.Length) > 0)
         {
             string  osql      = "";
             decimal Descuento = Convert.ToDecimal(dtVenta.Compute("SUM(Descuento)", string.Empty));
             decimal IV        = Convert.ToDecimal(dtVenta.Compute("SUM(IVA)", string.Empty));
             decimal total     = Convert.ToDecimal(dtVenta.Compute("SUM(Total)", string.Empty));
             decimal SubTotal  = total - IV + Descuento;
             string  cod       = ConexionSQL.ConsultaUnica("Select isnull(max(Cod),0)+1 from Venta");
             bool    flag      = false;
             if (radioButton2.Checked && !string.IsNullOrEmpty(textBox2.Text) && !string.IsNullOrEmpty(txtCliente.Text))
             {
                 osql = string.Format("insert into Venta(Cod, Cliente, SubTotal,Descuento,IVA,TipoPago, Referencia) values({0}, '{1}', '{2}','{3}','{4}', '{5}', '{6}')", cod, txtCliente.Text, SubTotal, Descuento, IV, radioButton2.Text, textBox2.Text);
                 flag = true;
             }
             if (radioButton1.Checked && !string.IsNullOrEmpty(txtCliente.Text))
             {
                 osql = string.Format("insert into Venta(Cod,Cliente,SubTotal,Descuento,IVA,TipoPago) values ({0}, '{1}', '{2}','{3}','{4}', '{5}')", cod, txtCliente.Text, SubTotal, Descuento, IV, radioButton1.Text);
                 flag = true;
             }
             if (flag)
             {
                 int i = ConexionSQL.DML(osql);
                 if (i > 0)
                 {
                     if (DetalleVenta(cod) == grvVenta.Rows.Count)
                     {
                         MessageBox.Show("Venta realizada con exito", "Venta Exitosa", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         // PrintTicket(cod,false);
                         // PrintTicket(cod,true);
                         Prueba(cod);
                         Limpiar();
                     }
                 }
                 else
                 {
                     MessageBox.Show("Ha ocurrido un error", "Venta Fallida", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             else
             {
                 MessageBox.Show("Por favor valide todos los campos", "Información de Venta Incompleta", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             MessageBox.Show("No puede realizar una venta sin productos que facturar", "Venta Fallida", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Venta Fallida", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #5
0
ファイル: Frmsql.cs プロジェクト: luismbm89/SOZ-v3
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         int i = ConexionSQL.DML(textBox1.Text);
         textBox1.Text += string.Format(" Registros afectados ({0})", i);
     }
     catch (Exception ex) {
         textBox1.Text = string.Format("{0}", ex.Message);
     }
 }
コード例 #6
0
        private void btnCancelar_Click(object sender, EventArgs e)
        {
            /*  try
             * {
             *    if (txtApertura.Text.Length > 0)
             * {
             *    decimal Apertura = decimal.Parse(txtApertura.Text,
             * NumberStyles.AllowCurrencySymbol |
             * NumberStyles.AllowThousands |
             * NumberStyles.AllowDecimalPoint);
             *    decimal Cierre = decimal.Parse(txtCierre.Text,
             * NumberStyles.AllowCurrencySymbol |
             * NumberStyles.AllowThousands |
             * NumberStyles.AllowDecimalPoint);
             *    decimal Saldo = Cierre - Apertura;
             *    if (Saldo > 0)
             *    {
             *        MessageBox.Show(string.Format("{0:c}", Saldo), "Saldo positivo al cierre", MessageBoxButtons.OK, MessageBoxIcon.Information);
             *    }
             *    if (Saldo == 0)
             *    {
             *        MessageBox.Show(string.Format("{0:c}", Saldo), "Saldo neutro al cierre", MessageBoxButtons.OK, MessageBoxIcon.Stop);
             *    }
             *    if (Saldo < 0)
             *    {
             *        MessageBox.Show(string.Format("{0:c}", Saldo), "Saldo negativo al cierre", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             *    }
             *    int i = ConexionSQL.DML(String.Format("Update Caja  set FechaCierre=default, MontoCierre='{1}',Estado=1 where Convert(varchar,Fecha,103)='{0}' and NoSeq in (Select max(NoSeq) from Caja where Convert(varchar,Fecha,103)='{0}') and Estado=0", DateTime.Now.ToShortDateString(),txtCierre.Text));
             *    if (i > 0)
             *    {
             *        MessageBox.Show("Cierre efectuado con éxito", "Cierre de Caja", MessageBoxButtons.OK, MessageBoxIcon.Information);
             *            ImprimirCierre("1");
             *    }
             * }
             * }
             * catch (Exception ex)
             * {
             *    MessageBox.Show(ex.Message, "Error de Apertura", MessageBoxButtons.OK, MessageBoxIcon.Error);
             * }*/
            int i = ConexionSQL.DML(String.Format("Update caja set MontoCierre='{0}',FechaCierre=default,Estado=1 where NoSeq='{1}'", Cierre(), txtApertura.Tag));

            if (i > 0)
            {
                int j = ConexionSQL.DML("Update Venta set Estado=1 where Fecha<=getdate()");
                int k = ConexionSQL.DML("Update Gasto set Flag=1 where Fecha<=getdate()");
                MessageBox.Show("Cierre de Caja efectuado correctamente", "Cierre de caja", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ImprimirCierre(txtApertura.Tag.ToString());
            }
        }
コード例 #7
0
ファイル: Gasto.cs プロジェクト: luismbm89/SOZ-v3
 private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 4)
     {
         Boolean flag = Convert.ToBoolean(dataGridView1.Rows[e.RowIndex].Cells[4].Value);
         if (flag)
         {
             ConexionSQL.DML(string.Format("Update Gasto set Estado=0 where Cod='{0}'", dataGridView1.Rows[e.RowIndex].Cells[0].Value));
         }
         else
         {
             ConexionSQL.DML(string.Format("Update Gasto set Estado=1 where Cod='{0}'", dataGridView1.Rows[e.RowIndex].Cells[0].Value));
         }
         CargarGastos();
     }
 }
コード例 #8
0
ファイル: FrmProducto.cs プロジェクト: luismbm89/SOZ-v3
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     try
     {
         int flag       = Convert.ToInt32(ConexionSQL.ConsultaUnica(string.Format("Select Count(*) from Producto where NoSeq='{0}'", txtNoSeq.Text)));
         int IVA        = 0;
         int habilitado = 0;
         if (rdbConIVA.Checked)
         {
             IVA = 1;
         }
         if (rdbHabilitado.Checked)
         {
             habilitado = 1;
         }
         if (flag > 0)
         {
             int u = ConexionSQL.DML(string.Format("Update Producto set BarCode='{0}',Code='{1}',Descripcion='{2}',Categoria='{3}',Marca='{4}',IVA='{5}',Costo='{6}',PrecioVenta='{7}',Estado={9} where NoSeq='{8}'", txtBarCode.Text, txtCode.Text, txtDescripcion.Text, comboBox2.SelectedValue, comboBox1.SelectedValue, IVA, txtCosto.Text, txtPrecio.Text, txtNoSeq.Text, habilitado));
             if (u > 0)
             {
                 MessageBox.Show("Actualización efectuada correctamente", "Actualización", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 Limpiar();
             }
         }
         else
         {
             if (ConexionSQL.ConsultaUnica(String.Format("Select count(*) from Producto where BarCode='{0}'", txtBarCode.Text)).Equals("0"))
             {
                 int i = ConexionSQL.DML(string.Format("insert into Producto values ({0},'{1}','{2}','{3}',{4},{5},{6},'{7}','{8}',1)", txtNoSeq.Text, txtBarCode.Text, txtCode.Text, txtDescripcion.Text, comboBox1.SelectedValue, comboBox2.SelectedValue, IVA, txtCosto.Text, txtPrecio.Text));
                 if (i > 0)
                 {
                     MessageBox.Show("Registro efectuado correctamente", "Actualización", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     Limpiar();
                 }
             }
             else
             {
                 MessageBox.Show("El Codigo de Barras ya existe", "Codigo de barras duplicado", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 txtBarCode.Focus();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #9
0
ファイル: FrmProducto.cs プロジェクト: luismbm89/SOZ-v3
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         int i = ConexionSQL.DML(string.Format("Update Marca set Estado=0 where Cod='{0}'", comboBox1.SelectedValue));
         if (i > 0)
         {
             CargarMarcas();
             textBox1.Text = "";
             textBox1.Focus();
             comboBox1.Text = "";
         }
         else
         {
             textBox1.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #10
0
ファイル: FrmProducto.cs プロジェクト: luismbm89/SOZ-v3
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         int flag = Convert.ToInt32(ConexionSQL.ConsultaUnica(string.Format("Select Count(*) from Marca where Descripcion='{0}'", textBox1.Text)));
         if (flag == 1)
         {
             int i = ConexionSQL.DML(string.Format("Update Marca set Estado=1 where Descripcion='{0}'", textBox1.Text));
             if (i > 0)
             {
                 CargarMarcas();
                 textBox1.Text = "";
                 textBox1.Focus();
             }
             else
             {
                 textBox1.Focus();
             }
         }
         else if (flag == 0)
         {
             int i = ConexionSQL.DML(string.Format("Insert into Marca values ('{0}',1)", textBox1.Text));
             if (i > 0)
             {
                 CargarMarcas();
                 textBox1.Text = "";
                 textBox1.Focus();
             }
             else
             {
                 textBox1.Focus();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #11
0
        private void btnGuardarProv_Click(object sender, EventArgs e)
        {
            int    flag = Convert.ToInt32(ConexionSQL.ConsultaUnica(string.Format("Select count(*) from Proveedor where Cod='{0}'", txtCodigoPro.Text)));
            string osql = "";
            string mensaje = "", Titulo = "";

            if (flag == 0)
            {
                osql    = string.Format("insert into Proveedor values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}',1)", txtNombreProv.Text, txtContactoProv.Text, txtTelefonoProv.Text, txtCelProv.Text, txtDireccionProv.Text, txtEmailProv.Text, txtComentarioProv.Text);
                mensaje = "Registro insertado correctamente";
                Titulo  = "Inserción";
                tabControl1.SelectedIndex = 1;
                lblTotalProv.Text         = string.Format("Total de Registros: {0}", ConexionSQL.ConsultaUnica("Select count(*) from Proveedor"));
                txtCodigoPro.Text         = "1";
                Proveedor();
            }
            else
            {
                int est = 0;
                if (rdbHabPro.Checked)
                {
                    est = 1;
                }
                osql    = string.Format("Update Proveedor set Nombre='{0}',Contacto='{1}',Telefono='{2}',Celular='{3}',Direccion='{4}',Correo='{5}',Comentarios='{6}',Estado='{8}' where Cod={7}", txtNombreProv.Text, txtContactoProv.Text, txtTelefonoProv.Text, txtCelProv.Text, txtDireccionProv.Text, txtEmailProv.Text, txtComentarioProv.Text, txtCodigoPro.Tag, est);
                mensaje = "Registro actualizado correctamente";
                Titulo  = "Actualización";
            }
            int i = ConexionSQL.DML(osql);

            if (i > 0)
            {
                tabControl1.SelectedIndex = 1;
            }
            MessageBox.Show(mensaje, Titulo, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            lblTotalProv.Text = string.Format("Total de Registros: {0}", ConexionSQL.ConsultaUnica("Select count(*) from Proveedor"));
            txtCodigoPro.Text = "1";
            Proveedor();
        }
コード例 #12
0
 private void btnApertura_Click(object sender, EventArgs e)
 {
     try
     {
         string NoCa = ConexionSQL.ConsultaUnica("Select isnull(max(NoSeq),0)+1 NoSeq from Caja");
         int    i    = ConexionSQL.DML(string.Format("insert into Caja values({1},default,default,default,'{0}',default,0)", txtApertura.Text, NoCa));
         if (i > 0)
         {
             MessageBox.Show("Apertura realizada con éxito", "Apertura de Caja", MessageBoxButtons.OK, MessageBoxIcon.Information);
             decimal Apertura = decimal.Parse(txtApertura.Text,
                                              NumberStyles.AllowCurrencySymbol |
                                              NumberStyles.AllowThousands |
                                              NumberStyles.AllowDecimalPoint);
             txtApertura.Text    = String.Format("{0:c}", Apertura);
             txtApertura.Enabled = false;
             btnApertura.Visible = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error de Apertura", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #13
0
ファイル: FrmProducto.cs プロジェクト: luismbm89/SOZ-v3
 private void toolStripButton4_Click(object sender, EventArgs e)
 {
     try{
         int flag = Convert.ToInt32(ConexionSQL.ConsultaUnica(string.Format("Select Count(*) from Producto where NoSeq='{0}'", txtNoSeq.Text)));
         if (flag > 0)
         {
             int habilitado = 0;
             if (rdbHabilitado.Checked)
             {
                 habilitado = 1;
             }
             int u = ConexionSQL.DML(string.Format("Update Producto set Estado={1} where NoSeq='{0}'", txtNoSeq.Text, habilitado));
             if (u > 0)
             {
                 MessageBox.Show("Actualizaciön efectuada correctamente", "Actualización", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 Limpiar();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }