Esempio n. 1
0
        private void LeerMermas()
        {
            String       id, unidad;
            FileStream   fs = new FileStream("Merma.txt", FileMode.Open, FileAccess.Read);
            StreamReader sr = new StreamReader(fs);

            while ((id = sr.ReadLine()) != null)
            {
                Merma merm = new Merma();
                merm.Id_articulo     = Int32.Parse(id);
                merm.Codigo          = sr.ReadLine();
                merm.Descripcion     = sr.ReadLine();
                merm.Cantidad        = Double.Parse(sr.ReadLine());
                unidad               = sr.ReadLine();
                merm.Unidad          = (TUnidad)Enum.Parse(typeof(TUnidad), unidad);
                merm.Fecha_caducidad = Convert.ToDateTime(sr.ReadLine());
                Categoria cat = new Categoria();
                cat.Nombre          = sr.ReadLine();
                merm.Categoria      = cat;
                merm.Motivo_de_baja = (TTipoMerma)Enum.Parse(typeof(TTipoMerma), sr.ReadLine());
                mermas.Add(merm);
            }
            sr.Close();
            fs.Close();
        }
Esempio n. 2
0
        public static string InsertMerma(Merma merma)
        {
            string resp = "";

            try
            {
                SqlTransaction transaction = clsConexion.getCon().BeginTransaction("InsertarMerma");
                string[]       elementos   = new string[6] {
                    merma.IdSucursal.ToString(), merma.IdEmpleado.ToString(), merma.IdIngrediente.ToString(), merma.Cantidad.ToString(), merma.Motivo, merma.IdInformante.ToString()
                };
                string sql             = string.Format("Insert Into Merma(IdSucursal,IdEmpleado,IdIngrediente,Cantidad,Motivo,IdInformante) Values ({0},{1},{2},{3},'{4}',{5});Select SCOPE_IDENTITY();", elementos);
                string actualizarStock = string.Format("Update Deposito set Stock=Stock-{0} where IdIngrediente={1} and IdSucursal={2}", merma.Cantidad, merma.IdIngrediente, merma.IdSucursal);
                if (merma.IdIngrediente == -1)
                {
                    elementos = new string[6] {
                        merma.IdSucursal.ToString(), merma.IdEmpleado.ToString(), merma.IdBebida.ToString(), merma.Cantidad.ToString(), merma.Motivo, merma.IdInformante.ToString()
                    };
                    sql             = string.Format("Insert Into Merma(IdSucursal,IdEmpleado,IdBebida,Cantidad,Motivo,IdInformante) Values ({0},{1},{2},{3},'{4}',{5});Select SCOPE_IDENTITY();", elementos);
                    actualizarStock = string.Format("Update Deposito set Stock=Stock-{0} where IdBebida={1} and IdSucursal={2}", merma.Cantidad, merma.IdBebida, merma.IdSucursal);
                }
                SqlCommand comando = new SqlCommand(sql, clsConexion.getCon());
                comando.Transaction = transaction;
                int id = Convert.ToInt32(comando.ExecuteScalar().ToString());
                comando.CommandText = actualizarStock;
                comando.ExecuteNonQuery();
                comando.Transaction.Commit();
            }
            catch (SqlException e)
            {
                resp = e.Message;
            }
            finally {
                clsConexion.closeCon();
            }
            return(resp);
        }
Esempio n. 3
0
 public frmMerma(int IdSol)
 {
     this.IdsolicitudMerma = IdSol;
     InitializeComponent();
     IdSucursal = clsConexion.SucursalSession;
     try
     {
         dtBebidas      = clsBebida.getBebidas(IdSucursal);
         dtIngredientes = clsIngrediente.getIngredientes(IdSucursal);
         dtEmpleado     = clsEmpleado.empleadosDeSucrursalMerma(IdSucursal);
         dtMerma        = clsMerma.getMerma(IdSucursal);
         DataRow ninguno = dtEmpleado.NewRow();
         ninguno["Nombre"]     = "Nadie";
         ninguno["IdEmpleado"] = 0;
         dtEmpleado.Rows.InsertAt(ninguno, 0);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     merma = new Merma();
     merma.IdInformante = Convert.ToInt32(clsConexion.IdEmpleado);
     merma.IdSucursal   = clsConexion.SucursalSession;
 }