Пример #1
0
        //A COMPLETAR
        public Boolean vender(Int32 qtde)
        {
            Int32   id        = 0;
            Int32   quant     = 0;
            Lote    lotezinho = new Lote();
            Boolean vendido   = false;

            Console.WriteLine("Informe qual é o ID do medicamento");
            id = Convert.ToInt32(Console.ReadLine());

            Medicamentos medicamentos = new Medicamentos();



            foreach (Lote lot in Lotes)
            {
                quant += Convert.ToInt32(lot.Qtde);
            }
            //L -= qtde;
            foreach (Lote lot in Lotes)
            {
                lotezinho.Qtde -= qtde;
                if (lotezinho.Qtde == 0)
                {
                    Lotes.Enqueue(lot);
                }
            }
            vendido = true;

            return(vendido);
        }//VENDER
Пример #2
0
        private void Recepcion_Load(object sender, EventArgs e)
        {
            Socios socio = new Socios();

            SocioIdcomboBox.DataSource    = socio.Listar("SocioId, Nombre", "1=1", "");
            SocioIdcomboBox.DisplayMember = "Nombre";
            SocioIdcomboBox.ValueMember   = "SocioId";


            BLL.Certificaciones Cert = new BLL.Certificaciones();
            CertificacionIdcomboBox.DataSource    = Cert.Listar("CertificacionId, Descripcion", "1=1", "");
            CertificacionIdcomboBox.DisplayMember = "Descripcion";
            CertificacionIdcomboBox.ValueMember   = "CertificacionId";

            Lotes lotes = new Lotes();

            LoteIdcomboBox.DataSource    = lotes.Listar("*", "1=1", "");
            LoteIdcomboBox.DisplayMember = "CodigoLote";
            LoteIdcomboBox.ValueMember   = "LoteId";

            BLL.TipoCacao TipoC = new BLL.TipoCacao();
            TipoCacaoIdcomboBox.DataSource    = TipoC.Listar("TipoCacaoId, Descripcion", "1=1", "");
            TipoCacaoIdcomboBox.DisplayMember = "Descripcion";
            TipoCacaoIdcomboBox.ValueMember   = "TipoCacaoId";
        }
        // GET: LotesComidas/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LotesComida lotesComida = await db.LotesComidas.FindAsync(id);

            if (lotesComida == null)
            {
                return(HttpNotFound());
            }

            List <Opciones> lstOpciones = new List <Opciones>();
            Opciones        objOpcion   = new Opciones();

            objOpcion.OpcionId    = -1;
            objOpcion.Codigopcion = "-- Seleccione --";
            lstOpciones.Add(objOpcion);
            lstOpciones.AddRange(db.Opciones.Where(O => O.TipoOpcion == "CuidoCerdos").ToList());
            ViewBag.OpcionId = new SelectList(lstOpciones, "OpcionId", "Codigopcion", lotesComida.OpcionId);

            List <Lotes> lstLotes = new List <Lotes>();
            Lotes        objLote  = new Lotes();

            objLote.LoteId     = -1;
            objLote.NombreLote = "-- Seleccione --";
            lstLotes.Add(objLote);
            lstLotes.AddRange(db.Lotes);
            ViewBag.LoteId = new SelectList(lstLotes, "LoteId", "NombreLote", lotesComida.LoteId);

            return(View(lotesComida));
        }
Пример #4
0
 public ActionResult PorLote(int?LoteId)
 {
     ViewBag.LoteExiste = LoteId.HasValue && LoteId > 0;
     if (ViewBag.LoteExiste)
     {
         ViewBag.Lote = Lote.Get(LoteId.Value);
     }
     else
     {
         Lotes lotes = Lotes.List(Current.FazendaId);
         ViewBag.Lotes = new Lotes();
         if (lotes != null && lotes.Count > 0)
         {
             foreach (Lote l in lotes)
             {
                 if (Lote.GetQtnAnimais(l.Id) > 0)
                 {
                     ViewBag.Lotes.Add(l);
                 }
             }
         }
         if (ViewBag.Lotes.Count <= 0)
         {
             return(RedirectToAction("ApresentaMensagem", new { menssagem = "Não existe lotes com animais disponíveis", message = MessageType.Warning }));
         }
     }
     return(View());
 }
