private void Form1_Load(object sender, EventArgs e)
        {
/*
 *          bd = new DataBase();
 *          bd.DataBaseProvider = TypeOfDataBase.MicrosoftSqlServer;
 *          bd.ConnectionString = "server=idea-PC; DataBase=DBI; User Id=sa; Password=1945sqlserver";
 *          bd.CreateConnection();
 *          DbObject.DefaultDataBaseObject = bd;
 */

            bdAccess = new DataBase();
            bdAccess.DataBaseProvider = TypeOfDataBase.MicrosoftAccess;
            bdAccess.ConnectionString = "Provider=Microsoft.jet.OLEDB.4.0;Data Source=" + Application.StartupPath + @"\descoBI.mdb;Jet OLEDB:Database Password=1945Inadescobi";
            bdAccess.CreateConnection();
            DbObject.DefaultDataBaseObject = bdAccess;

            dataGridView1.CellClick += new DataGridViewCellEventHandler(dataGridView1_CellClick);

            /*
             * String mac = "00:12:3F:43:98:52";
             * String mac2 = "";
             * String tarjeta = "Controladora Gigabit Broadcom NetXtreme 57xx";
             *
             * ManagementObjectSearcher mos = new ManagementObjectSearcher("select * from Win32_NetworkAdapter where Name='" + tarjeta + "'");
             * ManagementObjectCollection moc = mos.Get();
             * if (moc.Count > 0)
             * {
             *  foreach (ManagementObject mo in moc)
             *  {
             *      mac2 = (string)mo["MACAddress"];
             *      // MessageBox.Show(mac);
             *  }
             * }
             * else
             * {
             *  MessageBox.Show("Esta Aplicacion no coincide con el equipo, Favor de actualizarla");
             *  this.Close();
             * }
             *
             * if (mac != mac2)
             * {
             *  MessageBox.Show("Esta Aplicacion no coincide con el equipo, Favor de actualizarla");
             *  this.Close();
             * }
             */
        }
예제 #2
0
        private void buttonIngresarHoja_Click_1(object sender, EventArgs e)
        {
            #region validaciones
            if (FACTURA.Text != "")
            {
                try
                {
                    Convert.ToInt32(FACTURA.Text);
                }
                catch
                {
                    MessageBox.Show("Solo numeros en la factura");
                    return;
                }
            }
            if (checkBoxPorProyecto.Checked == true)
            {
                if (proyectoSeleccionado == null)
                {
                    MessageBox.Show("Falta elegir el proyecto");
                    return;
                }
            }
            else
            {
                if (FACTURA.Text == "" && txtpo.Text == "" && COTIZACION.Text == "" && REMISION.Text == "")
                {
                    MessageBox.Show("Es necesario capturar un comprobante de salida");
                    return;
                }
            }
            if (FACTURA.Text != "" && txtpo.Text == "")
            {
                MessageBox.Show("Falta capturar la PO de la factura");
                return;
            }
            if (comboBoxClientes.SelectedIndex == -1 || comboVendedor.SelectedIndex == -1)
            {
                MessageBox.Show("Seleccione Cliente y Vendedor");
                return;
            }
            #endregion validaciones
            List <productos>        listaproductos   = new List <productos>();
            List <inventariocostos> listainventarios = new List <inventariocostos>();
            OSAGralSeleccionada.PARTIDAS2.Clear();
            if (AccesoInternet())
            {
                DataTable sal;
                sumatoria = 0;
                if (dataGridView2.RowCount > 0)
                {
                    for (int jj = 0; jj < dataGridView2.RowCount - 1; jj++)
                    {
                        string a = dataGridView2.Rows[jj].Cells[8].Value.ToString();
                        sal = productos.sumas(dataGridView2.Rows[jj].Cells[8].Value.ToString());
                        string w = dataGridView2.Rows[jj].Cells[4].Value.ToString();
                        sumatoria += Convert.ToDouble(sal.Rows[0][0]) * Convert.ToInt32(dataGridView2.Rows[jj].Cells[4].Value);
                    }
                }
                try
                {
                    /*
                     * OSA_GRAL OrdenSalida = new OSA_GRAL();
                     * OrdenSalida.Id = OrdenSalida.NextID();
                     * OrdenSalida.ID_CLIENTE = ClienteSeleccionado.ID;
                     * OrdenSalida.ID_VENDEDOR = EmpleadoSeleccionado.ID;
                     * OrdenSalida.FACTURA = FACTURA.Text;
                     * OrdenSalida.CODIGODEBARRAS = OrdenSalida.Id.ToString();
                     * OrdenSalida.FECHA = DateTime.Now.Date;
                     */
                    #region datos de salida general
                    if (checkBoxPorProyecto.Checked == true)
                    {
                        OSAGralSeleccionada.PROYECTO_ID = proyectoSeleccionado.ID;
                    }
                    OSAGralSeleccionada.ID_CLIENTE     = ClienteSeleccionado.ID;
                    OSAGralSeleccionada.ID_VENDEDOR    = EmpleadoSeleccionado.ID;
                    OSAGralSeleccionada.FACTURA        = FACTURA.Text;
                    OSAGralSeleccionada.TC             = Convert.ToDouble(textBoxTipoCambio.Text);
                    OSAGralSeleccionada.CODIGODEBARRAS = OSAGralSeleccionada.Id.ToString();
                    OSAGralSeleccionada.FECHA          = DateTime.Now.Date;
                    OSAGralSeleccionada.REMISION       = REMISION.Text;
                    OSAGralSeleccionada.COTIZACION     = COTIZACION.Text;
                    #endregion salida
                    if (PartidasOSA.Rows.Count > 0)
                    {
                        int item = 1;
                        #region validacion de productos
                        foreach (DataRow dr in PartidasOSA.Rows)
                        {
                            int       idproducto = Convert.ToInt32(dr["ID_PRODUCTO2"]);
                            productos stock      = new productos(idproducto);
                            if (stock.PrecioAlmacen == 0)
                            {
                                MessageBox.Show("El producto " + idproducto + " " + stock.DESCRIPCION + " No tiene PRECIO ACTUAL, favor de ingresarlo");
                                return;
                            }
                            osa_indiv PartidaIndividual = new osa_indiv();
                            PartidaIndividual.Id           = partidaId;
                            PartidaIndividual.ID_OSAGRAL   = OSAGralSeleccionada.Id;
                            PartidaIndividual.ITEM2        = item;
                            PartidaIndividual.ID_PRODUCTO2 = idproducto;
                            PartidaIndividual.QTY2         = Convert.ToInt32(dr["QTY2"]);
                            PartidaIndividual.VENTA        = Convert.ToInt32(dr["VENTA"]);
                            if (stock.PrecioAlmacen > 0)
                            {
                                PartidaIndividual.precioAlmacen = stock.PrecioAlmacen;
                                PartidaIndividual.totalItem     = stock.PrecioAlmacen * PartidaIndividual.QTY2;
                            }
                            stock.STOCK -= PartidaIndividual.QTY2;
                            if (stock.STOCK < 0)
                            {
                                MessageBox.Show("No hay suficientes " + dr["Catálogo"].ToString() + " en Stock");
                                return;
                            }
                        }
                        #endregion validacion
                        foreach (DataRow dr in PartidasOSA.Rows)
                        {
                            int       idproducto = Convert.ToInt32(dr["ID_PRODUCTO2"]);
                            productos stock      = new productos(idproducto);

                            /* if (stock.PrecioAlmacen == 0)
                             * {
                             *   MessageBox.Show("El producto " + idproducto + " " + stock.DESCRIPCION + " No tiene PRECIO ACTUAL, favor de ingresarlo");
                             *   return;
                             * }*/
                            #region guardar individual
                            osa_indiv PartidaIndividual = new osa_indiv();
                            PartidaIndividual.Id           = partidaId;
                            PartidaIndividual.ID_OSAGRAL   = OSAGralSeleccionada.Id;
                            PartidaIndividual.ITEM2        = item;
                            PartidaIndividual.ID_PRODUCTO2 = idproducto;
                            PartidaIndividual.QTY2         = Convert.ToInt32(dr["QTY2"]);
                            PartidaIndividual.VENTA        = Convert.ToInt32(dr["VENTA"]);
                            if (stock.PrecioAlmacen > 0)
                            {
                                PartidaIndividual.precioAlmacen = stock.PrecioAlmacen;
                                PartidaIndividual.totalItem     = stock.PrecioAlmacen * PartidaIndividual.QTY2;
                            }
                            #endregion individual
                            stock.STOCK -= PartidaIndividual.QTY2;//resta al stock

                            /*if (stock.STOCK < 0)
                             * {
                             *  MessageBox.Show("No hay suficientes " + dr["Catálogo"].ToString() + " en Stock");
                             *  return;
                             * }*/
                            listaproductos.Add(stock);
                            //stock.Update("Id");//actualiza datos del producto
                            MessageBox.Show(stock.CATALOGO + " nuevo stock " + stock.STOCK);
                            #region LOOP SALIDAS INVETNARIOCOSTOS
                            inventariocostos invCost = new inventariocostos(PartidaIndividual.ID_PRODUCTO2, "Salida");
                            if (invCost.Id > 0)
                            {
                                if (PartidaIndividual.QTY2 <= invCost.cantidad_actual) //si la cantidad de salida es menor o igual a la cantidad de inventario costos
                                {
                                    invCost.cantidad_actual -= PartidaIndividual.QTY2; //le resta la cantidad de salida a la de inventario costos
                                    listainventarios.Add(invCost);
                                    //invCost.Update("Id");//actualiza
                                }
                                else//si la cantidad de salida es mayor
                                {
                                    int Qty = PartidaIndividual.QTY2;
                                    Qty -= invCost.cantidad_actual;//a la cantidad de salida le resta la de inventarios
                                    invCost.cantidad_actual = 0;
                                    listainventarios.Add(invCost);
                                    //invCost.Update("Id");//actaliza
                                    while (Qty > 0)
                                    {
                                        inventariocostos invCost2 = new inventariocostos(PartidaIndividual.ID_PRODUCTO2, "Salida2");
                                        if (invCost2.Id > 0)
                                        {
                                            if (Qty <= invCost2.cantidad_actual) //si la cantidad de salida es menor o igual a la cantidad de inventario costos
                                            {
                                                invCost2.cantidad_actual -= Qty; //le resta la cantidad de salida a la de inventario costos
                                                listainventarios.Add(invCost2);
                                                //invCost2.Update("Id");
                                                Qty = 0;
                                            }
                                            else// si la cantidad de salida es mayor
                                            {
                                                Qty -= invCost2.cantidad_actual;
                                                invCost2.cantidad_actual = 0;
                                                listainventarios.Add(invCost2);
                                                //invCost2.Update("Id");
                                            }
                                        }
                                        else
                                        {
                                            // MessageBox.Show("No hay entradas registradas para esta salida");
                                            Qty = 0;
                                        }
                                    }
                                }
                            }

                            /* else
                             * {
                             *   // MessageBox.Show("Este producto no tiene Facturas de compra, Favor de ingresarlas antes de Sacar el Producto");
                             * }*/
                            #endregion LOOP SALIDAS INVETNARIOCOSTOS
                            OSAGralSeleccionada.PARTIDAS2.Add(PartidaIndividual);//agrga la individual
                            partidaId++;
                            item++;
                        }
                        SaveFileDialog save = new SaveFileDialog();
                        save.DefaultExt = "pdf";
                        save.Filter     = "PDF files|*.pdf";
                        if (save.ShowDialog() == DialogResult.OK)
                        {
                            string ruta = save.FileName;

                            CreatePDF(ruta);
                            System.Diagnostics.Process.Start(ruta);
                        }
                        DialogResult result = MessageBox.Show("DESEA GENERAR LA SALIDA CON LOS DATOS CAPTURADOS?", "REVISAR PDF ANTES DE GUARDAR", MessageBoxButtons.YesNo);
                        if (result == DialogResult.No)
                        {
                            return;
                        }
                        else if (result == DialogResult.Yes)
                        {
                            OSAGralSeleccionada.InsertarHoja();
                            string titulo = "OSA:" + textBoxOENid.Text + "\n\n";
                            foreach (productos prod in listaproductos)
                            {
                                titulo += prod.CATALOGO + "=" + prod.DESCRIPCION + ".\n\n";
                                prod.Update("Id");
                            }
                            foreach (inventariocostos inve in listainventarios)
                            {
                                inve.Update("Id");
                            }
                            if (!(Directory.Exists(Application.StartupPath + @"/OSA_RESPALDO/")))
                            {
                                Directory.CreateDirectory(Application.StartupPath + @"/OSA_RESPALDO/");
                            }
                            string ruta = Application.StartupPath + @"/OSA_RESPALDO/OSA_" + textBoxOENid.Text + ".pdf";
                            CreatePDF(ruta);
                            polizasdb crearpoliza = new polizasdb();
                            crearpoliza.Insertarpoliza(this, titulo);//////////////////////////////////////poliza

                            MySqlConnectionStringBuilder sb = new MySqlConnectionStringBuilder();

                            sb.Server   = "secure199.inmotionhosting.com";
                            sb.UserID   = "abdsto5_felipe";
                            sb.Password = "******";
                            sb.Database = "abdsto5_cotizaciones";


                            //PRUEBAS EN LOCALHOST

                            /*
                             * sb.Server = "localhost";
                             * sb.UserID = "felipe";
                             * sb.Password = "******";
                             * sb.Database = "ejemplo";
                             */
                            bdMysql = new DataBase();
                            bdMysql.DataBaseProvider = TypeOfDataBase.MySqlServer;
                            bdMysql.ConnectionString = sb.ToString();
                            //   bdMysql.ConnectionString = "Server = localhost; Database = descobi; Uid = felipe; Pwd = 1945Inadescobi";
                            bdMysql.CreateConnection();
                            DbObject.DefaultDataBaseObject = bdMysql;

                            resetOSA();//reset
                        }
                    }
                    else
                    {
                        MessageBox.Show("No hay partidas para guardar");
                    }
                }
                catch
                {
                    MessageBox.Show("Ingrese los datos correctos");
                }
            }
            else
            {
                MessageBox.Show("NO HAY INTERNET INTENTELO EN UN MOMENTO");//10000
            }
        }
