public List <ZEBAN_S_BE> ZEBAN_S_GET(IDataReader reader) { List <ZEBAN_S_BE> zeban = new List <ZEBAN_S_BE>(); try { while (reader.Read()) { ZEBAN_S_BE z = new ZEBAN_S_BE(); z.BANFN = Int32.Parse(reader["BANFN"].ToString()); z.BNFPO = reader["BNFPO"].ToString(); z.SERIAL = Int32.Parse(reader["SERIAL"].ToString()); z.MENGE = Decimal.Parse(reader["MENGE"].ToString()); z.MEINS = reader["MEINS"].ToString(); z.PREIS = Decimal.Parse(reader["PREIS"].ToString()); z.WAERS = reader["WAERS"].ToString(); z.SERVICIO = reader["SERVICIO"].ToString(); z.TEXTO = reader["TEXTO"].ToString(); zeban.Add(z); } } catch (Exception ex) { throw ex; } finally { reader.Close(); } return(zeban); }
public static string crear2(string url, string valores, string comentario, string r, string us)// Crea requisición { string tipo = ""; string id = ""; ZEBAN_P_BE header = new ZEBAN_P_BE(); header.FK_USUARIO = us; header.STATUS = "0";//getStatus(user) + ""; header.F_APROBACION = DateTime.Now; header.REFERENCIA = r; List <ZEBAN_BE> items = new List <ZEBAN_BE>(); List <ZEBAN_I_BE> imps = new List <ZEBAN_I_BE>(); List <ZEBAN_S_BE> serv = new List <ZEBAN_S_BE>(); string[] tabla = valores.Split('|'); string valores_temp = ""; int cont = 0; for (int i = 0; i < tabla.Length - 1; i += 9) { if (cont > 0) { cont = (i / 9) + 1;//27.01.2017 i/8 } else { cont = i + 1; } valores_temp = tabla[i + 2] + "|" + tabla[i + 3] + "|" + tabla[i + 4] + "|" + tabla[i + 5] + "|" + tabla[i + 6] + "|" + tabla[i + 7] + "|" + tabla[i + 8] + "|"; tipo = tabla[i]; id = tabla[i + 1]; if (tipo == "s") { //res = creaServicios(valores, id, comentario); List <Object> list = new List <object>(); list = creaServicios(valores_temp, id, cont); ZEBAN_BE item_s = new ZEBAN_BE(); ZEBAN_I_BE imp_s = new ZEBAN_I_BE(); ZEBAN_S_BE serv_s = new ZEBAN_S_BE(); item_s = (ZEBAN_BE)list[0]; items.Add(item_s); imp_s = (ZEBAN_I_BE)list[1]; imps.Add(imp_s); serv_s = (ZEBAN_S_BE)list[2]; serv.Add(serv_s); } else if (tipo == "a") { //res = creaActivos(valores, id, comentario); List <Object> list = new List <object>(); list = creaActivos(valores_temp, id, cont); ZEBAN_BE item_i = new ZEBAN_BE(); ZEBAN_I_BE imp_i = new ZEBAN_I_BE(); ZEBAN_S_BE serv_i = new ZEBAN_S_BE(); item_i = (ZEBAN_BE)list[0]; items.Add(item_i); imp_i = (ZEBAN_I_BE)list[1]; imps.Add(imp_i); serv_i = (ZEBAN_S_BE)list[2]; serv.Add(serv_i); } else if (tipo == "m") { ZEBAN_BE item = new ZEBAN_BE(); item = creaMateriales(valores_temp, id, cont); items.Add(item); } else { //res = creaServicios(valores, id, comentario); List <Object> list = new List <object>(); list = creaImputa(valores_temp, id, cont); ZEBAN_BE item_s = new ZEBAN_BE(); ZEBAN_I_BE imp_s = new ZEBAN_I_BE(); ZEBAN_S_BE serv_s = new ZEBAN_S_BE(); item_s = (ZEBAN_BE)list[0]; items.Add(item_s); imp_s = (ZEBAN_I_BE)list[1]; imps.Add(imp_s); } } int conf = ZEBAN_P_BLL.INSERT(header); //Insertar registro en SQL List <ZEBAN_P_BE> zeban_p = ZEBAN_P_BLL.GET(); int b = zeban_p[(zeban_p.Count - 1)].BANFN; int banfn = b; for (int i = 0; i < items.Count; i++) { items[i].BANFN = b; } for (int i = 0; i < imps.Count; i++) { imps[i].BANFN = b; } for (int i = 0; i < serv.Count; i++) { serv[i].BANFN = b; } conf += ZEBAN_BLL.INSERT(items); if (imps.Count > 0) { conf += ZEBAN_I_BLL.INSERT(imps); } if (serv.Count > 0) { conf += ZEBAN_S_BLL.INSERT(serv); } if (!comentario.Equals("")) { ZEBAN_C_BE com = new ZEBAN_C_BE(); com.BANFN = banfn; com.FK_USUARIO = us; com.TEXTO = comentario; conf += ZEBAN_C_BLL.INSERT(com); } //USUARIO_BE u = USUARIO_BLL.GET(us)[0]; //enviar(us, banfn, url); USUARIO_BE usuarioBe = USUARIO_BLL.GET(us)[0]; using (List <USUARIO_BE> .Enumerator enumerator = USUARIO_BLL.GET(USUARIO_BLL.GET(us)[0].AREA).GetEnumerator()) { while (enumerator.MoveNext()) { USUARIO_BE current = enumerator.Current; if (current.GEREN | current.DIREC) { header.BANFN = (b); header.STATUS = ("2"); conf += ZEBAN_P_BLL.UPDATE(header); enviarA(usuarioBe.NipLogin, b, url); } else { enviar(us, b, url); } } } return("B"); }
private static List <Object> creaServicios(string valores, string id, int cont) { string[] item = valores.Split('|'); ////ZEBAN_P_BE header = new ZEBAN_P_BE(); ZEBAN_BE items = new ZEBAN_BE(); Conexion con = new Conexion(); ////header.FK_USUARIO = user; ////header.STATUS = getStatus(user); ////header.F_APROBACION = DateTime.Now; ////int conf = ZEBAN_P_BLL.INSERT(header); //Insertar registro en SQL ////List<ZEBAN_P_BE> zeban_p = ZEBAN_P_BLL.GET(); ////int b = zeban_p[(zeban_p.Count - 1)].BANFN; ////int banfn = b; ////items.BANFN = banfn; IRfcTable serv = con.check_servicio(id, "S"); items.BNFPO = "" + (cont * 10); items.DESCR = item[0]; items.DESCR = serv.GetString("DESCR"); items.F_ENTREGA = DateTime.Parse(item[4]); items.MAT_GR = item[2]; serv.CurrentIndex = 0; //items.MEINS = serv.GetString("UM"); items.MEINS = "SER"; //items.MENGE = Decimal.Parse(item[3]); items.MENGE = 1; //items.PREIS = Decimal.Parse(item[1]); items.PUR_GR = ConfigurationManager.AppSettings["purchaseGroup"]; items.TIPO = "F"; items.IMP = "K"; items.WERKS = ConfigurationManager.AppSettings["werks"]; items.WAERS = item[5]; ////List<ZEBAN_BE> Items = new List<ZEBAN_BE>(); ////Items.Add(items); ////conf += ZEBAN_BLL.INSERT(Items); //Insertar registro en SQL List <ZEBAN_S_BE> servs = new List <ZEBAN_S_BE>(); ZEBAN_S_BE temp = new ZEBAN_S_BE(); //temp.BANFN = banfn; temp.BNFPO = "" + (cont * 10); temp.SERIAL = 1; temp.MEINS = "SER"; temp.SERVICIO = serv.GetString("SERVICIO"); temp.TEXTO = con.check_servDesc(temp.SERVICIO); temp.MENGE = Decimal.Parse(item[3]); temp.PREIS = Decimal.Parse(item[1]); temp.WAERS = item[5]; servs.Add(temp); //conf += ZEBAN_S_BLL.INSERT(servs); //Insertar registro en SQL List <ZEBAN_I_BE> imps = new List <ZEBAN_I_BE>(); ZEBAN_I_BE tempi = new ZEBAN_I_BE(); //tempi.BANFN = banfn; tempi.BNFPO = "" + (cont * 10); tempi.SERIAL = 1; tempi.LINE = 1; tempi.GL_ACCOUNT = servs[0].GL_ACCOUNT; tempi.COSTCENTER = servs[0].COSTCENTER; imps.Add(tempi); //conf += ZEBAN_I_BLL.INSERT(imps); //Insertar registro en SQL //if (!comentario.Equals("")) //{ // ZEBAN_C_BE com = new ZEBAN_C_BE(); // com.BANFN = banfn; // com.FK_USUARIO = user; // com.TEXTO = comentario; // conf += ZEBAN_C_BLL.INSERT(com); //} //return "B"; List <Object> lista = new List <object>(); lista.Add(items); lista.Add(tempi); lista.Add(temp); return(lista); }
public string aprobar(string banfn, string user, string url) { string[] ur = url.Split('/'); string u = ""; for (int i = 0; i < ur.Length - 1; i++) { u += ur[i] + "/"; } List <ZEBAN_P_BE> requ = ZEBAN_P_BLL.GET(banfn); string referencia = "";//27.01.2017 if (requ.Count > 0) { referencia = requ[0].REFERENCIA;//27.01.2017 requ[0].STATUS = rol(USUARIO_BLL.GET(user)[0]) + ""; if (requ[0].STATUS.Equals("5") | requ[0].STATUS.Equals("6")) { Conexion con = new Conexion(); List <ZEBAN_BE> Items = ZEBAN_BLL.GET(Int32.Parse(banfn)); List <ZEBAN_I_BE> imps = new List <ZEBAN_I_BE>(); List <ZEBAN_S_BE> servs = new List <ZEBAN_S_BE>(); foreach (ZEBAN_BE z in Items) { List <ZEBAN_I_BE> ii = ZEBAN_I_BLL.GET(z.BANFN, z.BNFPO.Trim()); List <ZEBAN_S_BE> ss = ZEBAN_S_BLL.GET(z.BANFN, z.BNFPO.Trim()); foreach (ZEBAN_I_BE i in ii) { imps.Add(i); if (z.TIPO.Trim() != "F") { ZEBAN_S_BE t = new ZEBAN_S_BE(); t.ASSET_NUM = i.ASSET_NUM.Trim(); t.COSTCENTER = i.COSTCENTER.Trim(); t.BANFN = i.BANFN; t.BNFPO = i.BNFPO.Trim(); t.GL_ACCOUNT = i.GL_ACCOUNT.Trim(); t.SERIAL = i.SERIAL; //t. servs.Add(t); } } if (z.TIPO.Trim() == "F") { foreach (ZEBAN_S_BE s in ss) { s.SERVICIO = completa(s.SERVICIO.Trim(), 18); servs.Add(s); } } } string[] ret = con.bapi_pr_create2(Items, imps, servs, user, u, referencia); //Crea requisición//27.01.2017 string status; // = "E"; if (!ret[0].Equals("")) { status = "B"; requ[0].APROBO = user; requ[0].SAP_BANFN = ret[0]; requ[0].STATUS = "6"; int i = ZEBAN_P_BLL.UPDATE(requ[0]); if (i > 0) { ZEBAN_H_BE his = new ZEBAN_H_BE(); his.BANFN = banfn; his.FECHA = DateTime.Now; his.NIPLOGIN = user; ZEBAN_H_BLL.INSERT(his); List <ZEBAN_D_BE> docs = ZEBAN_D_BLL.GET(Int32.Parse(banfn)); for (int y = 0; y < docs.Count; y++) { byte[] bytes = docs[y].INFO; string name = docs[y].NOMBRE + "." + docs[y].EXT; ret[i] = con.rfcFuncionAdjuntar(ret[0], "BUS2105", name, bytes); } enviarF(user, Int32.Parse(banfn), u, ret[0]); //return "Se ha aprobado la requisición"; } ret[1] = "Se ha creado la requisición " + ret[0] + " en SAP"; } else { status = "Hubieron errores al crear la requisición:"; } return("\n" + ret[1]); } else { requ[0].APROBO = user; int i = ZEBAN_P_BLL.UPDATE(requ[0]); if (i > 0) { ZEBAN_H_BE his = new ZEBAN_H_BE(); his.BANFN = banfn; his.FECHA = DateTime.Now; his.NIPLOGIN = user; ZEBAN_H_BLL.INSERT(his); enviar(user, Int32.Parse(banfn), u); return("Se ha aprobado la requisición"); } } } return("Hubo un error al aprobar la requisición"); }