Пример #5
0
        public LoteRemessaCnab240 AdicionarLote(HeaderLoteRemessaCnab240 headerLote, TrailerLoteRemessaCnab240 trailerLote)
        {
            var loteAdd = new LoteRemessaCnab240();

            loteAdd.HeaderLote  = headerLote;
            loteAdd.TrailerLote = trailerLote;

            Lotes.Add(loteAdd);
            return(loteAdd);
        }
Пример #6
0
        public void setLoteActive(object parameter)
        {
            MessageBoxResult result = MessageBox.Show("Cambiar Estado a Activo?", "Cambiar Estado", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                InventoryQueries.SetLoteSalidaActive(SelectedInactive.CodLote);

                Lotes.Add(SelectedInactive);
                LotesInactive.Remove(SelectedInactive);
            }
        }
Пример #7
0
        private void Guardarbutton_Click(object sender, EventArgs e)
        {
            BLL.Exportacion exportacion = new BLL.Exportacion();

            if (ExportacionIdtextBox.Text.Length == 0)
            {
                double.TryParse(CantidadtextBox.Text, out toneladas);
                exportacion.CantidadToneladas = toneladas;
                exportacion.Fecha             = FechadateTimePicker.Text;
                exportacion.CertificacionId   = (int)CertificacionIdcomboBox.SelectedValue;
                exportacion.DestinoId         = (int)DestinosIdcomboBox.SelectedValue;
                exportacion.Resumen           = ResumenrichTextBox.Text;


                for (int i = 0; i < LoteslistBox.Items.Count; i++)
                {
                    Lotes lotes = new Lotes();
                    lotes.LoteId = (int)LoteIdcomboBox.SelectedValue;
                    exportacion.AgregarLotes(lotes.LoteId, LoteslistBox.Items[i].ToString());
                }
                if (exportacion.Insertar())
                {
                    MessageBox.Show("Se guardaron los datos!");
                }
                else
                {
                    MessageBox.Show("No se han guardado los datos!");
                }
            }
            else
            {
                int.TryParse(ExportacionIdtextBox.Text, out exportacionId);
                exportacion.ExportacionId = exportacionId;

                double.TryParse(CantidadtextBox.Text, out toneladas);
                exportacion.CantidadToneladas = toneladas;
                exportacion.Fecha             = FechadateTimePicker.Text;
                exportacion.CertificacionId   = (int)CertificacionIdcomboBox.SelectedValue;
                exportacion.ExportacionId     = (int)DestinosIdcomboBox.SelectedValue;
                exportacion.Resumen           = ResumenrichTextBox.Text;


                if (exportacion.Editar())
                {
                    MessageBox.Show("Se han actualizado los datos!");
                }
                else
                {
                    MessageBox.Show("No se han guardado los datos!");
                }
            }
        }
Пример #8
0
        public PartialViewResult Listar(int?FazendaId)
        {
            if (FazendaId.HasValue && FazendaId > 0)
            {
                ViewBag.Lotes = Lotes.List(FazendaId.Value);
            }
            else
            {
                ViewBag.Lotes = Lotes.List(SysPec.App.Helpers.Current.FazendaId);
            }

            return(PartialView());
        }
Пример #9
0
        private void RegistroExportacion_Load(object sender, EventArgs e)
        {
            Lotes lotes = new Lotes();

            LoteIdcomboBox.DataSource    = lotes.Listar("*", "1=1", "");
            LoteIdcomboBox.DisplayMember = "CodigoLote";
            LoteIdcomboBox.ValueMember   = "LoteId";
            addlotes = LoteIdcomboBox.Text;


            DestinosIdcomboBox.DataSource    = destinos.Listar("DestinoId, NombreDestino", "1=1", "");
            DestinosIdcomboBox.DisplayMember = "NombreDestino";
            DestinosIdcomboBox.ValueMember   = "DestinoId";
        }
Пример #10
0
        private void button3_Click(object sender, EventArgs e)
        {
            //LotesdataGridView.Items.Add(LoteIdcomboBox.Text);
            Lotes     lotes = new Lotes();
            DataTable dt    = new DataTable();

            lotes.Buscar((int)LoteIdcomboBox.SelectedValue);
            this.LotesdataGridView.Rows.Add(LoteIdcomboBox.SelectedValue.ToString(), lotes.Total.ToString());

            double.TryParse(PreciotextBox.Text, out precio);
            total += lotes.Total * precio;

            TotaltextBox.Text = total.ToString();

            total = Monto;
        }
