示例#1
0
        //public int actualizarInfoCliente(Ent_tticol125 parametros)
        //{
        //    int i2;

        //    int i1 = 0;
        //    InterfazDAL_tticol125 interfazDAL = new InterfazDAL_tticol125();
        //    try
        //    {
        //        i1 = interfazDAL.actualizarInfoCliente(parametros, ref strError, Aplicacion);
        //        strError = "Actualizar Informacion del cliente";
        //        interfazDAL.guardaErrores(ref strError, Aplicacion);
        //        strError = System.String.Empty;
        //        i2 = i1;
        //    }
        //    catch (System.TimeoutException e1)
        //    {
        //        throw new System.Exception(e1.StackTrace);
        //    }
        //    catch (System.Exception e2)
        //    {
        //        strError = strError + "| - |" + e2.Message.ToString();
        //        interfazDAL.guardaErrores(ref strError, Aplicacion);
        //        throw new System.Exception(strError);
        //    }
        //    return i2;
        //}

        public System.Collections.Generic.List <Ent_tticol125> enviaDatos(List <Ent_tticol125> parametros)
        {
            List <Ent_tticol125> list;

            int i = 1;
            List <Ent_tticol125>  list1       = new System.Collections.Generic.List <Ent_tticol125>();
            InterfazDAL_tticol125 interfazDAL = new InterfazDAL_tticol125();

            try
            {
                strError = "CREAR tticol125";
                i        = interfazDAL.insertarRegistro(ref parametros, ref strError, Aplicacion);
                strError = "Recuperar CalenDario";
                interfazDAL.guardaErrores(ref strError, Aplicacion);
                strError = System.String.Empty;
                if ((i > 0) && System.String.IsNullOrEmpty(strError))
                {
                    strError = "Recuperar tticol125 Sentencia";
                    interfazDAL.guardaErrores(ref strError, Aplicacion);
                    strError = System.String.Empty;
                    // list1 = recuperarClientes(ref parametros);
                }
                else if (strError != System.String.Empty)
                {
                    interfazDAL.guardaErrores(ref strError, Aplicacion);
                    throw new System.Exception(strError);
                }
                list = list1;
            }
            catch (System.TimeoutException e1)
            {
                throw new System.Exception(e1.StackTrace);
            }
            catch (System.Exception e2)
            {
                strError += e2.Message.ToString();
                interfazDAL.guardaErrores(ref strError, Aplicacion);
                throw new System.Exception(strError);
            }
            return(list);
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Session["save"] == null)
            {
                Session["save"] = true;
                List <Ent_tticol125> parameterCollection = new List <Ent_tticol125>();
                Ent_tticol125        obj = new Ent_tticol125();
                //Recorrer filas con valores en los textos
                Session["WorkOrder"] = txtWorkOrder.Text.Trim();

                //string vpaid = validaPalletID("OPI009584-001", 1);
                String a = string.Empty;
                foreach (GridViewRow row in grdRecords.Rows)
                {
                    string paid     = string.Empty;
                    string sec      = string.Empty;
                    int    sec022   = 0;
                    string toreturn = ((TextBox)row.Cells[4].FindControl("toReturn")).Text;
                    string toLot    = ((DropDownList)row.Cells[6].FindControl("toLot")).SelectedValue;
                    //string palletId = ((TextBox)row.Cells[9].FindControl("palletId")).Text;
                    string condLote = ((HiddenField)row.Cells[4].FindControl("LOTE")).Value.Trim();
                    ktlc = Convert.ToString(row.Cells[9].Text);
                    Item = row.Cells[0].Text.ToUpperInvariant();
                    //JC 180821 Tomar la bodega del maestro de artículos
                    HttpContext.Current.Session["ITEM"] = Item;
                    var Warehouse = Itwhcol130.GetWarehouseMaterialReturn(HttpContext.Current.Session["ITEM"].ToString());

                    Uni = row.Cells[3].Text.ToLower().Trim();
                    //JC 061221 Como ya no se tiene posición se define fija la posicíón 10
                    //Pos = row.Cells[0].Text;
                    Pos   = "10";
                    Tipo  = row.Cells[10].Text;
                    Clase = row.Cells[11].Text.ToUpperInvariant().Trim();

                    bool reqLote = condLote == "1" ? true : false;

                    //if (myObj.CUNI.Trim().ToUpper() != "PLT")
                    //{
                    //    MyConvertionFactor = FactorConversion(myObj.ITEM, myObj.CUNI, "PLT");
                    //    QUANTITYPLT = (MyConvertionFactor.Tipo == "Div") ? Convert.ToDecimal((QUANTITYCUNI * MyConvertionFactor.FactorB) / MyConvertionFactor.FactorD) : Convert.ToDecimal((QUANTITYCUNI * MyConvertionFactor.FactorD) / MyConvertionFactor.FactorB);
                    //    ciclosADVS = Convert.ToInt32(Math.Ceiling(QUANTITYPLT));
                    //}

                    //if (palletId.Trim() == string.Empty)
                    //{
                    //    lblResult.Text = RecordswithoutIDpallet;
                    //    lblResult.ForeColor = System.Drawing.Color.Red;
                    //    return;
                    //}
                    if ((reqLote && String.IsNullOrEmpty(toLot.Trim())) && !string.IsNullOrEmpty(toreturn))
                    {
                        lblResult.Text      = mensajes("lotcode");
                        lblResult.ForeColor = System.Drawing.Color.Red;
                        Session["save"]     = null;
                        return;
                    }

                    //string toreturn = ((TextBox)row.Cells[6].FindControl("toReturn")).Text;
                    //string toLot = ((TextBox)row.Cells[8].FindControl("toLot")).Text;

                    int tabla022 = 0;
                    int tabla042 = 0;
                    int tabla131 = 0;

                    if (!toreturn.Equals(string.Empty))
                    {
                        if (Tipo == "2")
                        {
                            if (Clase != "RET")
                            {
                                tabla022 = 1;
                                tabla042 = 0;
                                tabla131 = 0;
                            }
                            else
                            {
                                tabla042 = 1;
                                tabla022 = 0;
                                tabla131 = 0;
                            }
                        }
                        else
                        {
                            tabla131 = 1;
                            tabla022 = 0;
                            tabla042 = 0;
                        }

                        DataTable dt022 = Itticol022.SecuenciaMayorRT(txtWorkOrder.Text.Trim().ToUpperInvariant());
                        if (dt022.Rows.Count > 0)
                        {
                            paid   = dt022.Rows[0]["T$SQNB"].ToString().Trim().ToUpper();;
                            sec    = paid.Substring(12, 2);
                            sec022 = Convert.ToInt32(sec);
                            sec    = addZero(sec022 + 1);
                        }
                        else
                        {
                            sec = "01";
                        }

                        if (tabla131 == 1)
                        {
                            Ent_twhcol130131 obj131 = new Ent_twhcol130131();
                            Ent_twhcol130131 MyObj  = new Ent_twhcol130131();

                            MyObj.OORG = "4";
                            MyObj.ORNO = txtWorkOrder.Text.Trim().ToUpper();
                            MyObj.ITEM = row.Cells[0].Text.ToUpper();
                            MyObj.PAID = txtWorkOrder.Text.Trim().ToUpper() + "-RT" + sec;
                            //JC 061221 Como ya no se tiene posición se define fija la posicíón 10
                            //MyObj.PONO = Convert.ToInt32(row.Cells[0].Text).ToString();
                            MyObj.PONO = "10";
                            MyObj.SEQN = "0";
                            MyObj.CLOT = string.IsNullOrEmpty(toLot) ? " " : toLot.ToUpper();
                            //JC 180821 Grabar la bodega por defecto del item
                            //MyObj.CWAR = row.Cells[3].Text.ToUpperInvariant();
                            MyObj.CWAR  = Warehouse.Rows[0]["WARITEM"].ToString().Trim().ToUpper();
                            MyObj.QTYS  = toreturn;// cantidad escaneada view
                            MyObj.QTYA  = toreturn;
                            MyObj.UNIT  = row.Cells[3].Text.Trim();
                            MyObj.QTYC  = toreturn;                                       //cantidad escaneada view aplicando factor
                            MyObj.UNIC  = row.Cells[3].Text.Trim();
                            MyObj.DATE  = DateTime.Now.ToString("dd/MM/yyyy").ToString(); //fecha de confirmacion
                            MyObj.CONF  = "1";
                            MyObj.RCNO  = " ";                                            //llena baan
                            MyObj.DATR  = "01/01/70";                                     //llena baan
                            MyObj.LOCA  = " ";                                            // enviamos vacio
                            MyObj.DATL  = DateTime.Now.ToString("dd/MM/yyyy").ToString(); //llenar con fecha de hoy
                            MyObj.PRNT  = "1";                                            // llenar en 1
                            MyObj.DATP  = DateTime.Now.ToString("dd/MM/yyyy").ToString(); //llena baan
                            MyObj.NPRT  = "1";                                            //conteo de reimpresiones
                            MyObj.LOGN  = HttpContext.Current.Session["user"].ToString(); // nombre de ususario de la session
                            MyObj.LOGT  = " ";                                            //llena baan
                            MyObj.STAT  = "1";                                            // LLENAR EN 1
                            MyObj.DSCA  = row.Cells[1].Text.ToUpperInvariant();
                            MyObj.COTP  = "0";
                            MyObj.FIRE  = "1";
                            MyObj.PSLIP = " ";
                            MyObj.ALLO  = "0";
                            string StrError = string.Empty;

                            Itwhcol130.Insertartwhcol131(MyObj, ref StrError);
                        }

                        if (tabla022 == 1)
                        {
                            Ent_tticol022        obj022  = new Ent_tticol022();
                            List <Ent_tticol022> list022 = new List <Ent_tticol022>();

                            //obj022.pdno = txtWorkOrder.Text.Trim().ToUpper();
                            obj022.pdno    = string.IsNullOrEmpty(toLot) ? txtWorkOrder.Text.Trim().ToUpper() : toLot.ToUpper().Trim();
                            obj022.sqnb    = txtWorkOrder.Text.Trim().ToUpper() + "-RT" + sec;
                            obj022.proc    = 1;
                            obj022.logn    = HttpContext.Current.Session["user"].ToString();
                            obj022.mitm    = row.Cells[0].Text.ToUpper().Trim();
                            obj022.qtdl    = Convert.ToDecimal(toreturn);
                            obj022.cuni    = row.Cells[3].Text.Trim();
                            obj022.log1    = "NONE";
                            obj022.qtd1    = Convert.ToInt32(toreturn);
                            obj022.pro1    = 1;
                            obj022.log2    = "NONE";
                            obj022.qtd2    = Convert.ToInt32(toreturn);
                            obj022.pro2    = 2;
                            obj022.loca    = " ";
                            obj022.norp    = 1;
                            obj022.dele    = 2;
                            obj022.logd    = "NONE";
                            obj022.refcntd = 0;
                            obj022.refcntu = 0;
                            obj022.drpt    = DateTime.Now;
                            obj022.urpt    = HttpContext.Current.Session["user"].ToString();
                            obj022.acqt    = Convert.ToDecimal(toreturn);
                            //JC 180821 Grabar la bodega por defecto del item
                            //obj022.cwaf = row.Cells[3].Text.ToUpper();
                            //obj022.cwat = row.Cells[3].Text.ToUpper();
                            obj022.cwaf = Warehouse.Rows[0]["WARITEM"].ToString().Trim().ToUpper();
                            obj022.cwat = Warehouse.Rows[0]["WARITEM"].ToString().Trim().ToUpper();
                            obj022.aclo = "";
                            obj022.allo = 0;

                            list022.Add(obj022);
                            Itticol022.insertarRegistroSimple(ref obj022, ref strError);
                            Itticol022.InsertarRegistroTicol222(ref obj022, ref strError);
                        }
                        if (tabla042 == 1)
                        {
                            Ent_tticol042        obj042  = new Ent_tticol042();
                            List <Ent_tticol042> list042 = new List <Ent_tticol042>();
                            //JC 061221 Ajustar para que salve el campo orden en la tabla ticol042 siempre con un valor
                            //obj042.pdno = string.IsNullOrEmpty(toLot) ? " " : toLot.ToUpper().Trim();
                            obj042.pdno    = string.IsNullOrEmpty(toLot) ? txtWorkOrder.Text.Trim().ToUpper() : toLot.ToUpper().Trim();
                            obj042.sqnb    = txtWorkOrder.Text.Trim().ToUpper() + "-RT" + sec;
                            obj042.proc    = 1;
                            obj042.logn    = HttpContext.Current.Session["user"].ToString();
                            obj042.mitm    = row.Cells[0].Text.ToUpper().Trim();
                            obj042.pono    = Convert.ToInt32(Pos);
                            obj042.qtdl    = Convert.ToDouble(toreturn);
                            obj042.cuni    = row.Cells[3].Text.Trim();
                            obj042.log1    = "NONE";
                            obj042.qtd1    = Convert.ToDecimal(toreturn);
                            obj042.pro1    = 1;
                            obj042.log2    = "NONE";
                            obj042.qtd2    = Convert.ToDecimal(toreturn);
                            obj042.pro2    = 2;
                            obj042.loca    = " ";
                            obj042.norp    = 1;
                            obj042.dele    = 2;
                            obj042.logd    = "NONE";
                            obj042.refcntd = 0;
                            obj042.refcntu = 0;
                            obj042.drpt    = DateTime.Now;
                            obj042.urpt    = HttpContext.Current.Session["user"].ToString();
                            obj042.acqt    = Convert.ToDouble(toreturn);
                            //JC 180821 Grabar la bodega por defecto del item
                            //obj042.cwaf = row.Cells[3].Text.ToUpper();
                            //obj042.cwat = row.Cells[3].Text.ToUpper();
                            obj042.cwaf = Warehouse.Rows[0]["WARITEM"].ToString().Trim().ToUpper();
                            obj042.cwat = Warehouse.Rows[0]["WARITEM"].ToString().Trim().ToUpper();
                            //JC 061221 Se quita esta inserción debido a que se cambio la estructura del gridview
                            //obj042.cwaf = row.Cells[3].Text.ToUpper();
                            //obj042.cwat = row.Cells[3].Text.ToUpper();
                            obj042.aclo = "";
                            obj042.allo = 0;

                            list042.Add(obj042);
                            Itticol042.insertarRegistroSimple(ref obj042, ref strError);
                            Itticol042.InsertarRegistroTicol242(ref obj042, ref strError);
                        }

                        obj      = new Ent_tticol125();
                        obj.pdno = txtWorkOrder.Text.Trim().ToUpper();
                        //JC 061221 Como ya no se tiene posición se define fija la posicíón 10
                        //obj.pono = Convert.ToInt32(row.Cells[0].Text);
                        obj.pono = Convert.ToInt32("10");
                        obj.item = row.Cells[0].Text.ToUpper(); //.Trim();
                        //JC 180821 Grabar la bodega por defecto del item
                        //obj.cwar = row.Cells[3].Text.ToUpper(); //.Trim();
                        obj.cwar     = Warehouse.Rows[0]["WARITEM"].ToString().Trim().ToUpper();
                        obj.paid     = txtWorkOrder.Text.Trim().ToUpper() + "-RT" + sec;
                        obj.clot     = string.IsNullOrEmpty(toLot) ? " " : toLot.ToUpperInvariant();
                        obj.reqt     = Decimal.Parse(toreturn, System.Globalization.CultureInfo.InvariantCulture); //Convert.ToInt32(toreturn);
                        obj.refcntd  = "0";
                        obj.refcntu  = "0";
                        obj.mess     = " ";
                        obj.prin     = 1;
                        obj.conf     = 2;
                        obj.user     = Session["user"].ToString();
                        obj.idrecord = grdRecords.DataKeys[row.RowIndex].Value.ToString();
                        parameterCollection.Add(obj);
                    }
                }
                InterfazDAL_tticol125 idal = new InterfazDAL_tticol125();
                idal.insertarRegistro(ref parameterCollection, ref strError, Aplicacion);
                printResult.Visible     = true;
                printLabel.Visible      = true;
                lblResult.Text          = mensajes("msjsave");
                lblResult.ForeColor     = System.Drawing.Color.Green;
                this.HeaderGrid.Visible = false;

                grdRecords.DataSource = "";
                grdRecords.DataBind();
                btnSave.Visible = false;

                if (strError != string.Empty)
                {
                    btnSave.Visible = false;

                    lblResult.Text      = mensajes("errorsave");
                    lblResult.ForeColor = System.Drawing.Color.Red;
                    throw new System.InvalidOperationException(strError);
                }
            }
            printResult.Visible   = true;
            printLabel.Visible    = true;
            grdRecords.DataSource = "";
            grdRecords.DataBind();
            btnSave.Visible = false;
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            List <Ent_tticol125> parameterCollection = new List <Ent_tticol125>();
            Ent_tticol125        obj = new Ent_tticol125();

            //Recorrer filas con valores en los textos
            Session["WorkOrder"] = txtWorkOrder.Text.Trim();

            foreach (GridViewRow row in grdRecords.Rows)
            {
                string toreturn = ((TextBox)row.Cells[6].FindControl("toReturn")).Text;
                string toLot    = ((DropDownList)row.Cells[8].FindControl("toLot")).SelectedValue;

                string condLote = ((HiddenField)row.Cells[6].FindControl("LOTE")).Value.Trim();
                bool   reqLote  = condLote == "1" ? true : false;
                if ((reqLote && String.IsNullOrEmpty(toLot.Trim())) && !string.IsNullOrEmpty(toreturn))
                {
                    lblResult.Text = "Lot code is required. Cannot continue";
                    return;
                }

                //string toreturn = ((TextBox)row.Cells[6].FindControl("toReturn")).Text;
                //string toLot = ((TextBox)row.Cells[8].FindControl("toLot")).Text;

                if (!toreturn.Equals(string.Empty))
                {
                    obj          = new Ent_tticol125();
                    obj.pdno     = txtWorkOrder.Text.Trim().ToUpperInvariant();
                    obj.pono     = Convert.ToInt32(row.Cells[0].Text);
                    obj.item     = row.Cells[1].Text.ToUpperInvariant();                                       //.Trim();
                    obj.cwar     = row.Cells[3].Text.ToUpperInvariant();                                       //.Trim();
                    obj.clot     = string.IsNullOrEmpty(toLot) ? " " : toLot.ToUpperInvariant();
                    obj.reqt     = Decimal.Parse(toreturn, System.Globalization.CultureInfo.InvariantCulture); //Convert.ToInt32(toreturn);
                    obj.refcntd  = "0";
                    obj.refcntu  = "0";
                    obj.mess     = " ";
                    obj.prin     = 2;
                    obj.conf     = 2;
                    obj.user     = Session["user"].ToString();
                    obj.idrecord = grdRecords.DataKeys[row.RowIndex].Value.ToString();
                    parameterCollection.Add(obj);
                }
            }
            InterfazDAL_tticol125 idal = new InterfazDAL_tticol125();

            idal.insertarRegistro(ref parameterCollection, ref strError, Aplicacion);
            printResult.Visible     = true;
            printLabel.Visible      = true;
            lblResult.Text          = "Material Return was saved succesfully.";
            this.HeaderGrid.Visible = false;

            grdRecords.DataSource = "";
            grdRecords.DataBind();

            btnSave.Visible = false;
            if (strError != string.Empty)
            {
                btnSave.Visible = false;
                lblResult.Text  = strError;
                throw new System.InvalidOperationException(strError);
            }
        }