Ejemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            List <Ent_tticol118> parameterCollection = new List <Ent_tticol118>();
            Ent_tticol118        obj = new Ent_tticol118();
            //Recorrer filas con valores en los textos
            string disposition = String.Empty;
            string reason      = String.Empty;
            string stockw      = String.Empty;
            string orden       = String.Empty;

            foreach (GridViewRow row in grdRecords.Rows)
            {
                string toreturn = ((TextBox)row.Cells[7].FindControl("toReturn")).Text;
                string lote     = ((TextBox)row.Cells[7].FindControl("toReturn")).Text;
                reason      = ((DropDownList)row.Cells[10].FindControl("Reasonid")).SelectedValue;
                disposition = ((DropDownList)row.Cells[11].FindControl("Dispoid")).SelectedValue;
                stockw      = ((DropDownList)row.Cells[12].FindControl("Stockwareh")).SelectedValue;
                if (stockw == String.Empty)
                {
                    stockw = "NA";
                }
                string regrind = ((DropDownList)row.Cells[13].FindControl("Regrind")).SelectedValue;
                if (regrind == String.Empty)
                {
                    regrind = "NA";
                }
                string obse = ((TextBox)row.Cells[14].FindControl("Comments")).Text;
                if (obse.Length > 255)
                {
                    obse = ((TextBox)row.Cells[14].FindControl("Comments")).Text.Substring(1, 255);
                }
                string supplier = ((DropDownList)row.Cells[11].FindControl("Supplier")).SelectedValue;
                if (supplier == string.Empty)
                {
                    supplier = " ";
                }
                if (Session["Lote"].ToString() == " ")
                {
                    Session["Lote"] = " ";
                }
                if (!toreturn.Equals(string.Empty))
                {
                    obj      = new Ent_tticol118();
                    obj.item = "         " + txtItem.Text.Trim().ToUpperInvariant();
                    obj.cwar = row.Cells[2].Text.ToUpperInvariant();
                    //obj.clot = row.Cells[3].Text.ToUpperInvariant();
                    obj.clot    = Session["Lote"].ToString();
                    obj.qtyr    = Convert.ToInt32(toreturn);
                    obj.cdis    = reason;
                    obj.obse    = obse;
                    obj.logr    = Session["user"].ToString();
                    obj.disp    = Convert.ToInt32(disposition);
                    obj.stoc    = stockw;
                    obj.ritm    = regrind;
                    obj.proc    = 2;
                    obj.mess    = " ";
                    obj.suno    = supplier;
                    obj.refcntd = 0;
                    obj.refcntu = 0;
                    parameterCollection.Add(obj);
                }
            }



            InterfazDAL_tticol118 idal = new InterfazDAL_tticol118();
            int actualizar             = idal.actualizarRegistro_Param(ref parameterCollection, ref strError);

            if (actualizar < 1)
            {
                idal.insertarRegistro(ref parameterCollection, ref strError);
            }

            if (strError != string.Empty)
            {
                lblResult.Text = strError;
            }
            else
            {
                printResult.Visible = true;
                if (Convert.ToInt32(disposition) == 4)
                {
                    DataTable resultado = idal.invLabel_registroImprimir_Param(ref obj, ref strError);

                    DataRow reg = resultado.Rows[0];
                    Session["FilaImprimir"] = reg;
                    printLabel.Visible      = true;
                }
                lblResult.Text          = strError;
                lblResult.Text          = "Material Rejection Inside Warehouse was updated succesfully.";
                this.HeaderGrid.Visible = false;
            }

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

            if (strError != string.Empty)
            {
                lblResult.Text = strError;
                throw new System.InvalidOperationException(strError);
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            List <Ent_tticol118> parameterCollection = new List <Ent_tticol118>();
            Ent_tticol118        obj = new Ent_tticol118();
            //Recorrer filas con valores en los textos
            string disposition = String.Empty;
            string reason      = String.Empty;
            string stockw      = String.Empty;
            string orden       = String.Empty;

            //var Regrind;

            foreach (GridViewRow row in grdRecords.Rows)
            {
                string toreturn = ((TextBox)row.Cells[7].FindControl("toReturn")).Text;
                string lote     = ((TextBox)row.Cells[7].FindControl("toReturn")).Text;
                reason      = ((DropDownList)row.Cells[9].FindControl("Reasonid")).SelectedValue;
                disposition = ((DropDownList)row.Cells[8].FindControl("Dispoid")).SelectedValue;
                stockw      = ((DropDownList)grdRecords.Rows[0].Cells[1].FindControl("Stockwareh")).SelectedValue;
                DataTable DTMyRegrind = new DataTable();
                Session["MyRegrind"] = ((DropDownList)grdRecords.Rows[0].Cells[1].FindControl("Regrind")).SelectedValue.ToString().Trim();
                if (stockw == String.Empty)
                {
                    stockw = "NA";
                }
                string regrind = ((DropDownList)grdRecords.Rows[0].Cells[2].FindControl("Regrind")).SelectedValue;
                if (regrind == String.Empty)
                {
                    regrind = "NA";
                }
                string obse = ((TextBox)grdRecords.Rows[0].Cells[3].FindControl("Comments")).Text;
                if (obse.Length > 255)
                {
                    obse = ((TextBox)grdRecords.Rows[0].Cells[3].FindControl("Comments")).Text.Substring(1, 255);
                }
                string supplier = ((DropDownList)grdRecords.Rows[0].Cells[0].FindControl("Supplier")).SelectedValue;
                if (supplier == string.Empty)
                {
                    supplier = " ";
                }
                if (Session["Lote"].ToString() == "" || Session["Lote"].ToString() == " ")
                {
                    Session["Lote"] = " ";
                }

                if (!toreturn.Equals(string.Empty))
                {
                    obj      = new Ent_tticol118();
                    obj.item = Session["txtItem"].ToString().Trim().ToUpperInvariant();
                    obj.cwar = row.Cells[2].Text.ToUpperInvariant();
                    //obj.clot = row.Cells[3].Text.ToUpperInvariant();
                    obj.clot    = Session["Lote"].ToString();
                    obj.qtyr    = Double.Parse(toreturn, System.Globalization.CultureInfo.InvariantCulture);//Convert.ToDecimal(toreturn);
                    obj.cdis    = reason;
                    obj.obse    = obse;
                    obj.logr    = Session["user"].ToString();
                    obj.disp    = Convert.ToInt32(disposition);
                    obj.stoc    = stockw;
                    obj.ritm    = regrind;
                    obj.proc    = 2;
                    obj.mess    = " ";
                    obj.suno    = supplier;
                    obj.refcntd = 0;
                    obj.refcntu = 0;
                    parameterCollection.Add(obj);
                }
            }



            InterfazDAL_tticol118 idal = new InterfazDAL_tticol118();

            //int actualizar = idal.actualizarRegistro_Param(ref parameterCollection, ref strError);
            //if (actualizar < 1)

            if (string.IsNullOrEmpty(reason) || string.IsNullOrWhiteSpace(reason))
            {
                corregible = true;
                strError   = _textoLabels.readStatement(formName, _idioma, "lblReasoNull");
            }
            else
            {
                idal.insertarRegistro(ref parameterCollection, ref strError);
            }



            if (strError != string.Empty)
            {
                lblResult.Text = mensajes("errorsave");
            }
            else
            {
                printResult.Visible = true;
                if (Convert.ToInt32(disposition) == 4 || Convert.ToInt32(disposition) == 5)
                {
                    DataTable resultado = idal.invLabel_registroImprimir_Param(ref obj, ref strError);
                    resultado.Columns.Add("USER", typeof(String));
                    DataRow reg = resultado.Rows[0];
                    resultado.Rows[0]["USER"] = Session["user"].ToString().ToUpper();
                    Session["FilaImprimir"]   = reg;
                    //printLabel.Visible = true;
                }
                lblResult.Text          = strError;
                lblResult.Text          = mensajes("msjupdt");
                this.HeaderGrid.Visible = false;
            }

            if (corregible == false)
            {
                grdRecords.DataSource = "";
                grdRecords.DataBind();
                grdRecords.DataSource = "";
                grdRecords.DataBind();
            }

            if (strError != string.Empty)
            {
                lblResult.Text = strError;
                //throw new System.InvalidOperationException(strError);
            }
            else
            {
                //Print Label Inmmediatly

                if (Convert.ToInt32(disposition) == 4 || Convert.ToInt32(disposition) == 5)
                {
                    //obj.item = txtItem.Text;

                    //obj.clot = txtLot.Text;

                    lblResult.Text = string.Empty;

                    DataTable resultadop = idal.listaRegistros_Param(ref obj, ref strError);

                    resultadop.Columns.Add("FactorKG", typeof(string));

                    resultadop.Rows[0]["FactorKG"] = FactorKG.Trim();

                    Session["resultadop"] = resultadop;

                    StringBuilder paramurl = new StringBuilder();

                    paramurl.Append("?");

                    paramurl.Append("valor1=" + Request.QueryString[0].ToString() + "&");

                    paramurl.Append("valor2=" + Request.QueryString[1].ToString() + "&");

                    paramurl.Append("valor3=" + Request.QueryString[2].ToString());

                    Session["IsPreviousPage"] = "";

                    StringBuilder script = new StringBuilder();

                    script.Append("ventanaImp = window.open('../Labels/whInvLabelMaterialRejectedD.aspx', ");

                    script.Append("'ventanaImp', 'menubar=0,resizable=0,width=580,height=450');");

                    script.Append("ventanaImp.moveTo(30, 0);");

                    //script.Append("setTimeout (ventanaImp.close(), 20000);");

                    ScriptManager.RegisterStartupScript(this, this.GetType(), "printTag", script.ToString(), true);
                    //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Notify", "alert('Information Saved Successfully.');", true);
                    lblResult.Text    = mensajes("msjupdt");
                    lblResult.Visible = true;
                }
            }
        }