protected void btnSave_Click(object sender, EventArgs e) { List <Ent_tticol090> parameterCollection = new List <Ent_tticol090>(); Ent_tticol090 obj = new Ent_tticol090(); //Recorrer filas con valores en los textos Session["WorkOrder"] = txtWorkOrderFrom.Text.Trim(); foreach (GridViewRow row in grdRecords.Rows) { string toreturn = ((TextBox)row.Cells[4].FindControl("toReturn")).Text; //string toLot = ((TextBox)row.Cells[5].FindControl("toLot")).Text; string toLot = ((DropDownList)row.Cells[5].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; } if (!toreturn.Equals(string.Empty)) { obj = new Ent_tticol090(); obj.fpdn = txtWorkOrderFrom.Text.ToUpperInvariant(); obj.tpdn = txtWorkOrderTo.Text.ToUpperInvariant(); obj.clot = string.IsNullOrEmpty(toLot) ? " " : toLot.ToUpperInvariant(); obj.srno = 0; obj.item = row.Cells[0].Text.ToUpperInvariant(); obj.qana = Decimal.Parse(toreturn, System.Globalization.CultureInfo.InvariantCulture); obj.logn = Session["user"].ToString(); obj.proc = 2; obj.refcntd = 0; obj.refcntu = 0; obj.idrecord = grdRecords.DataKeys[row.RowIndex].Value.ToString(); parameterCollection.Add(obj); } } InterfazDAL_tticol090 idal = new InterfazDAL_tticol090(); idal.insertarRegistro(ref parameterCollection, ref strError); printResult.Visible = true; lblResult.Text = "Line Clearance was succesfully registered."; this.HeaderGrid.Visible = false; grdRecords.DataSource = ""; grdRecords.DataBind(); if (strError != string.Empty) { lblResult.Text = strError; throw new System.InvalidOperationException(strError); } }
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);"); } }
public static string validaInfo(string valor, string tipo, string orden = null) { string strSecondVal = string.Empty; string strError = string.Empty; string retorno = string.Empty; DataTable resultado = new DataTable(); InterfazDAL_ttwhcol016 idal016 = new InterfazDAL_ttwhcol016(); Ent_ttwhcol016 obj016 = new Ent_ttwhcol016(); InterfazDAL_tticol090 idal = new InterfazDAL_tticol090(); Ent_tticol090 obj = new Ent_tticol090(); if (tipo == "1") // Items { obj.item = valor; obj.fpdn = orden; resultado = idal.lineClearance_verificaRegistrosOrden_Param(ref obj, ref strError); } if (tipo == "2") // Lote { String[] valores = valor.Split('|'); obj016.clot = valores[0].Trim().ToUpperInvariant(); obj016.item = valores[1].Trim().ToUpperInvariant(); obj.fpdn = orden; resultado = idal016.TakeMaterialInv_verificaLote_Param(ref obj016, ref strError); strError = _idioma == "INGLES" ? "Lot code doesn´t exist. Cannot Continue" : "Codigo de lote no existe, no se puede continuar."; if (string.IsNullOrEmpty(strError)) { resultado = idal.lineClearance_verificaRegistrosOrden_Param(ref obj, ref obj016, ref strError); } strError = _idioma == "INGLES" ? "Lot code was not on Work Order. Cannot Continue" : "Codigo de lote no es de la orden de trabajo, no se puede continuar."; } // Validar si el numero de orden trae registros if (strError != string.Empty) { return("BAAN: " + strError); } if (resultado.Rows.Count > 0) { retorno = resultado.Rows[0]["DESCRIPCION"].ToString(); } return(retorno); }
public static string validaInfo(string valor, string tipo, string orden = null) { string strSecondVal = string.Empty; string strError = string.Empty; string retorno = string.Empty; DataTable resultado = new DataTable(); InterfazDAL_ttwhcol016 idal016 = new InterfazDAL_ttwhcol016(); Ent_ttwhcol016 obj016 = new Ent_ttwhcol016(); InterfazDAL_tticol090 idal = new InterfazDAL_tticol090(); Ent_tticol090 obj = new Ent_tticol090(); if (tipo == "1") // Items { obj.item = valor; obj.fpdn = orden; resultado = idal.lineClearance_verificaRegistrosOrden_Param(ref obj, ref strError); } if (tipo == "2") // Lote { String[] valores = valor.Split('|'); obj016.clot = valores[0].Trim().ToUpperInvariant(); obj016.item = valores[1].Trim().ToUpperInvariant(); obj.fpdn = orden; resultado = idal016.TakeMaterialInv_verificaLote_Param(ref obj016, ref strError); if (string.IsNullOrEmpty(strError)) { resultado = idal.lineClearance_verificaRegistrosOrden_Param(ref obj, ref obj016, ref strError); } } // Validar si el numero de orden trae registros if (strError != string.Empty) { return("BAAN: " + strError); } if (resultado.Rows.Count > 0) { retorno = resultado.Rows[0]["DESCRIPCION"].ToString(); } return(retorno); }