Пример #11
0
        private void Buscarbutton_Click(object sender, EventArgs e)
        {
            Lotes       lote        = new Lotes();
            Exportacion exportacion = new Exportacion();

            int.TryParse(ExportacionIdtextBox.Text, out idbuscado);
            lote.ExportacionId = idbuscado;
            lote.Buscar(idbuscado);

            exportacion.Fecha = FechadateTimePicker.Text;

            foreach (var item in exportacion.Lotes)
            {
                LotesdataGridView.Rows.Add(item.CodigoLote);
            }
        }
Пример #12
0
        /**
         * @fn  public bool existeLote(Lote pLote)
         *
         * @brief   Si existe el lote en el sistema.
         *
         * @author  WINMACROS
         * @date    17/07/2017
         *
         * @param   pLote   Lote.
         *
         * @return  True si existe, false si no.
         */

        public bool existeLote(Lote pLote)
        {
            bool ret  = false;
            int  cont = 0;

            while (cont < Lotes.Count && !ret)
            {
                Lote loteActual = Lotes.ElementAt(cont);
                if (pLote.Equals(loteActual))
                {
                    ret = true;
                }
                cont++;
            }
            return(ret);
        }
Пример #13
0
        /**
         * @fn  private void precarga()
         *
         * @brief   Precarga las listas del sistema.
         *
         * @author  WINMACROS
         * @date    17/07/2017
         */

        private void precarga()
        {
            baseDatos        bd = baseDatos.Bd;
            Automatizaciones a  = Automatizaciones.A;
            // bd.Prueba();
            //a.activosSms();
            List <Marcador> mar = bd.cargarMarcadores();

            Marcadores.AddRange(mar);

            List <Lote> lotess = bd.cargaLotesUnaSemana();

            Lotes.AddRange(lotess);
            accionesCodigo("Precarga la fecha del Score", bd.precargaFecha().ToString());
            tolls.FechaScore = bd.precargaFecha();
        }
Пример #14
0
        private void Guardarbutton_Click(object sender, EventArgs e)
        {
            BLL.Exportacion exportacion = new BLL.Exportacion();

            if (ExportacionIdtextBox.Text.Length == 0)
            {
                exportacion.Fecha     = FechadateTimePicker.Text;
                exportacion.DestinoId = (int)DestinosIdcomboBox.SelectedValue;
                exportacion.Resumen   = ResumenrichTextBox.Text;
                double.TryParse(TotaltextBox.Text, out Monto);
                exportacion.Monto = Monto;


                for (int i = 0; i < LotesdataGridView.Rows.Count; i++)
                {
                    Lotes lotes = new Lotes();
                    lotes.LoteId = (int)LoteIdcomboBox.SelectedValue;
                    exportacion.AgregarLotes(lotes.LoteId, LotesdataGridView.Rows[i].ToString());
                }
                if (exportacion.Insertar())
                {
                    MessageBox.Show("El producto esta listo para exportarce");
                }
                else
                {
                    MessageBox.Show("No se han guardado los datos!");
                }
            }
            else
            {
                int.TryParse(ExportacionIdtextBox.Text, out exportacionId);
                exportacion.ExportacionId = exportacionId;
                exportacion.Fecha         = FechadateTimePicker.Text;
                exportacion.ExportacionId = (int)DestinosIdcomboBox.SelectedValue;
                exportacion.Resumen       = ResumenrichTextBox.Text;


                if (exportacion.Editar())
                {
                    MessageBox.Show("Se han actualizado los datos!");
                }
                else
                {
                    MessageBox.Show("No se han guardado los datos!");
                }
            }
        }
