public int insertarRegistro(ref Ent_twhcol010 parametrosIn, ref string strError)
        {
            int retorno = -1;

            try
            {
                retorno = dal.insertarRegistro(ref parametrosIn, ref strError);
                return(retorno);
            }
            catch (Exception ex)
            {
                throw new Exception(strError += "\nPila: " + ex.Message);
            }
        }
Beispiel #2
0
        private List <Ent_ParametrosDAL> AdicionaParametrosComunes(Ent_twhcol010 parametros, bool blnUsarPRetorno = false)
        {
            method = MethodBase.GetCurrentMethod();
            string strError = string.Empty;
            List <Ent_ParametrosDAL> parameterCollection = new List <Ent_ParametrosDAL>();

            try
            {
                Ent_ParametrosDAL.AgregaParametro(ref parameterCollection, ":T$CLOT", DbType.String, parametros.clot);
                Ent_ParametrosDAL.AgregaParametro(ref parameterCollection, ":T$SQNB", DbType.Int32, parametros.sqnb);
                Ent_ParametrosDAL.AgregaParametro(ref parameterCollection, ":T$MITM", DbType.String, parametros.mitm);
                Ent_ParametrosDAL.AgregaParametro(ref parameterCollection, ":T$DSCA", DbType.String, parametros.dsca);
                Ent_ParametrosDAL.AgregaParametro(ref parameterCollection, ":T$CWOR", DbType.String, parametros.cwor);
                Ent_ParametrosDAL.AgregaParametro(ref parameterCollection, ":T$LOOR", DbType.String, parametros.loor);
                Ent_ParametrosDAL.AgregaParametro(ref parameterCollection, ":T$CWDE", DbType.String, parametros.cwde);
                Ent_ParametrosDAL.AgregaParametro(ref parameterCollection, ":T$LODE", DbType.String, parametros.lode);
                Ent_ParametrosDAL.AgregaParametro(ref parameterCollection, ":T$QTDL", DbType.Double, Convert.ToDecimal(parametros.qtdl));
                Ent_ParametrosDAL.AgregaParametro(ref parameterCollection, ":T$CUNI", DbType.String, parametros.cuni);
                Ent_ParametrosDAL.AgregaParametro(ref parameterCollection, ":T$USER", DbType.String, parametros.user);
                Ent_ParametrosDAL.AgregaParametro(ref parameterCollection, ":T$REFCNTD", DbType.Int32, parametros.refcntd);
                Ent_ParametrosDAL.AgregaParametro(ref parameterCollection, ":T$REFCNTU", DbType.Int32, parametros.refcntu);

                if (blnUsarPRetorno)
                {
                    Ent_ParametrosDAL pDal = new Ent_ParametrosDAL();
                    pDal.Name         = "@p_Int_Resultado";
                    pDal.Type         = DbType.Int32;
                    pDal.ParDirection = ParameterDirection.Output;
                    parameterCollection.Add(pDal);
                }
            }
            catch (Exception ex)
            {
                strError = "Error when creating parameters [301]. Try again or contact your administrator \n";
                log.escribirError(strError + Console.Out.NewLine + ex.Message, stackTrace.GetFrame(1).GetMethod().Name, method.Name, method.ReflectedType.Name);
            }
            return(parameterCollection);
        }
