protected void grdRecords_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                // Verificar que si la cantidad es igual a 0, el control "toReturn" se deshabilite
                if (Convert.ToDouble(e.Row.Cells[4].Text) == 0)
                {
                    ((TextBox)e.Row.Cells[6].FindControl("toReturn")).Enabled = false;
                    ((TextBox)e.Row.Cells[6].FindControl("toReturn")).Attributes.Add("onfocus", "limpiar(this);");
                }
                DropDownList lista = ((DropDownList)e.Row.Cells[5].FindControl("toLot"));
                // Verificar que si el lote es nulo o vacio
                string strLote = ((DataRowView)e.Row.DataItem).DataView.Table.Rows[e.Row.RowIndex]["LOTE"].ToString();
                string strItem = ((DataRowView)e.Row.DataItem).DataView.Table.Rows[e.Row.RowIndex]["ARTICULO"].ToString();
                InterfazDAL_tticol090 idal090 = new InterfazDAL_tticol090();
                Ent_tticol090         obj090  = new Ent_tticol090();
                obj090.tpdn = txtWorkOrder.Text.Trim().ToUpperInvariant();
                obj090.item = strItem;
                DataTable lotesItem = idal090.lineClearance_verificaLote_Param(ref obj090, ref strError);

                DataRow drv  = ((DataRowView)e.Row.DataItem).Row;
                var     fila = drv.ItemArray.ToArray();

                var serializador    = new JavaScriptSerializer();
                var FilaSerializada = serializador.Serialize(fila);

                if (strLote != "1")
                {
                    //((TextBox)e.Row.Cells[8].FindControl("toLot")).Enabled = false;
                    lista.Enabled = false;
                }
                else
                {
                    if (lista != null)
                    {
                        //((TextBox)e.Row.Cells[8].FindControl("toLot")).Attributes.Add("onblur", "validaLot(" + FilaSerializada.Trim() + ", this.value, this);");
                        ((TextBox)e.Row.Cells[6].FindControl("toReturn")).Attributes.Add("onfocus", "limpiar(this);");
                    }

                    DataRow filaIni = lotesItem.NewRow();
                    filaIni[0] = "  ";
                    filaIni[1] = " - Select Lot - ";
                    lotesItem.Rows.InsertAt(filaIni, 0);

                    lista.Enabled        = true;
                    lista.DataSource     = lotesItem;
                    lista.DataTextField  = "DESCRIPCION";
                    lista.DataValueField = "LOTE";
                    lista.DataBind();
                }
                ((RangeValidator)e.Row.Cells[6].FindControl("validateQuantity")).MinimumValue = "0";
                ((RangeValidator)e.Row.Cells[6].FindControl("validateQuantity")).MaximumValue = ((DataRowView)e.Row.DataItem).DataView.Table.Rows[e.Row.RowIndex]["CANT"].ToString();;
                TextBox control = (TextBox)e.Row.Cells[6].FindControl("toReturn");
                control.Attributes.Add("onblur", "validaLot(this, " + FilaSerializada + ", '" + txtWorkOrder.Text.Trim() + "');");
                control.Attributes.Add("onchange", "validarCantidadMaxima(this, " + FilaSerializada + ", 0);");
                lista.Attributes.Add("onchange", "validarCantidadMaxima(this, " + FilaSerializada + ", 1);");
            }
        }