Пример #15
0
        /**
         * @fn  public resultAgregarLote agregarLote(Lote pLote)
         *
         * @brief   Validador al momento de agregar un lote al sistema.
         *
         * @author  WINMACROS
         * @date    17/07/2017
         *
         * @param   pLote   Lote a validar.
         *
         * @return  Resultado de validacion.
         */

        public resultAgregarLote agregarLote(Lote pLote)
        {
            tolls             t   = tolls.T;
            resultAgregarLote ret = resultAgregarLote.agrego;

            Lote.tipoLote tipoLoteXNom = t.tipoLoteXNombreArchivo(pLote.Exc.Direccion);
            bool          excel        = pLote.Exc.validarExcel();

            if (!excel)
            {
                ret = resultAgregarLote.excelDeficiente;
            }
            else if (pLote.Exc.Direccion.Extencion != ".csv")
            {
                ret = resultAgregarLote.errorEnExtencion;
            }
            else if (tipoLoteXNom == Lote.tipoLote.errorCampana)
            {
                ret = resultAgregarLote.nombreMalEscrito;
            }
            else if (tipoLoteXNom != pLote.LoteTipo)
            {
                ret = resultAgregarLote.nombreDistintoCampana;
            }
            else if (pLote.Nombre.Length > 32)
            {
                ret = resultAgregarLote.nombreLargo;
            }
            else if (!pLote.asignarMarcador())
            {
                ret = resultAgregarLote.noExisteCampanaSistema;
            }
            else if (existeLote(pLote))
            {
                ret = resultAgregarLote.elLoteYaExiste;
            }
            else
            {
                Lotes.Add(pLote);
            }
            accionesCodigo("Se intenta cargar el lote:" + pLote.ToString() + " Al sistema. ", ret.ToString());
            return(ret);
        }
        // GET: LotesComidas/Create
        public ActionResult Create()
        {
            List <Opciones> lstOpciones = new List <Opciones>();
            Opciones        objOpcion   = new Opciones();

            objOpcion.OpcionId    = -1;
            objOpcion.Codigopcion = "-- Seleccione --";
            lstOpciones.Add(objOpcion);
            lstOpciones.AddRange(db.Opciones.Where(O => O.TipoOpcion == "CuidoCerdos").ToList());
            ViewBag.OpcionId = new SelectList(lstOpciones, "OpcionId", "Codigopcion");

            List <Lotes> lstLotes = new List <Lotes>();
            Lotes        objLote  = new Lotes();

            objLote.LoteId     = -1;
            objLote.NombreLote = "-- Seleccione --";
            lstLotes.Add(objLote);
            lstLotes.AddRange(db.Lotes);
            ViewBag.LoteId = new SelectList(lstLotes, "LoteId", "NombreLote");

            return(View());
        }
