///******************************************************************************* ///PROYECTO:Cafeteria Neurologos ///NOMBRE DE LA FUNCIÓN: Actualizar_Productos ///DESCRIPCIÓN: ACTUALIZA LOS PRODUCTOS O CATEGORIAS ///PARAMETROS: ///CREO: ///FECHA_CREO: ///MODIFICO: ///FECHA_MODIFICO: ///CAUSA_MODIFICACIÓN: ///******************************************************************************* public Boolean Actualizar_Productos(Cls_Mdl_Productos Datos) { Boolean Transaccion = false; SqlTransaction Obj_Transaccion; SqlConnection Obj_Conexion = new SqlConnection(ConexionBD.BD); SqlCommand Obj_Comando = new SqlCommand(); String Sql = String.Empty; String Estatus = String.Empty; Obj_Conexion.Open(); Obj_Transaccion = Obj_Conexion.BeginTransaction(); Obj_Comando.Transaction = Obj_Transaccion; Obj_Comando.Connection = Obj_Conexion; DataTable Dt_Registro = new DataTable(); try { if (!String.IsNullOrEmpty(Datos.Producto)) //PRODUCTOS { Sql = " UPDATE Cat_Productos SET "; Sql += " Producto = " + (String.IsNullOrEmpty(Datos.Producto) ? "null, " : "'" + Datos.Producto + "', "); Sql += " Categoria_ID = " + (String.IsNullOrEmpty(Datos.Categoria_ID.ToString()) ? "null, " : "'" + Datos.Categoria_ID + "', "); Sql += " Precio = " + (String.IsNullOrEmpty(Datos.Precio.ToString()) ? "null, " : "'" + Datos.Precio + "', "); Sql += " Usuario_Modifico = " + (String.IsNullOrEmpty(Datos.Usuario_Modifico) ? "null, " : "'" + Datos.Usuario_Modifico + "' "); Sql += " WHERE Cat_Productos.Producto_ID = '" + Datos.Producto_ID + "'"; } else //CATEGORIAS { Sql = " UPDATE Cat_Categorias SET "; Sql += " Categoria = " + (String.IsNullOrEmpty(Datos.Categoria) ? "null, " : "'" + Datos.Categoria + "', "); Sql += " Usuario_Modifico = " + (String.IsNullOrEmpty(Datos.Usuario_Modifico) ? "null, " : "'" + Datos.Usuario_Modifico + "' "); Sql += " WHERE Cat_Categorias.Categoria_ID = '" + Datos.Categoria_ID + "'"; } Obj_Comando.CommandText = Sql; Obj_Comando.ExecuteNonQuery(); Obj_Transaccion.Commit(); Obj_Conexion.Close(); Transaccion = true; } catch (Exception Ex) { Transaccion = false; Obj_Transaccion.Rollback(); throw new Exception(Ex.Message); } finally { if (!Transaccion) { Obj_Conexion.Close(); } } return(Transaccion); }
///******************************************************************************* ///NOMBRE DE LA FUNCIÓN: Consulta_Usuario ///DESCRIPCIÓN: CONSULTAR A lOS CLIENTES REGISTRADOS ///PARAMETROS: ///CREO: CHANTAL ORIGEL ///FECHA_CREO: ///MODIFICO: ///FECHA_MODIFICO: ///CAUSA_MODIFICACIÓN: ///******************************************************************************* public Boolean Enviar_Corte(Cls_Mdl_Balance Datos) { Boolean Transaccion = false; SqlTransaction Obj_Transaccion; SqlConnection Obj_Conexion = new SqlConnection(ConexionBD.BD); SqlCommand Obj_Comando = new SqlCommand(); String Sql = String.Empty; String Estatus = String.Empty; Obj_Conexion.Open(); Obj_Transaccion = Obj_Conexion.BeginTransaction(); Obj_Comando.Transaction = Obj_Transaccion; Obj_Comando.Connection = Obj_Conexion; DataTable Dt_Registro = new DataTable(); try { Sql = "INSERT INTO Ope_Balance ("; Sql += " Inicio_Caja, "; Sql += " Fin_Caja, "; Sql += " Ventas, "; Sql += " Usuario_Creo "; Sql += ") VALUES ("; Sql += (String.IsNullOrEmpty(Datos.Inicio_Caja) ? "null, " : "'" + Datos.Inicio_Caja + "', "); Sql += (String.IsNullOrEmpty(Datos.Fin_Caja) ? "null, " : "'" + Datos.Fin_Caja + "', "); Sql += (String.IsNullOrEmpty(Datos.Ventas) ? "null, " : "'" + Datos.Ventas + "', "); Sql += (String.IsNullOrEmpty(Datos.Usuario_Creo) ? "null " : "'" + Datos.Usuario_Creo + "' "); Sql += ")"; Obj_Comando.CommandText = Sql; Obj_Comando.ExecuteNonQuery(); Obj_Transaccion.Commit(); Obj_Conexion.Close(); Transaccion = true; } catch (Exception Ex) { Transaccion = false; Obj_Transaccion.Rollback(); throw new Exception(Ex.Message); } finally { if (!Transaccion) { Obj_Conexion.Close(); } } return(Transaccion); }
///******************************************************************************* ///NOMBRE DE LA FUNCIÓN: Consulta_Usuario ///DESCRIPCIÓN: CONSULTAR A lOS CLIENTES REGISTRADOS ///PARAMETROS: ///CREO: CHANTAL ORIGEL ///FECHA_CREO: ///MODIFICO: ///FECHA_MODIFICO: ///CAUSA_MODIFICACIÓN: ///******************************************************************************* public Boolean Actualizar(Cls_Mdl_Balance Datos) { Boolean Transaccion = false; SqlTransaction Obj_Transaccion; SqlConnection Obj_Conexion = new SqlConnection(ConexionBD.BD); SqlCommand Obj_Comando = new SqlCommand(); String Sql = String.Empty; String Estatus = String.Empty; Obj_Conexion.Open(); Obj_Transaccion = Obj_Conexion.BeginTransaction(); Obj_Comando.Transaction = Obj_Transaccion; Obj_Comando.Connection = Obj_Conexion; DataTable Dt_Registro = new DataTable(); try { Sql = " Update Ope_Balance SET "; Sql += " Inicio_Actualizado = " + (String.IsNullOrEmpty(Datos.Inicio_Actualizado) ? "null " : "'" + Datos.Inicio_Actualizado + "' "); Sql += " WHERE Balance_ID = " + Datos.Balance_ID; Obj_Comando.CommandText = Sql; Obj_Comando.ExecuteNonQuery(); Obj_Transaccion.Commit(); Obj_Conexion.Close(); Transaccion = true; } catch (Exception Ex) { Transaccion = false; Obj_Transaccion.Rollback(); throw new Exception(Ex.Message); } finally { if (!Transaccion) { Obj_Conexion.Close(); } } return(Transaccion); }
/////******************************************************************************* /////NOMBRE DE LA FUNCIÓN: Salvar_Lista /////DESCRIPCIÓN: Guardar o actualizar los items de la tabla /////PARAMETROS: /////CREO: MARIA CHANTAL ORIGEL SEGURA /////FECHA_CREO: /////MODIFICO: /////FECHA_MODIFICO: /////CAUSA_MODIFICACIÓN: /////******************************************************************************* internal Boolean Guardar_Venta(Cls_Mdl_Ventas Datos, List <Cls_Mdl_Ventas> Lista) { Boolean Transaccion = false; SqlTransaction Obj_Transaccion; SqlConnection Obj_Conexion = new SqlConnection(ConexionBD.BD); SqlCommand Obj_Comando = new SqlCommand(); String Sql = String.Empty; String Estatus = String.Empty; Obj_Conexion.Open(); Obj_Transaccion = Obj_Conexion.BeginTransaction(); Obj_Comando.Transaction = Obj_Transaccion; Obj_Comando.Connection = Obj_Conexion; try { Sql = "INSERT INTO Ope_Ventas ("; Sql += " Folio, "; Sql += " Subtotal, "; Sql += " IVA, "; Sql += " Total, "; Sql += " Usuario_Creo "; Sql += ") VALUES ("; Sql += (String.IsNullOrEmpty(Datos.Folio) ? "null, " : "'" + Datos.Folio + "', "); Sql += (String.IsNullOrEmpty(Datos.Subtotal) ? "null, " : "'" + Datos.Subtotal + "', "); Sql += (String.IsNullOrEmpty(Datos.IVA) ? "null, " : "'" + Datos.IVA + "', "); Sql += (String.IsNullOrEmpty(Datos.Total) ? "null, " : "'" + Datos.Total + "', "); Sql += (String.IsNullOrEmpty(Datos.Usuario_Creo) ? "null " : "'" + Datos.Usuario_Creo + "' "); Sql += ")"; Obj_Comando.CommandText = Sql; Obj_Comando.ExecuteNonQuery(); SqlDataAdapter Da_Datos = new SqlDataAdapter(); // DataTable Ds_Datos = new DataTable(); Sql = "SELECT Top 1 * FROM Ope_Ventas "; Sql += " order by Venta_ID desc"; Obj_Comando.CommandText = Sql; Da_Datos = new SqlDataAdapter(Obj_Comando); Da_Datos.Fill(Ds_Datos); var Venta_ID = System.Convert.ToInt16(Ds_Datos.Rows[0]["Venta_ID"].ToString()); for (int i = 0; i < Lista.Count; i++) { Sql = "INSERT INTO Ope_Ventas_Detalles ("; Sql += " Venta_ID, "; Sql += " Producto_ID, "; Sql += " Cantidad, "; Sql += " Precio, "; Sql += " Importe "; Sql += ") VALUES ("; Sql += (String.IsNullOrEmpty(Venta_ID.ToString()) ? "null, " : "'" + Venta_ID.ToString() + "', "); Sql += (String.IsNullOrEmpty(Lista[i].Producto_ID) ? "null, " : "'" + Lista[i].Producto_ID + "', "); Sql += (String.IsNullOrEmpty(Lista[i].Cantidad) ? "null, " : "'" + Lista[i].Cantidad + "', "); Sql += (String.IsNullOrEmpty(Lista[i].Precio) ? "null, " : "'" + Lista[i].Precio + "', "); Sql += (String.IsNullOrEmpty(Lista[i].Importe) ? "null, " : "'" + Lista[i].Importe + "' "); Sql += ")"; Obj_Comando.CommandText = Sql; Obj_Comando.ExecuteNonQuery(); } Obj_Transaccion.Commit(); Obj_Conexion.Close(); Transaccion = true; } catch (Exception Ex) { Transaccion = false; Obj_Transaccion.Rollback(); throw new Exception(Ex.Message); } finally { if (!Transaccion) { Obj_Conexion.Close(); } } return(Transaccion); }
///******************************************************************************* ///PROYECTO:Cafeteria Neurologos ///NOMBRE DE LA FUNCIÓN: Eliminar_Productos ///DESCRIPCIÓN: ACTUALIZA LOS PRODUCTOS O CATEGORIAS ///PARAMETROS: ///CREO: ///FECHA_CREO: ///MODIFICO: ///FECHA_MODIFICO: ///CAUSA_MODIFICACIÓN: ///******************************************************************************* public Boolean Eliminar_Productos(Cls_Mdl_Productos Datos) { Boolean Transaccion = false; SqlTransaction Obj_Transaccion; SqlConnection Obj_Conexion = new SqlConnection(ConexionBD.BD); SqlCommand Obj_Comando = new SqlCommand(); String Sql = String.Empty; String Estatus = String.Empty; String SqlCons = String.Empty; DataTable Dt_Registro = new DataTable(); Obj_Conexion.Open(); Obj_Transaccion = Obj_Conexion.BeginTransaction(); Obj_Comando.Transaction = Obj_Transaccion; Obj_Comando.Connection = Obj_Conexion; try { if (!String.IsNullOrEmpty(Datos.Producto_ID)) //PRODUCTOS { Sql = " DELETE FROM Cat_Productos"; Sql += " WHERE Cat_Productos.Producto_ID = '" + Datos.Producto_ID + "'"; Obj_Comando.CommandText = Sql; Obj_Comando.ExecuteNonQuery(); Transaccion = true; } else //CATEGORIAS { SqlCons = " Select * FROM Cat_Productos where Categoria_ID ='" + Datos.Categoria_ID + "'"; Dt_Registro = SqlHelper.ExecuteDataset(ConexionBD.BD, CommandType.Text, SqlCons).Tables[0]; if (Dt_Registro.Rows.Count > 0) { Transaccion = false; } else { Sql = " DELETE FROM Cat_Categorias"; Sql += " WHERE Cat_Categorias.Categoria_ID = '" + Datos.Categoria_ID + "'"; Obj_Comando.CommandText = Sql; Obj_Comando.ExecuteNonQuery(); Transaccion = true; } } Obj_Transaccion.Commit(); Obj_Conexion.Close(); } catch (Exception Ex) { Transaccion = false; Obj_Transaccion.Rollback(); throw new Exception(Ex.Message); } finally { if (!Transaccion) { Obj_Conexion.Close(); } } return(Transaccion); }
///******************************************************************************* ///PROYECTO:Cafeteria Neurologos ///NOMBRE DE LA FUNCIÓN: Guardar_Productos ///DESCRIPCIÓN: GUARDAR LOS PRODUCTOS O CATEGORIAS ///PARAMETROS: ///CREO: ///FECHA_CREO: ///MODIFICO: ///FECHA_MODIFICO: ///CAUSA_MODIFICACIÓN: ///******************************************************************************* public Boolean Guardar_Productos(Cls_Mdl_Productos Datos) { Boolean Transaccion = false; SqlTransaction Obj_Transaccion; SqlConnection Obj_Conexion = new SqlConnection(ConexionBD.BD); SqlCommand Obj_Comando = new SqlCommand(); String Sql = String.Empty; String Estatus = String.Empty; Obj_Conexion.Open(); Obj_Transaccion = Obj_Conexion.BeginTransaction(); Obj_Comando.Transaction = Obj_Transaccion; Obj_Comando.Connection = Obj_Conexion; DataTable Dt_Registro = new DataTable(); try { if (!String.IsNullOrEmpty(Datos.Producto)) //PRODUCTOS { Sql = "INSERT INTO Cat_Productos ("; Sql += " Producto, "; Sql += " Categoria_ID, "; Sql += " Precio, "; //Sql += " Fecha_Creo, "; Sql += " Usuario_Creo "; Sql += ") VALUES ("; Sql += (String.IsNullOrEmpty(Datos.Producto.ToString()) ? "null, " : "'" + Datos.Producto.ToString() + "', "); Sql += (String.IsNullOrEmpty(Datos.Categoria_ID.ToString()) ? "null, " : "'" + Datos.Categoria_ID + "', "); Sql += (String.IsNullOrEmpty(Datos.Precio.ToString()) ? "null, " : "'" + Datos.Precio + "', "); //Sql += (String.IsNullOrEmpty(Datos.Fecha_Creo) ? "null, " : "'" + Datos.Fecha_Creo + "', "); Sql += (String.IsNullOrEmpty(Datos.Usuario_Creo) ? "null " : "'" + Datos.Usuario_Creo + "' "); Sql += ")"; } else //CATEGORIAS { Sql = "INSERT INTO Cat_Categorias ("; Sql += " Categoria, "; //Sql += " Fecha_Creo, "; Sql += " Usuario_Creo "; Sql += ") VALUES ("; Sql += (String.IsNullOrEmpty(Datos.Categoria.ToString()) ? "null, " : "'" + Datos.Categoria.ToString() + "', "); //Sql += (String.IsNullOrEmpty(Datos.Fecha_Creo) ? "null, " : "'" + Datos.Fecha_Creo + "', "); Sql += (String.IsNullOrEmpty(Datos.Usuario_Creo) ? "null " : "'" + Datos.Usuario_Creo + "' "); Sql += ")"; } Obj_Comando.CommandText = Sql; Obj_Comando.ExecuteNonQuery(); Obj_Transaccion.Commit(); Obj_Conexion.Close(); Transaccion = true; } catch (Exception Ex) { Transaccion = false; Obj_Transaccion.Rollback(); throw new Exception(Ex.Message); } finally { if (!Transaccion) { Obj_Conexion.Close(); } } return(Transaccion); }