Example #2
0
        protected void grdRecords_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                // Verificar que si el lote es nulo o vacio
                string strLote = ((DataRowView)e.Row.DataItem).DataView.Table.Rows[e.Row.RowIndex]["IND_LOTE"].ToString();
                string strItem = ((DataRowView)e.Row.DataItem).DataView.Table.Rows[e.Row.RowIndex]["ARTICULO"].ToString();
                if (string.IsNullOrEmpty(strLote))
                {
                    ((DropDownList)e.Row.Cells[5].FindControl("toLot")).Enabled = false;
                    // ((TextBox)e.Row.Cells[5].FindControl("toLot")).Enabled = false;
                }
                else
                {
                    DataRow drv  = ((DataRowView)e.Row.DataItem).Row;
                    var     fila = drv.ItemArray.ToArray();

                    var serializador    = new JavaScriptSerializer();
                    var FilaSerializada = serializador.Serialize(fila);

                    //((RangeValidator)e.Row.Cells[4].FindControl("validateQuantity")).MinimumValue = "0";
                    TextBox toReturn = (TextBox)e.Row.Cells[4].FindControl("toReturn");
                    //                    TextBox toLot = (TextBox)e.Row.Cells[5].FindControl("toLot");

                    strLote = ((DataRowView)e.Row.DataItem).DataView.Table.Rows[e.Row.RowIndex]["IND_LOTE"].ToString();

                    obj      = new Ent_tticol090();
                    obj.tpdn = txtWorkOrderFrom.Text.Trim().ToUpperInvariant();
                    obj.item = strItem;
                    DataTable lotesItem = idal.lineClearance_verificaLote_Param(ref obj, ref strError);

                    if (toReturn != null)
                    {
                        ((TextBox)e.Row.Cells[4].FindControl("ActualQty")).Text = ((DataRowView)e.Row.DataItem).DataView.Table.Rows[e.Row.RowIndex]["ACT_CANT"].ToString();

                        string           dataCant = ((DataRowView)e.Row.DataItem).DataView.Table.Rows[e.Row.RowIndex]["ACT_CANT"].ToString();
                        CompareValidator objVal   = (CompareValidator)e.Row.Cells[4].FindControl("validateQuantity");

                        objVal.ValueToCompare    = dataCant;
                        objVal.ControlToValidate = toReturn.ID;
                        //objVal.Enabled = true;

                        //((RangeValidator)e.Row.Cells[4].FindControl("validateQuantity")).MaximumValue = ((DataRowView)e.Row.DataItem).DataView.Table.Rows[e.Row.RowIndex]["ACT_CANT"].ToString();


                        //((TextBox)e.Row.Cells[4].FindControl("toReturn")).Attributes.Add("onblur", "if(this.value != '') " +
                        //                                                                           "{ validaInfo('" + strItem + "' , '1',this); }");
                        ((TextBox)e.Row.Cells[4].FindControl("toReturn")).Attributes.Add("onblur", "if(this.value != '') " +
                                                                                         "{ validaInfo('" + strItem + "' , '1',this); " +
                                                                                         "validateMov('" + dataCant + "',this.value, '" + objVal.ClientID + "', this);}");
                        ((TextBox)e.Row.Cells[4].FindControl("toReturn")).Attributes.Add("onkeypress", "verificarDecimal(this,'" + ((DataRowView)e.Row.DataItem).DataView.Table.Rows[e.Row.RowIndex]["UNIDAD"].ToString().Trim() + "');");
                        ((TextBox)e.Row.Cells[4].FindControl("toReturn")).Attributes.Add("onchange", "verificarDecimal(this,'" + ((DataRowView)e.Row.DataItem).DataView.Table.Rows[e.Row.RowIndex]["UNIDAD"].ToString().Trim() + "');");
                    }

                    if (strLote != "1")
                    {
                        ((DropDownList)e.Row.Cells[5].FindControl("toLot")).Enabled = false;
                        //((TextBox)e.Row.Cells[5].FindControl("toLot")).Enabled = false;
                    }
                    else
                    {
                        DataRow filaIni = lotesItem.NewRow();
                        filaIni[0] = "  ";
                        filaIni[1] = _idioma == "INGLES" ? " - Select Lot - " : " - Seleccion un lote -";
                        lotesItem.Rows.InsertAt(filaIni, 0);

                        DropDownList lista = ((DropDownList)e.Row.Cells[5].FindControl("toLot"));
                        lista.DataSource     = lotesItem;
                        lista.DataTextField  = "DESCRIPCION";
                        lista.DataValueField = "LOTE";
                        lista.DataBind();

                        //((TextBox)e.Row.Cells[5].FindControl("toLot")).Attributes.Add("onblur", "if(this.value != ''){ validaInfo(this.value +'|" + strItem.Trim() + "', '2', this);}");
                        //((TextBox)e.Row.Cells[5].FindControl("toLot")).Attributes.Add("onfocus", "limpiar(this);");
                    }
                }
            }
        }