Пример #17
0
 private void ButtonEditar_Click(object sender, RoutedEventArgs e)
 {
     if (TextLotesId.Text != "")
     {
         string     resp   = "";
         ClassLotes Logica = new ClassLotes();
         Lotes      INFO   = new Lotes();
         INFO.Id_Lotes         = Convert.ToInt32(this.TextLotesId.Text);
         INFO.Descripcion      = TextDescripcion.Text;
         INFO.Cantidad         = int.Parse(TextCantidad.Text);
         INFO.Fecha_Caducidad  = DateTime.Parse(TextFechaCaducidad.Text);
         INFO.Fecha_Produccion = DateTime.Parse(TextFechaProduccion.Text);
         INFO.Productos_Id     = Convert.ToInt32(this.TextProductos_Id.Text);
         resp = Logica.ActualizaLotes(INFO);
         MessageBox.Show(resp);
     }
     else
     {
         MessageBox.Show("Marque el registro a modificar", "Error al Editar",
                         MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
     }
 }
Пример #18
0
        public ActionResult Index(int?AnimalId, AnimalMessageId?message, bool?ApresentaBusca)
        {
            ViewBag.StatusMessage =
                message == AnimalMessageId.AddSuccess ? "Animal adicionado com sucesso."
                    : message == AnimalMessageId.DisableSucess ? "Animal desabilitado com sucesso."
                    : message == AnimalMessageId.Error ? "Ocorreu um erro durante a operação. Tente novamente mais tarde."
                    : "";

            if (ApresentaBusca.HasValue && ApresentaBusca.Value)
            {
                ViewBag.ApresentaBusca = true;
            }
            else
            {
                ViewBag.ApresentaBusca = false;
                ViewBag.AnimalExiste   = AnimalId.HasValue && AnimalId.Value > 0;
                if (ViewBag.AnimalExiste)
                {
                    return(View(Animal.Get(AnimalId.Value)));
                }
                else
                {
                    Lotes lotes            = Lotes.List(Helpers.Current.FazendaId);
                    Lotes lotesDisponiveis = new Lotes();
                    foreach (Lote l in lotes)
                    {
                        if (LoteController._QtdMaxAnimais > Lote.GetQtnAnimais(l.Id))
                        {
                            lotesDisponiveis.Add(l);
                        }
                    }
                    ViewBag.LotesDisponiveis = lotesDisponiveis;
                }
            }
            return(View());
        }
 public long ObtenerStockActualArticulo()
 {
     return(Lotes.Sum(x => x.Cantidad));
 }
Пример #20
0
 public void Add(Lote item)
 {
     Lotes.Add(item);
 }
Пример #21
0
 private void LotesAddExecute()
 {
     Lotes.Add(new IngresoPorLote());
 }
        public async Task <ActionResult> Create(LotesComida lotesComida)
        {
            List <Opciones> lstOpciones = new List <Opciones>();
            Opciones        objOpcion   = new Opciones();
            List <Lotes>    lstLotes    = new List <Lotes>();
            Lotes           objLote     = new Lotes();

            if (ModelState.IsValid)
            {
                if (lotesComida.LoteId == -1 || lotesComida.OpcionId == 1)
                {
                    objOpcion.OpcionId    = -1;
                    objOpcion.Codigopcion = "-- Seleccione --";
                    lstOpciones.Add(objOpcion);
                    lstOpciones.AddRange(db.Opciones.Where(O => O.TipoOpcion == "CuidoCerdos").ToList());
                    ViewBag.OpcionId = new SelectList(lstOpciones, "OpcionId", "Codigopcion");

                    objLote.LoteId     = -1;
                    objLote.NombreLote = "-- Seleccione --";
                    lstLotes.Add(objLote);
                    lstLotes.AddRange(db.Lotes);
                    ViewBag.LoteId = new SelectList(lstLotes, "LoteId", "NombreLote");

                    return(View(lotesComida));
                }

                lotesComida.FechaSLoteComida = lotesComida.FechaLoteComida.ToString("yyyy-MM-dd");

                MemoryStream stream1           = new MemoryStream();
                DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(LotesComida));
                ser.WriteObject(stream1, lotesComida);
                stream1.Position = 0;
                StreamReader     sr        = new StreamReader(stream1);
                String           Resultado = sr.ReadToEnd();
                List <Respuesta> Respuesta = new List <Respuesta>();

                using (LocalDataContext db = new LocalDataContext())
                {
                    Respuesta = db.Database.SqlQuery <Respuesta>(Sp.uspLotesComidaIndividualInsertar + " @json", new SqlParameter("json", Resultado)).ToList();
                }

                if (Respuesta[0].Codigo == 1)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    objOpcion.OpcionId    = -1;
                    objOpcion.Codigopcion = "-- Seleccione --";
                    lstOpciones.Add(objOpcion);
                    lstOpciones.AddRange(db.Opciones.Where(O => O.TipoOpcion == "CuidoCerdos").ToList());
                    ViewBag.OpcionId = new SelectList(lstOpciones, "OpcionId", "Codigopcion", lotesComida.OpcionId);

                    objLote.LoteId     = -1;
                    objLote.NombreLote = "-- Seleccione --";
                    lstLotes.Add(objLote);
                    lstLotes.AddRange(db.Lotes);
                    ViewBag.LoteId = new SelectList(lstLotes, "LoteId", "NombreLote", lotesComida.LoteId);

                    TempData["testmsg"] = Respuesta[0].Descripcion;

                    return(View());
                }
            }

            objOpcion.OpcionId    = -1;
            objOpcion.Codigopcion = "-- Seleccione --";
            lstOpciones.Add(objOpcion);
            lstOpciones.AddRange(db.Opciones.Where(O => O.TipoOpcion == "CuidoCerdos").ToList());
            ViewBag.OpcionId = new SelectList(lstOpciones, "OpcionId", "Codigopcion", lotesComida.OpcionId);

            objLote.LoteId     = -1;
            objLote.NombreLote = "-- Seleccione --";
            lstLotes.Add(objLote);
            lstLotes.AddRange(db.Lotes);
            ViewBag.LoteId = new SelectList(lstLotes, "LoteId", "NombreLote", lotesComida.LoteId);

            TempData["testmsg"] = null;

            return(View());
        }