Beispiel #3
0
        public int insertarRegistro(ref Ent_twhcol010 parametro, ref string strError)
        {
            method = MethodBase.GetCurrentMethod();
            bool retorno = false;

            try
            {
                strSentencia = recursos.readStatement(method.ReflectedType.Name, method.Name, ref owner, ref env, tabla);

                parametrosIn = AdicionaParametrosComunes(parametro);
                retorno      = DAL.BaseDAL.BaseDal.EjecutarCrud("text", strSentencia, ref parametersOut, parametrosIn, false);

                return(Convert.ToInt32(retorno));
            }

            catch (Exception ex)
            {
                strError = ex.InnerException != null ?
                           ex.Message + " (" + ex.InnerException + ")" :
                           ex.Message;
            }

            return(Convert.ToInt32(retorno));
        }
        protected void btnActualizar_Click(object sender, EventArgs e)
        {
            lblConfirm.Text = String.Empty;
            lblError.Text   = String.Empty;
            var txtCantidadTransferir = txtCantidadTrasnferir.Text.Trim();
            var ubicacionDestino      = txtUbicacionDestino.Text.Trim().ToUpper();
            var cwar = txtSourceLocation.Text.Trim().ToUpper();
            var clot = txtNumeroLote.Text.Trim().ToUpper();

            if (txtCantidadTransferir == String.Empty || ubicacionDestino == String.Empty)
            {
                lblError.Text = mensajes("formempty");
                return;
            }

            var cantidadTransferir = double.Parse(txtCantidadTransferir, CultureInfo.InvariantCulture.NumberFormat);

            if (cantidadTransferir == 0)
            {
                lblError.Text = mensajes("quantityzero");
                return;
            }

            if (ubicacionDestino == txtSourceLocation.Text.Trim().ToUpper())
            {
                lblError.Text = mensajes("differentlocation");
                return;
            }

            var validaUbicacion = _idaltwhwmd300.validateExistsLocation(ref ubicacionDestino, ref cwar, ref strError).Rows;

            if (validaUbicacion.Count > 0)
            {
                var loct           = Convert.ToInt32(validaUbicacion[0]["LOCT"].ToString());
                var btrr           = Convert.ToInt32(validaUbicacion[0]["BTRR"].ToString());
                var cantdisponible = double.Parse(txtCantidad.Text.Trim(), CultureInfo.InvariantCulture.NumberFormat);

                if (loct != 5)
                {
                    lblError.Text = String.Format(mensajes("locationdesnotload"), ubicacionDestino);
                    return;
                }

                if (btrr != 2)
                {
                    lblError.Text = String.Format(mensajes("locationdesblocked"), ubicacionDestino);;
                    return;
                }

                if (cantidadTransferir > cantdisponible)
                {
                    lblError.Text = String.Format(mensajes("quantitytransfer"), cantidadTransferir, cantdisponible);
                    return;
                }

                var consecutivo = _idaltwhcol010.consultarConsecutivoRegistro(ref clot, ref strError);

                consecutivo = consecutivo + 1;

                Ent_twhcol010 data010 = new Ent_twhcol010()
                {
                    clot    = clot,
                    sqnb    = consecutivo,
                    mitm    = txtItem.Text.Trim().ToUpper(),
                    dsca    = txtDescription.Text.Trim().ToUpper(),
                    cwor    = txtSourceLocation.Text.Trim().ToUpper(),
                    loor    = txtUbicacion.Text.Trim().ToUpper(),
                    cwde    = txtSourceLocation.Text.Trim().ToUpper(),
                    lode    = txtUbicacionDestino.Text.Trim().ToUpper(),
                    qtdl    = double.Parse(txtCantidadTrasnferir.Text.Trim(), CultureInfo.InvariantCulture.NumberFormat),
                    cuni    = txtCantidadUnidad.Text.Split('-').Last().Trim(),
                    user    = HttpContext.Current.Session["user"].ToString(),
                    refcntd = 0,
                    refcntu = 0
                };

                var validSave = _idaltwhcol010.insertarRegistro(ref data010, ref strError);

                if (validSave > 0)
                {
                    lblConfirm.Text = mensajes("msjsave");

                    trDescription.Visible        = false;
                    trSource.Visible             = false;
                    trUbicacion.Visible          = false;
                    trCantidadUnidad.Visible     = false;
                    trCantidad.Visible           = false;
                    trDestination.Visible        = false;
                    trCantidadTransferir.Visible = false;
                    txtNumeroLote.Enabled        = true;
                    txtItem.Enabled = true;

                    txtNumeroLote.Text = String.Empty;
                    txtItem.Text       = String.Empty;

                    btnConsultar.Visible       = true;
                    btnConsultarSource.Visible = false;
                    btnActualizar.Visible      = false;

                    return;
                }
                else
                {
                    lblError.Text = mensajes("errorsave");
                    return;
                }
            }
            else
            {
                lblError.Text = mensajes("locationnotexists");
                return;
            }
        }
        protected void btnTransfer_Click(object sender, EventArgs e)
        {
            if (txtItem.Text.Trim() == String.Empty || txtTargetLocation.Text.Trim() == String.Empty || txtTargetQty.Text.Trim() == String.Empty)
            {
                lblError.Text = mensajes("formempty");
                return;
            }

            if (_tipoFormulario == "TO" && slPlant.SelectedValue.Trim() == String.Empty)
            {
                lblError.Text = mensajes("formempty");
                return;
            }

            var item = txtItem.Text.Trim().ToUpper();
            var loca = txtTargetLocation.Text.Trim().ToUpper();
            var qtdl = double.Parse(txtTargetQty.Text.Trim(), CultureInfo.InvariantCulture.NumberFormat);

            //Buscar datos del articulo
            Ent_ttcibd001 data001 = new Ent_ttcibd001()
            {
                item = item
            };
            var datosArticulo = _idalttcibd001.listaRegistro_ObtieneDescripcionUnidad(ref data001, ref strError);

            if (datosArticulo.Rows.Count <= 0)
            {
                lblError.Text = mensajes("itemnotexists");
                return;
            }

            var dscaitem = datosArticulo.Rows[0]["DESCRIPCION"].ToString();
            var cuni     = datosArticulo.Rows[0]["UNID"].ToString();

            //Buscar almacen de la ubicación+
            var loct           = "5";
            var btrr           = "2";
            var datosUbicacion = _idaltwhwmd300.findLocationByLoctAndBtrr(ref loct, ref btrr, ref loca, ref strError);

            if (datosUbicacion.Rows.Count <= 0)
            {
                lblError.Text = String.Format(mensajes("targetlocation"), loca);
                return;
            }

            var cwar = datosUbicacion.Rows[0]["CWAR"].ToString();

            //Valida si ya existe registro
            var consecutivo = _tipoFormulario == "TO" ? _idaltwhcol010.consultarConsecutivoMaximo(ref strError)
                : _idaltwhcol010.consultarConsecutivoMaximo(ref strError); //_idaltwhcol010.consultarConsecutivoRegistroPorItem(ref item, ref loca, ref strError);

            consecutivo = consecutivo + 1;

            Ent_twhcol010 data010 = new Ent_twhcol010()
            {
                clot    = " ",
                sqnb    = consecutivo,
                mitm    = item,
                dsca    = dscaitem,
                cwor    = _tipoFormulario == "TO" ? slPlant.SelectedValue.Trim().ToUpper() : cwar,
                loor    = " ",
                cwde    = cwar,
                lode    = loca,
                qtdl    = qtdl,
                cuni    = cuni,
                user    = HttpContext.Current.Session["user"].ToString(),
                refcntd = 0,
                refcntu = 0
            };

            var validInsert = _idaltwhcol010.insertarRegistro(ref data010, ref strError);

            if (validInsert > 0)
            {
                lblError.Text          = String.Empty;
                lblConfirm.Text        = mensajes("msjsave");
                txtItem.Text           = String.Empty;
                txtTargetLocation.Text = String.Empty;
                txtTargetQty.Text      = String.Empty;
                return;
            }
            else
            {
                lblError.Text = mensajes("errorsave");
                return;
            }
        }