예제 #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            MySqlConnectionStringBuilder sb = new MySqlConnectionStringBuilder();

            sb.Server   = "secure199.inmotionhosting.com";
            sb.UserID   = "abdsto5_felipe";
            sb.Password = "******";
            sb.Database = "abdsto5_cotizaciones";


            //PRUEBAS EN LOCALHOST

            /*
             * sb.Server = "localhost";
             * sb.UserID = "felipe";
             * sb.Password = "******";
             * sb.Database = "ejemplo";
             */
            bdMysql = new DataBase();
            bdMysql.DataBaseProvider = TypeOfDataBase.MySqlServer;
            bdMysql.ConnectionString = sb.ToString();
            //   bdMysql.ConnectionString = "Server = localhost; Database = descobi; Uid = felipe; Pwd = 1945Inadescobi";
            bdMysql.CreateConnection();
            DbObject.DefaultDataBaseObject = bdMysql;
            dataGridView1.CellClick       += new DataGridViewCellEventHandler(dataGridView1_CellClick);

            /*
             * String mac = "00:12:3F:43:98:52";
             * String mac2 = "";
             * String tarjeta = "Controladora Gigabit Broadcom NetXtreme 57xx";
             * ManagementObjectSearcher mos = new ManagementObjectSearcher("select * from Win32_NetworkAdapter where Name='" + tarjeta + "'");
             * ManagementObjectCollection moc = mos.Get();
             * if (moc.Count > 0)
             * {
             *  foreach (ManagementObject mo in moc)
             *  {
             *      mac2 = (string)mo["MACAddress"];
             *      // MessageBox.Show(mac);
             *  }
             * }
             * else
             * {
             *  MessageBox.Show("Esta Aplicacion no coincide con el equipo, Favor de actualizarla");
             *  this.Close();
             * }
             *
             * if (mac != mac2)
             * {
             *  MessageBox.Show("Esta Aplicacion no coincide con el equipo, Favor de actualizarla");
             *  this.Close();
             * }
             */
            DbObject db     = new DbObject();
            string   cambio = db.añoinflacion();

            if (cambio != DateTime.Now.Year.ToString())
            {
                bdMysql.editarinflacion("Update inflacion SET fecha=CURDATE(), cambio='0' WHERE Id=1");
            }

            lista = clientes.GetExistentes();

            DgieWS                 TCambio     = new DgieWS();
            string                 strTDCambio = TCambio.tiposDeCambioBanxico();
            XElement               root        = XElement.Parse(@strTDCambio);
            XNamespace             bm          = "http://www.banxico.org.mx/structure/key_families/dgie/sie/series/compact";
            IEnumerable <XElement> address     =
                from el in root.Descendants(bm + "DataSet").Elements(bm + "Series")
                where (string)el.Attribute("IDSERIE") == "SF43718"
                select el;

            foreach (XElement el in address)
            {
                tc = "" + el.Element(bm + "Obs").Attribute("OBS_VALUE").Value;
            }
            try
            {
                Convert.ToDouble(tc);
            }
            catch { tc = "0"; }
        }
예제 #4
0
        public void Insertarpoliza(FormSALIDAS formpolizas, string titulos)//insertar nueva orden
        {
            MySqlConnectionStringBuilder sb = new MySqlConnectionStringBuilder();

            sb.Server   = "secure199.inmotionhosting.com";
            sb.UserID   = "abdsto5_felipe";
            sb.Password = "******";
            sb.Database = "abdsto5_cotizaciones";


            //PRUEBAS EN LOCALHOST

            /*
             * sb.Server = "localhost";
             * sb.UserID = "felipe";
             * sb.Password = "******";
             * sb.Database = "ejemplo";
             */
            bdMysql = new DataBase();
            bdMysql.DataBaseProvider = TypeOfDataBase.MySqlServer;
            bdMysql.ConnectionString = sb.ToString();
            bdMysql.CreateConnection();
            DbObject.DefaultDataBaseObject = bdMysql;


            ID = 0;
actualizarfolio:
            try
            {
                folio  = this.NextNumber("folio");
                fecha  = DateTime.Now.Date;
                titulo = titulos;
                if (formpolizas.REMISION.Text != "")
                {
                    titulo = titulo + "Remision: " + formpolizas.REMISION.Text + "\n";
                }
                if (formpolizas.COTIZACION.Text != "")
                {
                    titulo = titulo + "Cotizacion: " + formpolizas.COTIZACION.Text + "\n";
                }
                if (formpolizas.checkBoxPorProyecto.Checked == true)
                {
                    titulo = titulo + "Proyecto: " + formpolizas.comboBoxProyecto.Text + " " + formpolizas.textBoxProyectoId.Text + "\n";
                }
                moneda         = "USD";
                subtotal       = Math.Round(formpolizas.sumatoria, 2);
                iva            = 0;
                ingreso        = 0;
                egreso         = Math.Round(formpolizas.sumatoria, 2);
                fechaoperacion = DateTime.Now.Date;
                factura        = formpolizas.FACTURA.Text;
                pocliente      = formpolizas.txtpo.Text;
                remision       = formpolizas.REMISION.Text;
                if (remision == "")
                {
                    remision = formpolizas.COTIZACION.Text;
                }
                origen    = "ALMACEN";
                suborigen = "N/A";
                if (formpolizas.checkBoxPorProyecto.Checked == true)
                {
                    destino = "PREFACTURA PROYECTOS";
                }
                else
                {
                    destino = "PREFACTURA PRODUCTOS";
                }
                subdestino       = formpolizas.comboBoxClientes.Text;
                notas            = "SALIDA AUTOMATICA DE ALMACEN";
                tipo             = "EGRESO";
                estatus          = 1;
                adjunto1         = "";
                saldo            = 0;
                estatus2         = 1;
                numero           = "";
                saldoglobal      = 0;
                proveedor        = "";
                porcentajemargen = 0;
                programado       = "";
                if (estatus == 1 && origen != "PROVEEDORES")
                {
                    programado = "pagado";
                }
                if (origen == "CAJA" || origen == "PROVEEDORES" || origen == "BRANNSTORE" || origen == "PRE IMPORTACION")
                {
                    programado = "";
                }
                if (estatus == 2)
                {
                    programado = "pagado";
                }
                deducible     = "NO";
                tipocambio    = Convert.ToDouble(formpolizas.textBoxTipoCambio.Text);
                retension     = 0;
                retension_isr = 0;
                saldo2        = 0;
                saldo3        = 0;
                saldo4        = 0;
                if (formpolizas.comboVendedor.Text == "Felipe Ortiz" || formpolizas.comboVendedor.Text == "Oficina" || formpolizas.comboVendedor.Text == "Antonio Viera")
                {
                    idnegocio = 1;
                }
                else if (formpolizas.comboVendedor.Text == "Jesus ortiz")
                {
                    idnegocio = 19;
                }
                else if (formpolizas.comboVendedor.Text == "Samuel" || formpolizas.comboVendedor.Text == "Taller")
                {
                    idnegocio = 18;
                }
                else
                {
                    idnegocio = 3;
                }
                idproyecto = formpolizas.idproyectos;

                pocliente = formpolizas.txtpo.Text;
                if (formpolizas.checkBoxPorProyecto.Checked == true)
                {
                    prefactura = Convert.ToInt32(this.factura(idproyecto.ToString()));
                }
                else
                {
                    idproyecto = 0;
                    if (formpolizas.txtpo.Text != "" && formpolizas.txtpo.Text != "0")
                    {
                        prefactura = Convert.ToInt32(this.facturapoliza(pocliente));
                    }
                }
                this.Insert();
                if (this.Error != "")
                {
                    goto actualizarfolio;
                }
                else
                {
                    formpolizas.OSAGralSeleccionada.actualizarosa("idpoliza", folio.ToString(), "Id=" + formpolizas.OSAGralSeleccionada.Id.ToString());
                }
            }
            catch
            {
                goto actualizarfolio;
            }
        }