Пример #23
0
 public virtual void AgregarLote(Lote lote)
 {
     lote.NoEsNull(nameof(lote));
     lote.Inventario = this;
     Lotes.Add(lote);
 }
Пример #24
0
 private void LotesRemoveExecute()
 {
     Lotes.RemoveAt(Lotes.Count - 1);
 }
Пример #25
0
        private async void GuardarExecuteAsync()
        {
            using (SqlConnection conn = new SqlConnection((App.Current as App).ConnectionString)) {
                using (SqlCommand cmd = new SqlCommand()) {
                    cmd.Connection  = conn;
                    cmd.CommandType = CommandType.Text;

                    // Ingreso por lote
                    cmd.CommandText = @"INSERT INTO IngresoPorLote VALUES (@Semana, @Lote, @Cantidad, @Dia, 
                                        @Descabece, @SaleKFC, @SalePie, @Incubadora, @Saldo)";
                    conn.Open();
                    foreach (IngresoPorLote i in Lotes)
                    {
                        cmd.Parameters.AddWithValue("@Semana", Semana);
                        cmd.Parameters.AddWithValue("@Lote", i.Lote);
                        cmd.Parameters.AddWithValue("@Cantidad", i.Cantidad);
                        cmd.Parameters.AddWithValue("@Dia", i.Dia);
                        cmd.Parameters.AddWithValue("@Descabece", i.Descabece);
                        cmd.Parameters.AddWithValue("@SaleKFC", i.SaleKFC);
                        cmd.Parameters.AddWithValue("@SalePie", i.SalePie);
                        cmd.Parameters.AddWithValue("@Incubadora", i.Incubadora);
                        cmd.Parameters.AddWithValue("@Saldo", i.Saldo);
                        cmd.ExecuteNonQuery();
                        cmd.Parameters.Clear();
                    }

                    // Ventas
                    cmd.CommandText = @"INSERT INTO Venta VALUES (@Semana, @Cliente, @Cantidad)";
                    foreach (Venta i in Ventas)
                    {
                        cmd.Parameters.AddWithValue("@Semana", Semana);
                        cmd.Parameters.AddWithValue("@Cliente", i.Cliente);
                        cmd.Parameters.AddWithValue("@Cantidad", i.Cantidad);
                        cmd.ExecuteNonQuery();
                        cmd.Parameters.Clear();
                    }

                    // Otros
                    cmd.CommandText = @"INSERT INTO Global VALUES 
                                        (@Semana, @Ingreso, @IngresoEdit, @Mortalidad, @MortalidadEdit, 
                                        @Precio, @PrecioEdit, @Venta, @VentaEdit, @Liquidacion, @LiquidacionEdit)";
                    cmd.Parameters.AddWithValue("@Semana", Semana);
                    cmd.Parameters.AddWithValue("@Ingreso", Lotes.Sum(item => item.Cantidad));
                    cmd.Parameters.AddWithValue("@IngresoEdit", SqlDbType.Bit).Value = false;
                    cmd.Parameters.AddWithValue("@Mortalidad", Mortalidad);
                    cmd.Parameters.AddWithValue("@MortalidadEdit", SqlDbType.Bit).Value = false;
                    cmd.Parameters.AddWithValue("@Precio", Precio);
                    cmd.Parameters.AddWithValue("@PrecioEdit", SqlDbType.Bit).Value = false;
                    cmd.Parameters.AddWithValue("@Venta", Ventas.Sum(item => item.Cantidad));
                    cmd.Parameters.AddWithValue("@VentaEdit", SqlDbType.Bit).Value = false;
                    cmd.Parameters.AddWithValue("@Liquidacion", Liquidacion);
                    cmd.Parameters.AddWithValue("@LiquidacionEdit", SqlDbType.Bit).Value = false;
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }
            }
            await ShowContentDialogAsync("Crear Semana", "La semana " + Semana + " ha sido creada.");

            Semana = "00-0000";
            Lotes.Clear();
            Ventas.Clear();
            Liquidacion = 0;
            Mortalidad  = 6;
            Precio      = 0;
        }
