private void button1_Click(object sender, EventArgs e) { Models.Dev_prov devo = new Models.Dev_prov(); Models.det_dev_prov detalles = new Models.det_dev_prov(); Models.Product productos = new Models.Product(); Models.det_devolution det_devolu = new Models.det_devolution(); Models.Log historial = new Models.Log(); using (devo) { devo.Id_proveedor = Convert.ToInt32(txtId_proveedor.Text); devo.Total = Convert.ToDouble(txtTotal.Text); devo.Estado = false; devo.Motivo = txtMotivo.Text; devo.create_dev(); string mensaje = "se envio una devolucion a " + txtProveedor.Text + "<br/>"; List <Models.Dev_prov> ultimo = devo.get_lastdevolucion(Convert.ToInt32(txtId_proveedor.Text), Convert.ToDouble(txtTotal.Text), txtMotivo.Text); Folio_guardado = ultimo[0].Id; using (detalles) { foreach (DataGridViewRow row in dtProductos.Rows) { detalles.Id_devolucion = ultimo[0].Id; detalles.Id_producto = Convert.ToInt32(row.Cells["id"].Value.ToString()); detalles.Cantidad = Convert.ToDouble(row.Cells["cantidad"].Value.ToString()); detalles.Pu = Convert.ToDouble(row.Cells["p_u"].Value.ToString()); detalles.Estado = false; detalles.create_det(); using (historial) { historial.Id_usuario = Convert.ToInt32(Inicial.id_usario); historial.Descripcion = "se envio " + row.Cells["cantidad"].Value.ToString() + " del producto " + row.Cells["desripcion"].Value.ToString() + " como devolucion al proveedor " + txtProveedor.Text; historial.createLog(); } mensaje += row.Cells["cantidad"].Value.ToString() + " -- " + row.Cells["desripcion"].Value.ToString() + "<br/>"; if (row.Cells["folios"].Value is null) { using (productos) { List <Models.Product> producto = productos.getProductById(Convert.ToInt32(row.Cells["id"].Value.ToString())); productos.Existencia = producto[0].Existencia - Convert.ToDouble(row.Cells["cantidad"].Value.ToString()); productos.Id = Convert.ToInt32(row.Cells["id"].Value.ToString()); productos.update_inventary(); } } else { using (productos) { productos.Id = Convert.ToInt32(row.Cells["id"].Value.ToString()); List <Models.Product> produ = productos.getProductById(Convert.ToInt32(row.Cells["id"].Value.ToString())); productos.Devoluciones = produ[0].Devoluciones - Convert.ToDouble(row.Cells["cantidad"].Value.ToString()); productos.update_devoluciones(); } char delimitar = ','; string[] folios = row.Cells["folios"].Value.ToString().Split(delimitar); int cuantos = folios.Count(); for (int i = 0; i < cuantos; i++) { using (det_devolu) { det_devolu.Id_producto = Convert.ToInt32(row.Cells["id"].Value.ToString()); det_devolu.Id_devolucion = Convert.ToInt32(folios[i]); det_devolu.enviar(); } } } } } mensaje += "con un total de $" + txtTotal.Text; intercambios intercambios = new intercambios(); intercambios.enviar_correo("", mensaje, "Envio de devolucion"); } imprimir(); }
private void button1_Click(object sender, EventArgs e) { if (txtNombre.Text != "" || cbTipo.Text != "") { Models.Users usuario = new Models.Users(); string resultado = ""; using (MD5 md5Hash = MD5.Create()) { resultado = Forms.intercambios.GetMd5Hash(md5Hash, txtContra.Text); } if (cbTipo.SelectedValue.ToString() == "Cajero") { usuario.Id = id; usuario.Tipo = cbTipo.SelectedValue.ToString(); usuario.Nombre = txtNombre.Text; usuario.User = ""; } else { usuario.Id = id; usuario.Tipo = cbTipo.SelectedValue.ToString(); usuario.Nombre = txtNombre.Text; usuario.User = txtUsuario.Text; } if (id == 0) { if (cbTipo.SelectedValue.ToString() == "Cajero") { usuario.Pass = ""; } else { usuario.Pass = resultado; } using (usuario) { usuario.createUser(); List <Models.Users> resu = usuario.getInsertUser(txtUsuario.Text, usuario.Pass); Models.Permisos permiso = new Models.Permisos(); using (permiso) { permiso.Id_usuario = resu[0].Id; permiso.May_men = Convert.ToInt16(checkBox1.Checked); permiso.Historia_venta = Convert.ToInt16(checkBox2.Checked); permiso.Entrada_efectivo = Convert.ToInt16(checkBox3.Checked); permiso.Salida_efectivo = Convert.ToInt16(checkBox4.Checked); permiso.Cobrar_ticket = Convert.ToInt16(checkBox5.Checked); permiso.Cancelar_ticket = Convert.ToInt16(checkBox6.Checked); permiso.Alimina_art_venta = Convert.ToInt16(checkBox7.Checked); permiso.Cred_cli = Convert.ToInt16(checkBox8.Checked); permiso.Mod_cli = Convert.ToInt16(checkBox9.Checked); permiso.Nuevo_prod = Convert.ToInt16(checkBox10.Checked); permiso.Mod_prod = Convert.ToInt16(checkBox11.Checked); permiso.Del_prod = Convert.ToInt16(checkBox12.Checked); permiso.Rep_venta = Convert.ToInt16(checkBox13.Checked); permiso.Nueva_promo = Convert.ToInt16(checkBox14.Checked); permiso.Add_mercancia = Convert.ToInt16(checkBox15.Checked); permiso.Ver_minimos = Convert.ToInt16(checkBox16.Checked); permiso.Ver_mov_inv = Convert.ToInt16(checkBox17.Checked); permiso.Ajus_inv = Convert.ToInt16(checkBox18.Checked); permiso.Corte_caja = Convert.ToInt16(checkBox19.Checked); permiso.Corte_todos = Convert.ToInt16(checkBox20.Checked); permiso.Ganancias = Convert.ToInt16(checkBox21.Checked); permiso.Reporte_ganancias = Convert.ToInt16(checkBox22.Checked); permiso.Retiro_efectivo = Convert.ToInt16(checkBox23.Checked); permiso.Devoluciones = Convert.ToInt16(chkDevoluciones.Checked); permiso.Cam_precio = Convert.ToInt32(chkPrecio.Checked); permiso.createPermisos(); } } } else { if (cbTipo.SelectedValue.ToString() == "Cajero") { usuario.Pass = ""; } else { List <Models.Users> get = usuario.getUserbyid(id); if (get[0].Pass == txtContra.Text) { usuario.Pass = txtContra.Text; } else { usuario.Pass = resultado; } } using (usuario) { usuario.saveUser(); Models.Permisos permiso = new Models.Permisos(); using (permiso) { permiso.Id_usuario = id; permiso.May_men = Convert.ToInt16(checkBox1.Checked); permiso.Historia_venta = Convert.ToInt16(checkBox2.Checked); permiso.Entrada_efectivo = Convert.ToInt16(checkBox3.Checked); permiso.Salida_efectivo = Convert.ToInt16(checkBox4.Checked); permiso.Cobrar_ticket = Convert.ToInt16(checkBox5.Checked); permiso.Cancelar_ticket = Convert.ToInt16(checkBox6.Checked); permiso.Alimina_art_venta = Convert.ToInt16(checkBox7.Checked); permiso.Cred_cli = Convert.ToInt16(checkBox8.Checked); permiso.Mod_cli = Convert.ToInt16(checkBox9.Checked); permiso.Nuevo_prod = Convert.ToInt16(checkBox10.Checked); permiso.Mod_prod = Convert.ToInt16(checkBox11.Checked); permiso.Del_prod = Convert.ToInt16(checkBox12.Checked); permiso.Rep_venta = Convert.ToInt16(checkBox13.Checked); permiso.Nueva_promo = Convert.ToInt16(checkBox14.Checked); permiso.Add_mercancia = Convert.ToInt16(checkBox15.Checked); permiso.Ver_minimos = Convert.ToInt16(checkBox16.Checked); permiso.Ver_mov_inv = Convert.ToInt16(checkBox17.Checked); permiso.Ajus_inv = Convert.ToInt16(checkBox18.Checked); permiso.Corte_caja = Convert.ToInt16(checkBox19.Checked); permiso.Corte_todos = Convert.ToInt16(checkBox20.Checked); permiso.Ganancias = Convert.ToInt16(checkBox21.Checked); permiso.Reporte_ganancias = Convert.ToInt16(checkBox22.Checked); permiso.Retiro_efectivo = Convert.ToInt16(checkBox23.Checked); permiso.Id = id_permiso; permiso.Devoluciones = Convert.ToInt16(chkDevoluciones.Checked); permiso.Cam_precio = Convert.ToInt32(chkPrecio.Checked); permiso.savePermisos(); } } } Models.Log historial = new Models.Log(); string mensaje = ""; using (historial) { mensaje = "se agrego nuevo usuario: " + txtNombre.Text; historial.Id_usuario = Convert.ToInt32(Inicial.id_usario); historial.Descripcion = mensaje; intercambios intercambio = new intercambios(); intercambio.enviar_correo("", mensaje, "Nuevo usuario"); } this.Close(); } }
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e) { Models.Configuration configuracion = new Models.Configuration(); using (configuracion) { List <Models.Configuration> config = configuracion.getConfiguration(); Font font = new Font("Verdana", 8, FontStyle.Regular); int y = 70; var format = new StringFormat() { Alignment = StringAlignment.Center }; if (config[0].Logo_ticket != "") { if (File.Exists(config[0].Logo_ticket)) { Image logo = Image.FromFile(config[0].Logo_ticket); e.Graphics.DrawImage(logo, new Rectangle(0, 00, 250, 70)); } } y = y + 10; e.Graphics.DrawString(config[0].Razon_social, font, Brushes.Black, 125, y, format); y = y + 10; e.Graphics.DrawString(config[0].RFC, font, Brushes.Black, 125, y, format); y = y + 10; string calle = config[0].Calle + " " + config[0].No_ext; if (config[0].No_int != "") { calle += "-" + config[0].No_int; } e.Graphics.DrawString(calle, font, Brushes.Black, 125, y, format); y = y + 10; e.Graphics.DrawString(config[0].Municipio + " " + config[0].Estado, font, Brushes.Black, 125, y, format); y = y + 10; e.Graphics.DrawString("Telefono" + config[0].Telefono, font, Brushes.Black, 125, y, format); y = y + 10; e.Graphics.DrawString(config[0].Razon_social, font, Brushes.Black, 125, y, format); format = new StringFormat() { Alignment = StringAlignment.Far }; y = y + 10; e.Graphics.DrawString("___________________________________________", font, Brushes.Black, 0, y); y = y + 15; e.Graphics.DrawString("Transferencia: " + txtFolios.Text, font, Brushes.Black, 0, y); /* y = y + 10; * e.Graphics.DrawString("___________________________________________", font, Brushes.Black, 0, y); */ y = y + 20; e.Graphics.DrawString("Cant.", font, Brushes.Black, 50, y, format); e.Graphics.DrawString("P/U.", font, Brushes.Black, 100, y, format); e.Graphics.DrawString("IMPTE.", font, Brushes.Black, 220, y, format); y = y + 10; e.Graphics.DrawString("___________________________________________", font, Brushes.Black, 0, y); foreach (DataGridViewRow row in dtProductos.Rows) { y = y + 30; e.Graphics.DrawString(row.Cells["descripcion"].Value.ToString(), font, Brushes.Black, 10, y); e.Graphics.DrawString(row.Cells["cantidad"].Value.ToString(), font, Brushes.Black, 50, y + 10, format); e.Graphics.DrawString(formato(row.Cells["p_u"].Value.ToString()), font, Brushes.Black, 100, y + 10, format); e.Graphics.DrawString(formato(row.Cells["Importe"].Value.ToString()), font, Brushes.Black, 220, y + 10, format); } y = y + 15; e.Graphics.DrawString("___________________________________________", font, Brushes.Black, 0, y); y = y + 15; e.Graphics.DrawString("Total", font, Brushes.Black, 150, y + 10, format); e.Graphics.DrawString(txtSubtotal.Text, font, Brushes.Black, 220, y + 10, format); y = y + 40; intercambios inter = new intercambios(); e.Graphics.DrawString(inter.enletras(txtSubtotal.Text), font, Brushes.Black, 0, y); y = y + 30; e.Graphics.DrawString("___________________________________________", font, Brushes.Black, 0, y); } }