public static string InsertarReseiptRawMaterial(string OORG, string ORNO, string ITEM, string PONO, string LOT, decimal QUANTITY, string STUN, string PALLET, string UNIT) { //if (string.IsNullOrEmpty(ORNO.Trim())) //{ // //RequiredField.Enabled = true; // //RequiredField.IsValid = false; // txtPalletIDValue.Focus(); // lblError.Text = mensajes("Palletnotpresent"); // // grdRecords.DataSource = ""; // // grdRecords.DataBind(); // return; //} //var ORNO = lblreturnorderValue.Text.Trim().ToUpper(); //var PONO = dropDownPosition.Text; //var QUANTITYAUX = Convert.ToInt32(lblqtyValue1.Value.ToString()); //var ITEM = lblItemValue1.Value.Trim().ToString().ToUpper(); Ent_twhcol130131 MyObj = new Ent_twhcol130131(); decimal QUANTITYAUX = QUANTITY; LOT = LOT.Trim() == string.Empty ? " " : LOT.Trim(); string Retrono = "El Registro no se ha insertado"; DataTable DTOrdencompra = ConsultaOrdencompra(ORNO, PONO, QUANTITYAUX, ITEM, ""); //DataTable DTOrdencompra = ConsultaPOReturn(ORNO, PONO, QUANTITYAUX, ITEM, ""); if (DTOrdencompra.Rows.Count > 0) //Changes { bool OrdenImportacion = false; OrdenImportacion = twhcol130DAL.ConsultaOrdenImportacion(DTOrdencompra.Rows[0]["T$COTP"].ToString()).Rows.Count > 0 ? true : false; string LOCAL = string.Empty; string PRIORIDAD = string.Empty; Ent_twhcol130131 MyObjError = new Ent_twhcol130131(); try { string strError = string.Empty; Ent_twhwmd200 OBJ200 = new Ent_twhwmd200 { cwar = DTOrdencompra.Rows[0]["T$CWAR"].ToString().Trim() }; DataTable Dttwhwmd200 = twhwmd200.listaRegistro_ObtieneAlmacenLocation(ref OBJ200, ref strError); if (Dttwhwmd200.Rows.Count > 0) { if (Dttwhwmd200.Rows[0]["LOC"].ToString().Trim() == "1") { PRIORIDAD = twhcol130DAL.ConsultarPrioridadNativa(DTOrdencompra.Rows[0]["T$CWAR"].ToString().Trim()).Rows[0]["T$PRIO"].ToString().Trim(); LOCAL = twhcol130DAL.ConsultarLocationNativa(DTOrdencompra.Rows[0]["T$CWAR"].ToString().Trim(), PRIORIDAD).Rows[0]["T$LOCA"].ToString().Trim(); } } } catch (Exception ex) { //LOCAL = " "; MyObjError.error = true; MyObjError.errorMsg = Priorinboundnotfound; //return MyObjError; } // var OORG = 2; var FIRE = 2; MyObj.OORG = OORG.ToString();// Order type escaneada view MyObj.ORNO = DTOrdencompra.Rows[0]["T$ORNO"].ToString(); MyObj.ITEM = DTOrdencompra.Rows[0]["T$ITEM"].ToString().Trim(); MyObj.PAID = PALLET; MyObj.PONO = DTOrdencompra.Rows[0]["T$PONO"].ToString(); MyObj.SEQN = DTOrdencompra.Rows[0]["T$SQNBR"].ToString(); MyObj.CLOT = LOT; // lote VIEW MyObj.CWAR = DTOrdencompra.Rows[0]["T$CWAR"].ToString(); MyObj.QTYS = QUANTITYAUX.ToString("0.00"); // cantidad escaneada view MyObj.UNIT = STUN; //unit escaneada view MyObj.QTYC = QUANTITYAUX.ToString("0.00"); //cantidad escaneada view aplicando factor MyObj.UNIC = UNIT; //unidad view stock 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 = LOCAL; // 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 = "0"; // LLENAR EN 1 MyObj.DSCA = DTOrdencompra.Rows[0]["DSCA"].ToString(); MyObj.COTP = DTOrdencompra.Rows[0]["T$COTP"].ToString(); MyObj.FIRE = FIRE.ToString(); MyObj.PSLIP = ""; MyObj.ALLO = "0"; MyObj.PAID_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + PALLET.ToString() + "&code=Code128&dpi=96"; MyObj.ORNO_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + DTOrdencompra.Rows[0]["T$ORNO"].ToString() + "&code=Code128&dpi=96"; MyObj.ITEM_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + DTOrdencompra.Rows[0]["T$ITEM"].ToString().Trim().ToUpper() + "&code=Code128&dpi=96"; MyObj.CLOT_URL = LOT.ToString().Trim() != "" ? UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + LOT.ToString().Trim().ToUpper() + "&code=Code128&dpi=96" : ""; MyObj.QTYC_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + QUANTITYAUX.ToString("0.00").Trim().ToUpper() + "&code=Code128&dpi=96"; MyObj.UNIC_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + UNIT.ToString().Trim().ToUpper() + "&code=Code128&dpi=96"; //if (OrdenImportacion) //{ var i = 1; int PRIO = 1; Ent_tticol082 Objtticol082 = new Ent_tticol082 { OORG = OORG.ToString(), ORNO = MyObj.ORNO, OSET = DTOrdencompra.Rows[0]["T$OSET"].ToString(), PONO = MyObj.PONO, SQNB = MyObj.SEQN, ADVS = i.ToString(), ITEM = MyObj.ITEM, STAT = "2", QTYT = QUANTITYAUX.ToString("0.00"), CWAR = DTOrdencompra.Rows[0]["T$CWAR"].ToString(), UNIT = MyObj.UNIT, PRIO = PRIO.ToString(), PAID = PALLET, LOGN = HttpContext.Current.Session["user"].ToString(), }; bool InsertSuccess = Itticol082.InsertarregistroItticol082(Objtticol082); if (InsertSuccess) { //Update pallet ID status to “Picked” (whcol131.stat). bool updatesuccess = twhcol130DAL.UpdateStatusPicked(MyObj); HttpContext.Current.Session["MaterialDesc"] = MyObj.ITEM; HttpContext.Current.Session["MaterialCode"] = MyObj.ITEM; HttpContext.Current.Session["codePaid"] = MyObj.PAID.ToString(); HttpContext.Current.Session["Lot"] = MyObj.ORNO; HttpContext.Current.Session["Quantity"] = MyObj.QTYS + " " + MyObj.UNIT; HttpContext.Current.Session["Origin"] = MyObj.ORNO; HttpContext.Current.Session["Supplier"] = ""; HttpContext.Current.Session["RecibedBy"] = HttpContext.Current.Session["user"].ToString(); HttpContext.Current.Session["RecibedOn"] = DateTime.Now.ToString(); HttpContext.Current.Session["Reprint"] = "no"; Retrono = JsonConvert.SerializeObject(MyObj); } else { MyObj.error = true; MyObj.errorMsg = "la insercion fue: " + InsertSuccess.ToString(); Retrono = JsonConvert.SerializeObject(MyObj); } } else { MyObj.error = true; MyObj.errorMsg = Retrono; Retrono = JsonConvert.SerializeObject(MyObj); } return(Retrono); }
public static string InsertarReseiptRawMaterial(string OORG, string ORNO, string ITEM, string PONO, string LOT, decimal QUANTITY, string STUN, string CUNI, string CWAR, string FIRE, string PSLIP) { //string PSLIP = string.Empty; PSLIP = PSLIP.Trim() == string.Empty ? " " : PSLIP.Trim(); decimal QUANTITYAUX = QUANTITY; string Retrono = "El Registro no se ha insertado"; Factor MyConvertionFactor = new Factor { }; if (CUNI != STUN) { MyConvertionFactor = FactorConversion(ITEM, STUN, CUNI); QUANTITY = (MyConvertionFactor.Tipo == "Div") ? Convert.ToDecimal((QUANTITY * MyConvertionFactor.FactorB) / MyConvertionFactor.FactorD) : Convert.ToDecimal((QUANTITY * MyConvertionFactor.FactorD) / MyConvertionFactor.FactorB); } if (MyConvertionFactor.FactorD != null || CUNI == STUN) { if (OORG == "2") { DataTable DTOrdencompra = ConsultaOrdencompra(ORNO, PONO, QUANTITYAUX, ITEM, ""); if (DTOrdencompra.Rows.Count > 0) { bool OrdenImportacion = false; OrdenImportacion = twhcol130DAL.ConsultaOrdenImportacion(DTOrdencompra.Rows[0]["T$COTP"].ToString()).Rows.Count > 0 ? true : false; int consecutivoPalletID = 0; DataTable DTPalletContinue = twhcol130DAL.PaidMayorwhcol130(ORNO); string SecuenciaPallet = "001"; if (DTPalletContinue.Rows.Count > 0) { foreach (DataRow item in DTPalletContinue.Rows) { consecutivoPalletID = Convert.ToInt32(item["T$PAID"].ToString().Trim().Substring(10, 3)) + 1; if (consecutivoPalletID.ToString().Length == 1) { SecuenciaPallet = "00" + consecutivoPalletID; } if (consecutivoPalletID.ToString().Length == 2) { SecuenciaPallet = "0" + consecutivoPalletID; } if (consecutivoPalletID.ToString().Length == 3) { SecuenciaPallet = consecutivoPalletID.ToString(); } } } string LOCAL = string.Empty; string PRIORIDAD = string.Empty; Ent_twhcol130131 MyObjError = new Ent_twhcol130131(); try { string strError = string.Empty; Ent_twhwmd200 OBJ200 = new Ent_twhwmd200 { cwar = DTOrdencompra.Rows[0]["T$CWAR"].ToString().Trim() }; DataTable Dttwhwmd200 = twhwmd200.listaRegistro_ObtieneAlmacenLocation(ref OBJ200, ref strError); if (Dttwhwmd200.Rows.Count > 0) { if (Dttwhwmd200.Rows[0]["LOC"].ToString().Trim() == "1") { PRIORIDAD = twhcol130DAL.ConsultarPrioridadNativa(DTOrdencompra.Rows[0]["T$CWAR"].ToString().Trim()).Rows[0]["T$PRIO"].ToString().Trim(); LOCAL = twhcol130DAL.ConsultarLocationNativa(DTOrdencompra.Rows[0]["T$CWAR"].ToString().Trim(), PRIORIDAD).Rows[0]["T$LOCA"].ToString().Trim(); } } } catch (Exception ex) { //LOCAL = " "; MyObjError.error = true; MyObjError.errorMsg = "Prior inbound not found"; return(JsonConvert.SerializeObject(MyObjError)); } Ent_twhcol130131 MyObj = new Ent_twhcol130131 { OORG = OORG,// Order type escaneada view ORNO = DTOrdencompra.Rows[0]["T$ORNO"].ToString(), ITEM = DTOrdencompra.Rows[0]["T$ITEM"].ToString(), PAID = DTOrdencompra.Rows[0]["T$ORNO"].ToString() + "-" + SecuenciaPallet, PONO = DTOrdencompra.Rows[0]["T$PONO"].ToString(), SEQN = DTOrdencompra.Rows[0]["T$SQNBR"].ToString(), CLOT = LOT, // lote VIEW CWAR = DTOrdencompra.Rows[0]["T$CWAR"].ToString(), QTYS = QUANTITYAUX.ToString("0.0000"), // cantidad escaneada view UNIT = STUN, //unit escaneada view QTYC = QUANTITY.ToString("0.0000"), //cantidad escaneada view aplicando factor UNIC = CUNI, //unidad view stock DATE = DateTime.Now.ToString("dd/MM/yyyy").ToString(), //fecha de confirmacion CONF = "1", RCNO = " ", //llena baan DATR = "01/01/70", //llena baan LOCA = LOCAL, // enviamos vacio DATL = DateTime.Now.ToString("dd/MM/yyyy").ToString(), //llenar con fecha de hoy PRNT = "1", // llenar en 1 DATP = DateTime.Now.ToString("dd/MM/yyyy").ToString(), //llena baan NPRT = "1", //conteo de reimpresiones LOGN = HttpContext.Current.Session["user"].ToString(), // nombre de ususario de la session LOGT = " ", //llena baan STAT = "0", // LLENAR EN 1 ALLO = "0", DSCA = DTOrdencompra.Rows[0]["DSCA"].ToString(), COTP = DTOrdencompra.Rows[0]["T$COTP"].ToString(), FIRE = FIRE, PSLIP = PSLIP.ToUpper(), PAID_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + DTOrdencompra.Rows[0]["T$ORNO"].ToString() + "-" + SecuenciaPallet + "&code=Code128&dpi=96", ORNO_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + DTOrdencompra.Rows[0]["T$ORNO"].ToString() + "&code=Code128&dpi=96", ITEM_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + DTOrdencompra.Rows[0]["T$ITEM"].ToString().Trim().ToUpper() + "&code=Code128&dpi=96", CLOT_URL = LOT.ToString().Trim() != "" ? UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + LOT.ToString().Trim().ToUpper() + "&code=Code128&dpi=96" : "", QTYC_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + QUANTITY.ToString("0.0000").Trim().ToUpper() + "&code=Code128&dpi=96", UNIC_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + STUN.ToString().Trim().ToUpper() + "&code=Code128&dpi=96" }; if (OrdenImportacion) { DataTable ConsultaPresupuestoImportacion = twhcol130DAL.ConsultaPresupuestoImportacion(ORNO); if (ConsultaPresupuestoImportacion.Rows.Count > 0 && ConsultaPresupuestoImportacion.Rows[0]["pres"].ToString().Trim() == "3") { bool Insertsucces = twhcol130DAL.InsertarReseiptRawMaterial(MyObj); if (Insertsucces) { Retrono = JsonConvert.SerializeObject(MyObj); } else { MyObj.error = true; MyObj.errorMsg = "la insercion fue: " + Insertsucces.ToString(); Retrono = JsonConvert.SerializeObject(MyObj); } } else { MyObj.error = true; MyObj.errorMsg = "Import PO, Budget is not closed. PO cannot be recived"; Retrono = JsonConvert.SerializeObject(MyObj); } } else { bool Insertsucces = twhcol130DAL.InsertarReseiptRawMaterial(MyObj); if (Insertsucces) { Retrono = JsonConvert.SerializeObject(MyObj); } else { MyObj.error = true; MyObj.errorMsg = "la insercion fue: " + Insertsucces.ToString(); Retrono = JsonConvert.SerializeObject(MyObj); } } } } else { DataTable DTNOOrdencompra = ConsultaNOOrdencompra(ORNO, PONO, OORG, QUANTITY, ITEM, LOT); bool ExistenciaLot = ValidarLote(ITEM, LOT); if (DTNOOrdencompra.Rows.Count > 0 && (ExistenciaLot == true || DTNOOrdencompra.Rows[0]["KLTC"].ToString().Trim() != "1")) { int consecutivoPalletID = 0; DataTable DTPalletContinue = twhcol130DAL.PaidMayorwhcol130(ORNO); string SecuenciaPallet = "001"; if (DTPalletContinue.Rows.Count > 0) { foreach (DataRow item in DTPalletContinue.Rows) { consecutivoPalletID = Convert.ToInt32(item["T$PAID"].ToString().Trim().Substring(10, 3)) + 1; if (consecutivoPalletID.ToString().Length == 1) { SecuenciaPallet = "00" + consecutivoPalletID; } if (consecutivoPalletID.ToString().Length == 2) { SecuenciaPallet = "0" + consecutivoPalletID; } if (consecutivoPalletID.ToString().Length == 3) { SecuenciaPallet = consecutivoPalletID.ToString(); } } } string LOCAL = string.Empty; string PRIORIDAD = string.Empty; Ent_twhcol130131 MyObjError = new Ent_twhcol130131(); try { PRIORIDAD = twhcol130DAL.ConsultarPrioridadNativa(DTNOOrdencompra.Rows[0]["T$CWAR"].ToString().Trim()).Rows[0]["T$PRIO"].ToString().Trim(); LOCAL = twhcol130DAL.ConsultarLocationNativa(DTNOOrdencompra.Rows[0]["T$CWAR"].ToString().Trim()).Rows[0]["T$LOCA"].ToString().Trim(); } catch (Exception ex) { //LOCAL = " "; MyObjError.error = true; MyObjError.errorMsg = "Prior inbound not found"; return(JsonConvert.SerializeObject(MyObjError)); } Ent_twhcol130131 MyObj = new Ent_twhcol130131 { OORG = OORG,// Order type escaneada view ORNO = DTNOOrdencompra.Rows[0]["T$ORNO"].ToString(), ITEM = DTNOOrdencompra.Rows[0]["T$ITEM"].ToString(), PAID = DTNOOrdencompra.Rows[0]["T$ORNO"].ToString() + "-" + SecuenciaPallet, PONO = DTNOOrdencompra.Rows[0]["T$PONO"].ToString(), SEQN = DTNOOrdencompra.Rows[0]["T$SEQN"].ToString(), CLOT = LOT, // lote VIEW CWAR = DTNOOrdencompra.Rows[0]["T$CWAR"].ToString(), QTYS = QUANTITYAUX.ToString("0.0000"), // cantidad escaneada view UNIT = STUN, //unidad view stock QTYC = QUANTITY.ToString("0.0000"), //cantidad escaneada view aplicando factor UNIC = CUNI, //unit escaneada view DATE = DateTime.Now.ToString("dd/MM/yyyy").ToString(), //fecha de confirmacion CONF = "1", RCNO = " ", //llena baan DATR = "01/01/70", //llena baan LOCA = LOCAL, // enviamos vacio DATL = DateTime.Now.ToString("dd/MM/yyyy").ToString(), //llenar con fecha de hoy PRNT = "1", // llenar en 1 DATP = DateTime.Now.ToString("dd/MM/yyyy").ToString(), //llena baan NPRT = "1", //conteo de reimpresiones LOGN = HttpContext.Current.Session["user"].ToString(), // nombre de ususario de la session LOGT = " ", //llena baan STAT = "0", // LLENAR EN 1 ALLO = "0", DSCA = DTNOOrdencompra.Rows[0]["T$DSCA"].ToString(), FIRE = FIRE, PAID_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + DTNOOrdencompra.Rows[0]["T$ORNO"].ToString() + "-" + SecuenciaPallet + "&code=Code128&dpi=96", ORNO_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + DTNOOrdencompra.Rows[0]["T$ORNO"].ToString() + "&code=Code128&dpi=96", ITEM_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + DTNOOrdencompra.Rows[0]["T$ITEM"].ToString().Trim().ToUpper() + "&code=Code128&dpi=96", CLOT_URL = LOT.ToString().Trim() != "" ? UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + LOT.ToString().Trim().ToUpper() + "&code=Code128&dpi=96" : "", QTYC_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + QUANTITY.ToString("0.0000").Trim().ToUpper() + "&code=Code128&dpi=96", UNIC_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + STUN.ToString().Trim().ToUpper() + "&code=Code128&dpi=96" }; bool Insertsucces = twhcol130DAL.InsertarReseiptRawMaterial(MyObj); if (Insertsucces) { Retrono = JsonConvert.SerializeObject(MyObj); } else { MyObj.error = true; MyObj.errorMsg = "la insercion fue:" + Insertsucces.ToString(); Retrono = JsonConvert.SerializeObject(MyObj); } } else { Ent_twhcol130131 MyObj = new Ent_twhcol130131 { error = true, errorMsg = "The lot does not correspond to the order" }; Retrono = JsonConvert.SerializeObject(MyObj); } } } return(Retrono); }
public static string InsertarReseiptRawMaterial(string OORG, string ORNO, string ITEM, string PONO, string LOT, decimal QUANTITY, string STUN, string CUNI, string CWAR, string FIRE, string PSLIP) { //string PSLIP = string.Empty; PSLIP = PSLIP.Trim() == string.Empty ? " " : PSLIP.Trim(); decimal QUANTITYAUX = QUANTITY; string Retrono = "El Registro no se ha insertado"; Factor MyConvertionFactor = new Factor { }; QUANTITYAUX_COMPLETADA = 0; if (CUNI != STUN) { MyConvertionFactor = FactorConversion(ITEM, STUN, CUNI); QUANTITY = (MyConvertionFactor.Tipo == "Div") ? Convert.ToDecimal((QUANTITY * MyConvertionFactor.FactorB) / MyConvertionFactor.FactorD) : Convert.ToDecimal((QUANTITY * MyConvertionFactor.FactorD) / MyConvertionFactor.FactorB); } if (MyConvertionFactor.FactorD != null || CUNI == STUN) { if (OORG == "2") { DataTable DTOrdencompra = ConsultaOrdencompra(ORNO, PONO, QUANTITYAUX, ITEM, ""); if (DTOrdencompra.Rows.Count > 0) { bool OrdenImportacion = false; OrdenImportacion = twhcol130DAL.ConsultaOrdenImportacion(DTOrdencompra.Rows[0]["T$COTP"].ToString()).Rows.Count > 0 ? true : false; int consecutivoPalletID = 0; DataTable DTPalletContinue = twhcol130DAL.PaidMayorwhcol130(ORNO); string SecuenciaPallet = "001"; if (DTPalletContinue.Rows.Count > 0) { foreach (DataRow item in DTPalletContinue.Rows) { consecutivoPalletID = Convert.ToInt32(item["T$PAID"].ToString().Trim().Substring(10, 3)) + 1; if (consecutivoPalletID.ToString().Length == 1) { SecuenciaPallet = "00" + consecutivoPalletID; } if (consecutivoPalletID.ToString().Length == 2) { SecuenciaPallet = "0" + consecutivoPalletID; } if (consecutivoPalletID.ToString().Length == 3) { SecuenciaPallet = consecutivoPalletID.ToString(); } } } string LOCAL = string.Empty; string PRIORIDAD = string.Empty; Ent_twhcol130131 MyObjError = new Ent_twhcol130131(); try { string strError = string.Empty; Ent_twhwmd200 OBJ200 = new Ent_twhwmd200 { cwar = DTOrdencompra.Rows[0]["T$CWAR"].ToString().Trim() }; DataTable Dttwhwmd200 = twhwmd200.listaRegistro_ObtieneAlmacenLocation(ref OBJ200, ref strError); if (Dttwhwmd200.Rows.Count > 0) { if (Dttwhwmd200.Rows[0]["LOC"].ToString().Trim() == "1") { PRIORIDAD = twhcol130DAL.ConsultarPrioridadNativa(DTOrdencompra.Rows[0]["T$CWAR"].ToString().Trim()).Rows[0]["T$PRIO"].ToString().Trim(); LOCAL = twhcol130DAL.ConsultarLocationNativa(DTOrdencompra.Rows[0]["T$CWAR"].ToString().Trim(), PRIORIDAD).Rows[0]["T$LOCA"].ToString().Trim(); } } } catch (Exception ex) { //LOCAL = " "; MyObjError.error = true; MyObjError.errorMsg = "Prior inbound not found"; return(JsonConvert.SerializeObject(MyObjError)); } Ent_twhcol130131 MyObj = new Ent_twhcol130131 { OORG = OORG,// Order type escaneada view ORNO = DTOrdencompra.Rows[0]["T$ORNO"].ToString(), ITEM = DTOrdencompra.Rows[0]["T$ITEM"].ToString(), PAID = DTOrdencompra.Rows[0]["T$ORNO"].ToString() + "-" + SecuenciaPallet, PONO = DTOrdencompra.Rows[0]["T$PONO"].ToString(), SEQN = DTOrdencompra.Rows[0]["T$SQNBR"].ToString(), CLOT = LOT, // lote VIEW CWAR = DTOrdencompra.Rows[0]["T$CWAR"].ToString(), QTYS = QUANTITYAUX.ToString("0.0000"), // cantidad escaneada view UNIT = STUN, //unit escaneada view QTYC = QUANTITY.ToString("0.0000"), //cantidad escaneada view aplicando factor UNIC = CUNI, //unidad view stock DATE = DateTime.Now.ToString("dd/MM/yyyy").ToString(), //fecha de confirmacion CONF = "1", RCNO = " ", //llena baan DATR = "01/01/70", //llena baan LOCA = LOCAL, // enviamos vacio DATL = DateTime.Now.ToString("dd/MM/yyyy").ToString(), //llenar con fecha de hoy PRNT = "1", // llenar en 1 DATP = DateTime.Now.ToString("dd/MM/yyyy").ToString(), //llena baan NPRT = "1", //conteo de reimpresiones LOGN = HttpContext.Current.Session["user"].ToString(), // nombre de ususario de la session LOGT = " ", //llena baan STAT = "0", // LLENAR EN 1 ALLO = "0", DSCA = DTOrdencompra.Rows[0]["DSCA"].ToString(), COTP = DTOrdencompra.Rows[0]["T$COTP"].ToString(), NAMA = DTOrdencompra.Rows[0]["T$NAMA"].ToString(), FIRE = FIRE, PSLIP = PSLIP.ToUpper(), PROC = "2", //RFID = " ", EVNT = " ", REFCNTD = "0", REFCNTU = "0", ITEM_URL = DTOrdencompra.Rows[0]["T$ITEM"].ToString().Trim().ToUpper() + " - " + DTOrdencompra.Rows[0]["DSCA"].ToString().Trim().ToUpper(), PAID_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + DTOrdencompra.Rows[0]["T$ORNO"].ToString() + "-" + SecuenciaPallet + "&code=Code128&dpi=96", ORNO_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + DTOrdencompra.Rows[0]["T$ORNO"].ToString() + "&code=Code128&dpi=96", CLOT_URL = LOT.ToString().Trim() != "" ? UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + LOT.ToString().Trim().ToUpper() + "&code=Code128&dpi=96" : "", QTYC_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + QUANTITY.ToString("0.0000").Trim().ToUpper() + "&code=Code128&dpi=96", UNIC_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + STUN.ToString().Trim().ToUpper() + "&code=Code128&dpi=96" }; if (MyObj.FIRE == "1") { DataTable x131 = twhcol130DAL.ConsultaSumatoriaCantidadesTticol130131(MyObj); DataTable x210 = twhcol130DAL.ConsultaSumatoriaCantidadesTwhinh210(MyObj); QUANTITYAUX_COMPLETADA = QUANTITYAUX_COMPLETADA + Convert.ToDecimal(MyObj.QTYC); decimal LIMITE = 0.05m; decimal TotalRecibido = Convert.ToDecimal(DTOrdencompra.Rows[0]["RECIBIDO"].ToString()); decimal QTYCActual = Convert.ToDecimal(MyObj.QTYC); decimal CantidadMaxima = Convert.ToDecimal(DTOrdencompra.Rows[0]["T$QSTK"].ToString()); decimal Restante = (CantidadMaxima - (TotalRecibido + QTYCActual)); if (Math.Abs(Restante) <= LIMITE) { MyObj.QTYC = Convert.ToString(CantidadMaxima - TotalRecibido); } } HttpContext.Current.Session["MaterialDesc"] = DTOrdencompra.Rows[0]["DSCA"].ToString(); HttpContext.Current.Session["MaterialCode"] = DTOrdencompra.Rows[0]["T$ITEM"].ToString(); HttpContext.Current.Session["codePaid"] = DTOrdencompra.Rows[0]["T$ORNO"].ToString() + "-" + SecuenciaPallet; HttpContext.Current.Session["Lot"] = LOT; HttpContext.Current.Session["Quantity"] = MyObj.QTYC + " " + CUNI; HttpContext.Current.Session["Origin"] = LOT; HttpContext.Current.Session["Supplier"] = DTOrdencompra.Rows[0]["T$NAMA"].ToString(); HttpContext.Current.Session["RecibedBy"] = _operator; HttpContext.Current.Session["RecibedOn"] = DateTime.Now.ToString(); HttpContext.Current.Session["Reprint"] = "no"; HttpContext.Current.Session["AutoPrint"] = "yes"; if (OrdenImportacion) { DataTable ConsultaPresupuestoImportacion = twhcol130DAL.ConsultaPresupuestoImportacion(ORNO); if (ConsultaPresupuestoImportacion.Rows.Count > 0 && ConsultaPresupuestoImportacion.Rows[0]["pres"].ToString().Trim() == "3") { bool Insertsucces = twhcol130DAL.InsertarReseiptRawMaterial(MyObj); if (Insertsucces) { Retrono = JsonConvert.SerializeObject(MyObj); } else { MyObj.error = true; MyObj.errorMsg = "la insercion fue: " + Insertsucces.ToString(); Retrono = JsonConvert.SerializeObject(MyObj); } } else { MyObj.error = true; MyObj.errorMsg = "Import PO, Budget is not closed. PO cannot be recived"; Retrono = JsonConvert.SerializeObject(MyObj); } } else { bool Insertsucces = twhcol130DAL.InsertarReseiptRawMaterial(MyObj); if (Insertsucces) { //if (rfid == true) //{ //DataTable DtRfID = twhcol130DAL.selectTccol020(MyObj); // if (DtRfID.Rows.Count > 0) // { // if (DtRfID.Rows[0]["T$RFID"].ToString().Trim() == "1") // { // //if (rfid == true) // //{ // SrvRfidPop.Service1Client wcfser = new SrvRfidPop.Service1Client(); // string res = wcfser.ProWhcol133(MyObj.PAID, "0", "VA Dock", MyObj.ORNO, MyObj.DATE, MyObj.LOGN, "0", "0", "0"); // Console.WriteLine(res); // //} // } // } //} Retrono = JsonConvert.SerializeObject(MyObj); } else { MyObj.error = true; MyObj.errorMsg = "la insercion fue: " + Insertsucces.ToString(); Retrono = JsonConvert.SerializeObject(MyObj); } } } } else { DataTable DTNOOrdencompra = ConsultaNOOrdencompra(ORNO, PONO, OORG, QUANTITY, ITEM, LOT); bool ExistenciaLot = ValidarLote(ITEM, LOT); if (DTNOOrdencompra.Rows.Count > 0 && (ExistenciaLot == true || DTNOOrdencompra.Rows[0]["KLTC"].ToString().Trim() != "1")) { int consecutivoPalletID = 0; DataTable DTPalletContinue = twhcol130DAL.PaidMayorwhcol130(ORNO); string SecuenciaPallet = "001"; if (DTPalletContinue.Rows.Count > 0) { foreach (DataRow item in DTPalletContinue.Rows) { consecutivoPalletID = Convert.ToInt32(item["T$PAID"].ToString().Trim().Substring(10, 3)) + 1; if (consecutivoPalletID.ToString().Length == 1) { SecuenciaPallet = "00" + consecutivoPalletID; } if (consecutivoPalletID.ToString().Length == 2) { SecuenciaPallet = "0" + consecutivoPalletID; } if (consecutivoPalletID.ToString().Length == 3) { SecuenciaPallet = consecutivoPalletID.ToString(); } } } string LOCAL = string.Empty; string PRIORIDAD = string.Empty; Ent_twhcol130131 MyObjError = new Ent_twhcol130131(); try { PRIORIDAD = twhcol130DAL.ConsultarPrioridadNativa(DTNOOrdencompra.Rows[0]["T$CWAR"].ToString().Trim()).Rows[0]["T$PRIO"].ToString().Trim(); LOCAL = twhcol130DAL.ConsultarLocationNativa(DTNOOrdencompra.Rows[0]["T$CWAR"].ToString().Trim()).Rows[0]["T$LOCA"].ToString().Trim(); } catch (Exception ex) { //LOCAL = " "; MyObjError.error = true; MyObjError.errorMsg = "Prior inbound not found"; return(JsonConvert.SerializeObject(MyObjError)); } Ent_twhcol130131 MyObj = new Ent_twhcol130131 { OORG = OORG,// Order type escaneada view ORNO = DTNOOrdencompra.Rows[0]["T$ORNO"].ToString(), ITEM = DTNOOrdencompra.Rows[0]["T$ITEM"].ToString(), PAID = DTNOOrdencompra.Rows[0]["T$ORNO"].ToString() + "-" + SecuenciaPallet, PONO = DTNOOrdencompra.Rows[0]["T$PONO"].ToString(), SEQN = DTNOOrdencompra.Rows[0]["T$SEQN"].ToString(), CLOT = LOT, // lote VIEW CWAR = DTNOOrdencompra.Rows[0]["T$CWAR"].ToString(), QTYS = QUANTITYAUX.ToString("0.0000"), // cantidad escaneada view UNIT = STUN, //unidad view stock QTYC = QUANTITY.ToString("0.0000"), //cantidad escaneada view aplicando factor UNIC = CUNI, //unit escaneada view DATE = DateTime.Now.ToString("dd/MM/yyyy").ToString(), //fecha de confirmacion CONF = "1", RCNO = " ", //llena baan DATR = "01/01/70", //llena baan LOCA = LOCAL, // enviamos vacio DATL = DateTime.Now.ToString("dd/MM/yyyy").ToString(), //llenar con fecha de hoy PRNT = "1", // llenar en 1 DATP = DateTime.Now.ToString("dd/MM/yyyy").ToString(), //llena baan NPRT = "1", //conteo de reimpresiones LOGN = HttpContext.Current.Session["user"].ToString(), // nombre de ususario de la session LOGT = " ", //llena baan STAT = "0", // LLENAR EN 1 ALLO = "0", DSCA = DTNOOrdencompra.Rows[0]["T$DSCA"].ToString(), NAMA = DTNOOrdencompra.Rows[0]["T$NAMA"].ToString(), FIRE = FIRE, ITEM_URL = DTNOOrdencompra.Rows[0]["T$ITEM"].ToString().Trim().ToUpper() + " - " + DTNOOrdencompra.Rows[0]["DSCA"].ToString().Trim().ToUpper(), PAID_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + DTNOOrdencompra.Rows[0]["T$ORNO"].ToString() + "-" + SecuenciaPallet + "&code=Code128&dpi=96", ORNO_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + DTNOOrdencompra.Rows[0]["T$ORNO"].ToString() + "&code=Code128&dpi=96", CLOT_URL = LOT.ToString().Trim() != "" ? UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + LOT.ToString().Trim().ToUpper() + "&code=Code128&dpi=96" : "", QTYC_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + QUANTITY.ToString("0.0000").Trim().ToUpper() + "&code=Code128&dpi=96", UNIC_URL = UrlBaseBarcode + "/Barcode/BarcodeHandler.ashx?data=" + STUN.ToString().Trim().ToUpper() + "&code=Code128&dpi=96" }; HttpContext.Current.Session["MaterialDesc"] = DTNOOrdencompra.Rows[0]["T$DSCA"].ToString(); HttpContext.Current.Session["MaterialCode"] = DTNOOrdencompra.Rows[0]["T$ITEM"].ToString(); HttpContext.Current.Session["codePaid"] = DTNOOrdencompra.Rows[0]["T$ORNO"].ToString() + "-" + SecuenciaPallet; HttpContext.Current.Session["Lot"] = LOT; HttpContext.Current.Session["Quantity"] = QUANTITY.ToString("0.0000") + " " + CUNI; HttpContext.Current.Session["Origin"] = LOT; HttpContext.Current.Session["Supplier"] = _operator; HttpContext.Current.Session["RecibedBy"] = _operator; HttpContext.Current.Session["RecibedOn"] = DateTime.Now.ToString(); HttpContext.Current.Session["Reprint"] = "no"; HttpContext.Current.Session["AutoPrint"] = "yes"; if (MyObj.FIRE == "1") { DataTable CantidadesTticol130131 = twhcol130DAL.ConsultaSumatoriaCantidadesTticol130131(MyObj); DataTable CantidadesTwhinh210 = twhcol130DAL.ConsultaSumatoriaCantidadesTwhinh210(MyObj); if (CantidadesTticol130131.Rows.Count > 0 && CantidadesTwhinh210.Rows.Count > 0) { double qtyc = Convert.ToDouble(CantidadesTticol130131.Rows[0]["QTYC"].ToString()); double qstk = Convert.ToDouble(CantidadesTwhinh210.Rows[0]["T$QSTK"].ToString()); } } bool Insertsucces = twhcol130DAL.InsertarReseiptRawMaterial(MyObj); if (Insertsucces) { Retrono = JsonConvert.SerializeObject(MyObj); } else { MyObj.error = true; MyObj.errorMsg = "la insercion fue:" + Insertsucces.ToString(); Retrono = JsonConvert.SerializeObject(MyObj); } } else { Ent_twhcol130131 MyObj = new Ent_twhcol130131 { error = true, errorMsg = "The lot does not correspond to the order" }; Retrono = JsonConvert.SerializeObject(MyObj); } } } return(Retrono); }