Пример #26
0
        }//VENDER

        public void comprar(Lote lote)
        {
            Lotes.Enqueue(lote);
        }
        public static void GenerarRecepcion(DataGridView dataGridCompras, string cveDoc, int numEmpresa, RNPedimento pedimento)
        {
            try
            {
                List <Lotes> lotes = new List <Lotes>();
                // se obtiene el folio y la clave de la Recepción
                int    folio          = 0;
                string cveDocRecpcion = GenerarRecepcion("r", null, numEmpresa, out folio);
                List <RNPartidasRecepcion> partidas = new List <RNPartidasRecepcion>();
                // se crea el documento de recepción y sus partidas
                //registrar cabecera y patidas
                RNOrdenRecepcion recepcion = new RNOrdenRecepcion().GenerarRecepcion(cveDoc, cveDocRecpcion, folio, numEmpresa, out partidas);


                for (int fila = 0; fila < dataGridCompras.Rows.Count; fila++)
                {
                    for (int col = 8; col < dataGridCompras.Rows[fila].Cells.Count; col = col + 2)
                    {
                        if (lotes.Any(x => x.lote == dataGridCompras.Rows[fila].Cells[col].Value.ToString()))
                        {
                            foreach (var l in lotes)
                            {
                                if (l.lote == dataGridCompras.Rows[fila].Cells[col].Value.ToString())
                                {
                                    l.contador++;
                                }
                            }
                        }
                        else
                        {
                            Lotes lotes1 = new Lotes();
                            lotes1.articulo  = dataGridCompras.Rows[fila].Cells[6].Value.ToString();
                            lotes1.contador  = 1;
                            lotes1.lote      = dataGridCompras.Rows[fila].Cells[col].Value.ToString();
                            lotes1.caducidad = Convert.ToDateTime(dataGridCompras.Rows[fila].Cells[col + 1].Value.ToString());
                            lotes1.partida   = Convert.ToInt32(dataGridCompras.Rows[fila].Cells[0].Value.ToString());
                            lotes.Add(lotes1);
                        }
                    }
                }
                foreach (var l in lotes)
                {
                    if (ValidarLote(l.lote, pedimento.numPedimento, numEmpresa))
                    {
                        l.reg_ltpd        = AgregarLote(l.lote, pedimento, l.articulo, l.caducidad, l.contador, 1, "A", DateTime.Now, numEmpresa);
                        l.reg_ltpd_Enlace = RNLbInventory.RegistrarEnlace(l.reg_ltpd, l.contador, numEmpresa);
                        l.minve_id        = RNLbInventory.RegistrarMovInveRecepcion(partidas.Where(x => x.NUM_PAR == l.partida).FirstOrDefault(), recepcion, l.reg_ltpd_Enlace, 1, numEmpresa);
                    }
                    else
                    {
                        l.reg_ltpd        = ActualizarLote(l.lote, pedimento.numPedimento, l.articulo, l.caducidad, l.contador, 1, "A", DateTime.Now, numEmpresa);
                        l.reg_ltpd_Enlace = RNLbInventory.RegistrarEnlace(l.reg_ltpd, l.contador, numEmpresa);
                        l.minve_id        = RNLbInventory.RegistrarMovInveRecepcion(partidas.Where(x => x.NUM_PAR == l.partida).FirstOrDefault(), recepcion, l.reg_ltpd_Enlace, 1, numEmpresa);
                    }

                    RNPartidasRecepcion.ActualizarPartida(recepcion.CVE_DOC, l.partida, l.reg_ltpd_Enlace, l.minve_id, numEmpresa);
                    RNLbInventory.ActualizarExistencias(partidas.Where(x => x.NUM_PAR == l.partida).FirstOrDefault().CVE_ART, recepcion.NUM_ALMA, 1, partidas.Where(x => x.NUM_PAR == l.partida).FirstOrDefault().CANT, numEmpresa);
                }
                if (RNLbInventory.ObtenerImportadora().NumEmpresa == numEmpresa)
                {
                    RNRemision.GenerarRemision(recepcion, partidas, lotes);
                    GenerarRecepcionComercializadora(recepcion, partidas, lotes, pedimento);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error al generar la recepción:  " + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }