public override object GetData(int actionType) { //return base.GetData(actionType); ResponseObj = new TransObj(); string consec, plan; int prvId; try { switch ((ActionType)actionType) { case ActionType.GetConsecClient: var clts = Entities.Database.SqlQuery <GeneralCat>(SQL_GET_CONSECT_CLINT).ToList(); clts.Insert(0, new GeneralCat { catId = -1, catVal = "Seleccione..." }); return(clts); case ActionType.GetConsec: var cnsc = Entities.Database.SqlQuery <GeneralCat>(SQL_GET_CONSECT).ToList(); cnsc.Insert(0, new GeneralCat { catId = -1, catVal = "Seleccione..." }); return(cnsc); case ActionType.GetFecha: break; case ActionType.GetProveedor: #region GetProveedor var prov = Entities.Database.SqlQuery <GeneralCat>(SQL_GET_PROVE).ToList(); prov.Insert(0, new GeneralCat { catId = -1, catVal = "Seleccione..." }); return(prov); #endregion case ActionType.GetTransp: #region GetTransp var trasp = Entities.Database.SqlQuery <GeneralCat>(SQL_GET_TRANSP).ToList(); trasp.Insert(0, new GeneralCat { catId = -1, catVal = "Seleccione..." }); return(trasp); #endregion case ActionType.GetDespachoByConsec: #region GetDespachoByConsec consec = RequestObj.TransParms[0].Value; var despByCon = (from d in Entities.V_LGC_DESPACHO_GRID where d.CONSECUTIVO_CLIENTE == consec select new { d.GUIA_ID, d.GUIA, d.CONSECUTIVO_CLIENTE, d.CONSECUTIVO, d.CODIGO_PREMIO, d.PREMIO, d.FECHA_REDENCION, d.REMITENTE_NOMBRE, d.REMITENTE_VAL, d.REMITENTE_DIRECCION, d.ORIGEN_ID, d.ORIGEN, d.DESTINATARIO_NOMBRE, d.DESTINATARIO_DIRECCION, d.DESTINATARIO_TELEFONO, d.DESTINO_ID, d.DESTINO, d.UNIDADES, d.VALOR, d.ESPECIFICACIONES }).ToList(); LastSearch = (ActionType)actionType; LastSearchData = consec; return(despByCon); #endregion case ActionType.GetDespachoByFecha: break; case ActionType.GetDespachoByProveedor: #region GetDespachoByProveedor prvId = int.Parse(RequestObj.TransParms[0].Value); var despByProv = (from d in Entities.V_LGC_DESPACHO_GRID where d.PROVEEDOR_ID == prvId select new { d.GUIA_ID, d.GUIA, d.CONSECUTIVO_CLIENTE, d.CONSECUTIVO, d.CODIGO_PREMIO, d.PREMIO, d.FECHA_REDENCION, d.REMITENTE_NOMBRE, d.REMITENTE_VAL, d.REMITENTE_DIRECCION, d.ORIGEN_ID, d.ORIGEN, d.DESTINATARIO_NOMBRE, d.DESTINATARIO_DIRECCION, d.DESTINATARIO_TELEFONO, d.DESTINO_ID, d.DESTINO, d.UNIDADES, d.VALOR, d.ESPECIFICACIONES }) .OrderBy(d => d.CONSECUTIVO_CLIENTE).ToList(); LastSearch = (ActionType)actionType; LastSearchData = prvId; return(despByProv); #endregion case ActionType.GetDespachoByPlanilla: #region GetDespachoByPlanilla plan = RequestObj.TransParms[0].Value; var despByPlan = (from d in Entities.V_LGC_DESPACHO_GRID where d.CONSECUTIVO == plan select new { d.GUIA_ID, d.GUIA, d.CONSECUTIVO_CLIENTE, d.CONSECUTIVO, d.CODIGO_PREMIO, d.PREMIO, d.FECHA_REDENCION, d.REMITENTE_NOMBRE, d.REMITENTE_VAL, d.REMITENTE_DIRECCION, d.ORIGEN_ID, d.ORIGEN, d.DESTINATARIO_NOMBRE, d.DESTINATARIO_DIRECCION, d.DESTINATARIO_TELEFONO, d.DESTINO_ID, d.DESTINO, d.UNIDADES, d.VALOR, d.ESPECIFICACIONES }) .OrderBy(d => d.CONSECUTIVO_CLIENTE).ToList(); LastSearch = (ActionType)actionType; LastSearchData = plan; return(despByPlan); #endregion case ActionType.GetDespachoByNumGuia: #region GetDespachoByNumGuia int ini = int.Parse(RequestObj.TransParms[0].Value); int end = int.Parse(RequestObj.TransParms[1].Value); var despByNumGuia = (from d in Entities.V_LGC_DESPACHO_GRID where ini <= d.GUIA_ID && d.GUIA_ID <= end select new { d.GUIA_ID, d.GUIA, d.CONSECUTIVO_CLIENTE, d.CONSECUTIVO, d.CODIGO_PREMIO, d.PREMIO, d.FECHA_REDENCION, d.REMITENTE_NOMBRE, d.REMITENTE_VAL, d.REMITENTE_DIRECCION, d.ORIGEN_ID, d.ORIGEN, d.DESTINATARIO_NOMBRE, d.DESTINATARIO_DIRECCION, d.DESTINATARIO_TELEFONO, d.DESTINO_ID, d.DESTINO, d.UNIDADES, d.VALOR, d.ESPECIFICACIONES }) .OrderBy(d => d.GUIA_ID).ToList(); LastSearch = (ActionType)actionType; LastSearchData = new int[] { ini, end }; return(despByNumGuia); #endregion case ActionType.GetDespachoAll: #region GetDespachoAll var despByAll = (from d in Entities.V_LGC_DESPACHO_GRID select new { d.GUIA_ID, d.GUIA, d.CONSECUTIVO_CLIENTE, d.CONSECUTIVO, d.CODIGO_PREMIO, d.PREMIO, d.FECHA_REDENCION, d.REMITENTE_NOMBRE, d.REMITENTE_VAL, d.REMITENTE_DIRECCION, d.ORIGEN_ID, d.ORIGEN, d.DESTINATARIO_NOMBRE, d.DESTINATARIO_DIRECCION, d.DESTINATARIO_TELEFONO, d.DESTINO_ID, d.DESTINO, d.UNIDADES, d.VALOR, d.ESPECIFICACIONES }) .OrderBy(d => d.CONSECUTIVO_CLIENTE).OrderBy(d => d.CONSECUTIVO_CLIENTE).ToList(); LastSearch = (ActionType)actionType; LastSearchData = ""; return(despByAll); #endregion case ActionType.GetDespachoWthGuia: #region GetDespachoWthGuia var despByWthG = (from d in Entities.V_LGC_DESPACHO_GRID where d.GUIA_ID.HasValue select new { d.GUIA_ID, d.GUIA, d.CONSECUTIVO_CLIENTE, d.CONSECUTIVO, d.CODIGO_PREMIO, d.PREMIO, d.FECHA_REDENCION, d.REMITENTE_NOMBRE, d.REMITENTE_VAL, d.REMITENTE_DIRECCION, d.ORIGEN_ID, d.ORIGEN, d.DESTINATARIO_NOMBRE, d.DESTINATARIO_DIRECCION, d.DESTINATARIO_TELEFONO, d.DESTINO_ID, d.DESTINO, d.UNIDADES, d.VALOR, d.ESPECIFICACIONES }) .OrderBy(d => d.GUIA_ID).ToList(); LastSearch = (ActionType)actionType; LastSearchData = ""; return(despByWthG); #endregion case ActionType.SaveData: #region SaveData try { var data = JsonConvert.DeserializeObject <JObject>(RequestObj.TransParms.Where(p => p.Key == "data").FirstOrDefault().Value); var NoGuia = long.Parse(RequestObj.TransParms.Where(p => p.Key == "NoGuia").FirstOrDefault().Value); var fEnvio = RequestObj.TransParms.Where(p => p.Key == "fEnvio").FirstOrDefault().Value; var peso = RequestObj.TransParms.Where(p => p.Key == "peso").FirstOrDefault().Value; var pesoVol = RequestObj.TransParms.Where(p => p.Key == "pesoVol").FirstOrDefault().Value; var pesoLiq = RequestObj.TransParms.Where(p => p.Key == "pesoLiq").FirstOrDefault().Value; var obs = RequestObj.TransParms.Where(p => p.Key == "obs").FirstOrDefault().Value; var usId = RequestObj.TransParms.Where(p => p.Key == "usId").FirstOrDefault().Value; var provId = RequestObj.TransParms.Where(p => p.Key == "provId").FirstOrDefault().Value; var NoGuiaAl = RequestObj.TransParms.Where(p => p.Key == "NoGuiaAl").FirstOrDefault().Value; //var dest = data["DESTINATARIO_NOMBRE"] + string sql = string.Format(SQL_IN_GUIA, NoGuia, //GUIA_ID "LOG", //GUIA_PREFIJO (int)CatTipoGuia.Despacho, //TIPO_ID "NULL", //recoleccion //idRECOLECCION_ID "NULL", //Despacho //IdDESPACHO_ID data["ORIGEN_ID"], //ORIGEN data["REMITENTE_VAL"], //REMITENTE_NOMBRE data["REMITENTE_DIRECCION"], //REMITENTE_DIRECCION data["REMITENTE_TELEFONO"], //REMITENTE_TELEFONO data["DESTINO_ID"], //DESTINO data["DESTINATARIO_NOMBRE"], //DESTINATARIO_NOMBRE data["DESTINATARIO_DIRECCION"], //DESTINATARIO_DIRECCION data["DESTINATARIO_TELEFONO"], //DESTINATARIO_TELEFONO data["UNIDADES"], //UNIDADES peso, //PESO pesoVol, //PESO_VOL pesoLiq, //PESO_LIQ data["VALOR"], //VALOR_DECLARADO "Obsequio", //data["DICE_CONTENER"], //DICE_CONTENER usId, //ELABORADO_POR //"NULL", //ENCARGADO_A obs, //OBSERVACIONES provId, NoGuiaAl ); int res = Entities.Database.ExecuteSqlCommand(sql); if (res == 0) { throw new Exception("Los datos no han sido guardados"); } string cc = data["CONSECUTIVO_CLIENTE"].ToString(); var des = Entities.LGC_DESPACHO.Where(d => d.CONSECUTIVO_CLIENTE == cc).FirstOrDefault(); des.GUIA_ID = NoGuia; Entities.SaveChanges(); ResponseObj.MessCode = TransObj.MessCodes.Ok; } catch (SqlException sqlEx) { if (sqlEx.Message.Contains("PRIMARY KEY")) { throw new Exception("El numero de guia ya existe."); } else { throw sqlEx; } } catch (Exception ex) { ResponseObj.MessCode = TransObj.MessCodes.Error; throw ex; } break; #endregion case ActionType.GetGuia: #region GetGuia long gId = long.Parse(RequestObj.TransParms[0].Value); var guia = (from g in Entities.V_GUIA where g.GUIA_ID == gId select new { g.GUIA_ID, g.GUIA_PREFIJO, g.ORIGEN, g.REMITENTE_NOMBRE, g.REMITENTE_DIRECCION, g.REMITENTE_TELEFONO, g.DESTINATARIO_NOMBRE, g.DESTINATARIO_DIRECCION, g.DESTINATARIO_TELEFONO, g.FECHA_ENVIO, g.UNIDADES, g.PESO, g.PESO_VOL, g.PESO_LIQ, g.VALOR_DECLARADO, g.DICE_CONTENER, g.BARCODE, g.OBSERVACIONES, g.ORIGEN_VAL, g.DESTINO_VAL, g.ELABORADO_POR_VAL }).ToList(); //Entities.Database.SqlQuery<V_GUIA>(string.Format(SQL_GET_GUIA, gId)).FirstOrDefault(); //var et = JsonConvert.DeserializeObject<JObject>(JsonConvert.SerializeObject(guia)); return(guia); #endregion case ActionType.GetLabels: #region GetLabels List <long> gIds = JsonConvert.DeserializeObject <List <long> >(RequestObj.TransParms[0].Value); var guias = (from g in Entities.V_GUIA_ETIQUETA where gIds.Contains(g.GUIA_ID) select g).ToList(); return(guias); #endregion break; default: break; } } catch (Exception ex) { throw ex; } return(ResponseObj); }
public override object GetData(int actionType) { ResponseObj = new TransObj(); bool itemZero = false, _new; int cat, id = 0; //CatTypes ctype; try { ActionType dType = (ActionType)actionType; switch (dType) { case ActionType.GetAllCatTypes: #region GetAllCatTypes itemZero = bool.Parse(RequestObj.TransParms.Where(p => p.Key == "itemZero").FirstOrDefault().Value); var catTps = (from c in Entities.V_ASFW_CATTYPE where c.VISIBLE select new { c.CATTYPEID, c.NAME }).OrderBy(c => c.NAME).ToList(); if (itemZero) { catTps.Insert(0, new { CATTYPEID = -1, NAME = "Seleccione..." }); } ResponseObj.TransParms.Add(new TransParm("cat", JsonConvert.SerializeObject(catTps))); ResponseObj.MessCode = TransObj.MessCodes.Ok; #endregion break; case ActionType.GetAllCatalogs: break; case ActionType.GetCatalog: #region GetCatalog cat = int.Parse(RequestObj.TransParms.Where(p => p.Key == "cat").FirstOrDefault().Value); //ctype = (CatTypes)Enum.Parse(typeof(CatTypes), reqCat); if (cat == (int)CatTypes.CIUDAD) { return(GetData((int)ActionType.GetCiudad)); } else if (cat == (int)CatTypes.DEPARTAMENTO) { return(GetData((int)ActionType.GetDepto)); } if (RequestObj.TransParms.Where(p => p.Key == "itemZero").FirstOrDefault() != null) { itemZero = bool.Parse(RequestObj.TransParms.Where(p => p.Key == "itemZero").FirstOrDefault().Value); } int catParent = -1; if (RequestObj.TransParms.Where(p => p.Key == "catPar0").FirstOrDefault() != null) { catParent = int.Parse(RequestObj.TransParms.Where(p => p.Key == "catPar0").FirstOrDefault().Value); } var catgs = (from c in Entities.V_ASFW_CATVAL where c.CATTYPEID == cat && c.SHOWABLE.Value && (catParent == -1 || c.CATPARENT0 == catParent) select new GeneralCat { catId = c.CATVALID, catVal = c.VAL }).OrderBy(c => c.catVal).ToList(); if (itemZero) { catgs.Insert(0, new GeneralCat { catId = -1, catVal = "Seleccione..." }); } ResponseObj.TransParms.Add(new TransParm("cat", JsonConvert.SerializeObject(catgs))); ResponseObj.MessCode = TransObj.MessCodes.Ok; #endregion break; case ActionType.GetCiudad: #region GetCiudad if (RequestObj.TransParms.Where(p => p.Key == "itemZero").FirstOrDefault() != null) { itemZero = bool.Parse(RequestObj.TransParms.Where(p => p.Key == "itemZero").FirstOrDefault().Value); } //int dep = int.Parse(RequestObj.TransParms.Where(p => p.Key == "catPar0").FirstOrDefault().Value); var catCiud = (from c in Entities.V_ASFW_CITY_CODE_MUN //where c.DEPTO_ID == dep select new { catId = c.ID.Value, catVal = c.MUN_DEPTO }).OrderBy(c => c.catVal).ToList(); if (itemZero) { catCiud.Insert(0, new { catId = -1, catVal = "Seleccione..." }); } ResponseObj.TransParms.Add(new TransParm("cat", JsonConvert.SerializeObject(catCiud))); ResponseObj.MessCode = TransObj.MessCodes.Ok; #endregion break; case ActionType.GetDepto: #region GetDepto if (RequestObj.TransParms.Where(p => p.Key == "itemZero").FirstOrDefault() != null) { itemZero = bool.Parse(RequestObj.TransParms.Where(p => p.Key == "itemZero").FirstOrDefault().Value); } var catDeps = (from d in Entities.V_ASFW_CITY_CODE_DEP select new { catId = d.ID.ToString(), catVal = d.NOM_DEPTO }).OrderBy(d => d.catVal).ToList(); if (itemZero) { catDeps.Insert(0, new { catId = "-1", catVal = "Seleccione..." }); } ResponseObj.TransParms.Add(new TransParm("cat", JsonConvert.SerializeObject(catDeps))); ResponseObj.MessCode = TransObj.MessCodes.Ok; #endregion break; case ActionType.GetCtlgFields: #region GetCtlgFields //ctype = (CatTypes)Enum.Parse(typeof(CatTypes), RequestObj.TransParms.Where(p => p.Key == "cat").FirstOrDefault().Value); if (RequestObj.TransParms.Where(p => p.Key == "itemZero").FirstOrDefault() != null) { itemZero = bool.Parse(RequestObj.TransParms.Where(p => p.Key == "itemZero").FirstOrDefault().Value); } cat = int.Parse(RequestObj.TransParms.Where(p => p.Key == "cat").FirstOrDefault().Value); var catgFlds = (from c in Entities.V_ASFW_CATVAL where c.ACTIVE.Value && c.SHOWABLE.Value && c.CATTYPEID == cat select new { catId = c.CATVALID, catVal = c.VAL, c.CUSTOMFIELD0, c.CUSTOMFIELD1, c.CUSTOMFIELD2 }).OrderBy(c => c.catVal).ToList(); if (itemZero) { catgFlds.Insert(0, new { catId = -1, catVal = "Seleccione...", CUSTOMFIELD0 = new decimal?(), CUSTOMFIELD1 = new decimal?(), CUSTOMFIELD2 = "" }); } ResponseObj.TransParms.Add(new TransParm("cat", JsonConvert.SerializeObject(catgFlds))); ResponseObj.MessCode = TransObj.MessCodes.Ok; #endregion break; case ActionType.GetCats2Edit: #region GetCats2Edit //ctype = (CatTypes)Enum.Parse(typeof(CatTypes), RequestObj.TransParms.Where(p => p.Key == "cat").FirstOrDefault().Value); if (RequestObj.TransParms.Where(p => p.Key == "itemZero").FirstOrDefault() != null) { itemZero = bool.Parse(RequestObj.TransParms.Where(p => p.Key == "itemZero").FirstOrDefault().Value); } cat = int.Parse(RequestObj.TransParms.Where(p => p.Key == "cat").FirstOrDefault().Value); var cats2E = (from c in Entities.V_ASFW_CATVAL where c.SHOWABLE.Value && c.CATTYPEID == cat select new { catId = c.CATVALID, catVal = c.VAL, c.CUSTOMFIELD0, c.CUSTOMFIELD1, c.CUSTOMFIELD2, c.ACTIVE }).OrderBy(c => c.catVal).ToList(); if (itemZero) { cats2E.Insert(0, new { catId = -1, catVal = "Seleccione...", CUSTOMFIELD0 = new decimal?(), CUSTOMFIELD1 = new decimal?(), CUSTOMFIELD2 = "", ACTIVE = new bool?() }); } ResponseObj.TransParms.Add(new TransParm("cat", JsonConvert.SerializeObject(cats2E))); ResponseObj.MessCode = TransObj.MessCodes.Ok; #endregion break; case ActionType.SaveCatalog: #region SaveCatalog //JObject catInfo = JObject.Parse(RequestObj.TransParms.Where(c => c.Key == "catInfo").FirstOrDefault().Value); //if (!string.IsNullOrEmpty(catInfo["catId"].ToString())) // id = int.Parse(catInfo["catId"].ToString()); //Data.Model.ASFW_CATVAL cat2Save = Entities.ASFW_CATVAL.Where(c => c.CATVALID == id).FirstOrDefault(); //_new = cat2Save == null; //if (_new) // cat2Save = new Data.Model.ASFW_CATVAL(); //cat2Save.ACTIVE = Boolean.Parse(catInfo["ACTIVE"].ToString()); //if (!string.IsNullOrEmpty(catInfo["CUSTOMFIELD0"].ToString()) && catInfo["CUSTOMFIELD0"].ToString() != "0") // cat2Save.CUSTOMFIELD0 = decimal.Parse(catInfo["CUSTOMFIELD0"].ToString()); //cat2Save.CATTYPEID = int.Parse(catInfo["catType"].ToString()); //cat2Save.VAL = catInfo["catVal"].ToString(); //cat2Save.SHOWABLE = true; //if (_new) // Entities.ASFW_CATVAL.Add(cat2Save); //Entities.SaveChanges(); //return GetData((int)ActionType.GetCats2Edit); #endregion case ActionType.DeleteCatalog: #region DeleteCatalog //id = int.Parse(RequestObj.TransParms.Where(p => p.Key == "catId").FirstOrDefault().Value); //Data.Model.ASFW_CATVAL cat2Del = Entities.ASFW_CATVAL.Where(c => c.CATVALID == id).FirstOrDefault(); //if (cat2Del == null) // throw new Exception("Catálogo no encontrado"); //cat2Del.SHOWABLE = false; //Entities.SaveChanges(); //return GetData((int)ActionType.GetCats2Edit); #endregion default: break; } } catch (Exception ex) { ResponseObj.MessCode = TransObj.MessCodes.Error; ResponseObj.Mess = ex.Message; } return(ResponseObj); }
public GuiasController() { Entities = new LgcWebEntities(); RequestObj = new TransObj(); }
static void Main(string[] args) { var p = new Person() { name = "Tim", id = "00010", personId = "p1" }; var student = new Student() { name = "Tim", id = "00010", studentId = "01020" }; Person person = TransObj <Student, Person> .Trans(student); //Console.WriteLine(person.id); //Console.WriteLine(person.name); Student student1 = TransObj <Person, Student> .Trans(p); //定义一个变量。 //var e = Expression.New(typeof(Person)); //ConstantExpression constant = Expression.Constant(10, typeof(int)); //ConstantExpression constant1 = Expression.Constant(200,typeof(int)); //BinaryExpression binaryExpression = Expression.Add(constant1, constant); //ParameterExpression paraLeft = Expression.Parameter(typeof(int), "a"); //ParameterExpression paraRight = Expression.Parameter(typeof(int), "b"); //BinaryExpression binaryLeft = Expression.Multiply(paraLeft, paraRight); //ConstantExpression conRight = Expression.Constant(2, typeof(int)); //BinaryExpression binaryBody = Expression.Add(binaryLeft, conRight); //LambdaExpression lambda = // Expression.Lambda<Func<int, int, int>>(binaryBody, paraLeft, paraRight); //Console.WriteLine(lambda.ToString()); //Console.Read(); //ParameterExpression parameterExpression = Expression.Parameter(typeof(int), "i"); //BinaryExpression binaryExpression = Expression.AddAssign(parameterExpression, parameterExpression); //var ex = Expression.Lambda<Func<int, int>>(binaryExpression, parameterExpression); //Func<int, int> lambdaExpression = Expression.Lambda<Func<int, int>>(binaryExpression, parameterExpression).Compile(); ParameterExpression parameter = Expression.Parameter(typeof(Person), "p"); List <MemberExpression> memberList = new List <MemberExpression>(); List <MemberBinding> bindingList = new List <MemberBinding>(); foreach (var item in typeof(Person).GetProperties()) { MemberExpression memberExpression = Expression.Property(parameter, item.Name); Console.WriteLine(memberExpression.ToString()); MemberBinding binding = Expression.Bind(item, memberExpression); Console.WriteLine(binding); bindingList.Add(binding); memberList.Add(memberExpression); } //Console.WriteLine(lambdaExpression(10)); Console.ReadKey(); }
public override object GetData(int actionType) { //return base.GetData(actionType); ResponseObj = new TransObj(); StringBuilder sql; ExcelLoader exLoader; string path; int cat, i = 0; try { switch ((ActionType)actionType) { case ActionType.GetCatalog: #region GetCatalog GeneralController catController = new CatalogsController(); //cat = int.Parse(RequestObj.TransParms.Where(p => p.Key == "cat").FirstOrDefault().Value); catController.RequestObj = this.RequestObj; return(catController.GetData((int)CatalogsController.ActionType.GetCatalog)); #endregion case ActionType.GetWorksheets: #region GetWorksheets path = JsonConvert.DeserializeObject <string>(RequestObj.TransParms.Where(p => p.Key == "fName").FirstOrDefault().Value); exLoader = new ExcelLoader(); return(exLoader.LoadWorkSheets(path)); #endregion case ActionType.ImportDespachos: #region ImportDespachos path = JsonConvert.DeserializeObject <string>(RequestObj.TransParms.Where(p => p.Key == "fName").FirstOrDefault().Value); string workSheet = JsonConvert.DeserializeObject <string>(RequestObj.TransParms.Where(p => p.Key == "workSheet").FirstOrDefault().Value); exLoader = new ExcelLoader(); DtDespachosIn = exLoader.LoadFile(path, workSheet); return(true); #endregion case ActionType.LoadRemitente: #region LoadRemitente var clts = Entities.Database.SqlQuery <GeneralCat>(SQL_GET_CLIENTES).ToList(); clts.Insert(0, new GeneralCat { catId = -1, catVal = "Seleccione..." }); return(clts); #endregion case ActionType.LoadCitiesFullName: #region LoadCitiesFullName CitiesFullNames = Entities.Database.SqlQuery <GeneralCat>(SQL_CIUDADES).ToList(); #endregion break; case ActionType.LoadProveedores: #region LoadProveedores Proveedores = Entities.Database.SqlQuery <GeneralCat>(string.Format(SQL_PROVEEDORES, ClienteID)).ToList(); #endregion break; case ActionType.IsInDespacho: #region IsInDespacho ConsecCliente = Entities.Database.SqlQuery <string>(SQL_IS_IN_DESPACHO, ClienteID).ToList(); #endregion break; case ActionType.InsertDespachos: #region InsertDespachos //int cId = JsonConvert.DeserializeObject<int>(RequestObj.TransParms.Where(p => p.Key == "cId").FirstOrDefault().Value); DataRow r = null; sql = new StringBuilder(); string s = "", conCliente = ""; try { for (i = 0; i < DtDespachosOut.Rows.Count; i++) { r = DtDespachosOut.Rows[i]; if (r[COL_CONSECUTIVO_CLIENTE].ToString().Trim().Length == 0) { continue; } conCliente = r[COL_CONSECUTIVO_CLIENTE].ToString(); var e = Entities.LGC_DESPACHO. Where(d => d.CONSECUTIVO_CLIENTE == conCliente) .FirstOrDefault(); if (e != null) { sql.Clear(); throw new GeneralControllerException(string.Format("El registro en la fila {0} ya existe.(Consec:{1})", i + 1, conCliente)); } s = string.Format(SQL_IN_DESPACHO, ClienteID, EntUtils.GetStrFromDtRow(r, GV_COL_CONSECUTIVO), EntUtils.GetStrFromDtRow(r, GV_COL_CONSECUTVO_AVMK), EntUtils.GetStrFromDtRow(r, GV_COL_CONSECUTIVO_CLIENTE), EntUtils.GetDTFromDtRow(r, GV_COL_FECHA_ENVIO_ARCHIVO, false).Value.ToString("dd/MM/yyyy"), "", "", EntUtils.GetDTFromDtRow(r, GV_COL_FECHA_DE_REDENCION, false).Value.ToString("dd/MM/yyyy"), EntUtils.GetStrFromDtRow(r, GV_COL_CEDULA), EntUtils.GetStrFromDtRow(r, GV_COL_CLIENTE), EntUtils.GetStrFromDtRow(r, GV_COL_ENTREGAR_A), EntUtils.GetStrFromDtRow(r, GV_COL_DIRECCION), EntUtils.GetStrFromDtRow(r, GV_COL_CIUDAD), EntUtils.GetIntFromDtRow(r, GV_COL_DEPARTAMENTO), EntUtils.GetStrFromDtRow(r, GV_COL_TELEFONO), EntUtils.GetStrFromDtRow(r, GV_COL_CELULAR), EntUtils.GetStrFromDtRow(r, GV_COL_CORREO_ELECTRONICO), EntUtils.GetStrFromDtRow(r, GV_COL_CODIGO_PREMIO), EntUtils.GetStrFromDtRow(r, GV_COL_PREMIO), EntUtils.GetStrFromDtRow(r, GV_COL_ESPECIFICACIONES), EntUtils.GetIntFromDtRow(r, GV_COL_PROVEEDOR), EntUtils.GetIntFromDtRow(r, GV_COL_CANTIDAD), EntUtils.GetIntFromDtRow(r, GV_COL_VALOR), ClienteID); sql.Append(s); } DataBaseUtils dbUtils = new DataBaseUtils(); return(dbUtils.RunScriptFromStngBldr(sql, Entities)); } catch (Exception ex) { string rData = ""; if (r != null) { rData = string.Join("|", r.ItemArray); } throw new Exception(string.Format("Error en fila {0}. [{1}] ", i + 1, rData) + ex.Message); } #endregion default: break; } } catch (Exception ex) { throw ex; } return(ResponseObj); }
private void btnSave_Click(object sender, EventArgs e) { int rIndex; try { if (string.IsNullOrEmpty(tbGuia.Text.Trim())) { MessageBox.Show("Ingrese # de Guia"); return; } if (dtFechaEnvio.Value.Date < DateTime.Now.Date) { MessageBox.Show("La Fecha de envio no puede ser anterior a hoy."); return; } if (string.IsNullOrEmpty(tbPeso.Text.Trim())) { MessageBox.Show("Ingrese peso"); return; } if (string.IsNullOrEmpty(tbPesoRealVol.Text.Trim())) { MessageBox.Show("Ingrese peso volumetrico"); return; } if (dgvDespachos.SelectedRows.Count == 0) { MessageBox.Show("Debe seleccionar un registro"); return; } rIndex = dgvDespachos.SelectedRows[0].Index; var item = dgvDespachos.SelectedRows[0].DataBoundItem; string itemS = JsonConvert.SerializeObject(item); string obs = JsonConvert.DeserializeObject <JObject>(itemS)["CONSECUTIVO_CLIENTE"].ToString() + " - " + //JsonConvert.DeserializeObject<JObject>(itemS)["ESPECIFICACIONES"].ToString() + " - " + tbObservaciones.Text.Trim(); controller.RequestObj.TransParms.Clear(); controller.RequestObj.TransParms.Add(new TransParm("NoGuia", tbGuia.Text.Trim())); controller.RequestObj.TransParms.Add(new TransParm("fEnvio", dtFechaEnvio.Value.Date.ToString("dd/MM/yyyy"))); controller.RequestObj.TransParms.Add(new TransParm("peso", tbPeso.Text.Trim())); controller.RequestObj.TransParms.Add(new TransParm("pesoVol", tbPesoRealVol.Text.Trim())); controller.RequestObj.TransParms.Add(new TransParm("pesoLiq", tbPesoLiq.Text.Trim())); controller.RequestObj.TransParms.Add(new TransParm("obs", obs)); controller.RequestObj.TransParms.Add(new TransParm("data", itemS)); controller.RequestObj.TransParms.Add(new TransParm("usId", Program.usrObj.UsrId.ToString())); controller.RequestObj.TransParms.Add(new TransParm("provId", cbAliado.SelectedValue.ToString())); controller.RequestObj.TransParms.Add(new TransParm("NoGuiaAl", tbGuiaAliado.Text.Trim())); TransObj response = (TransObj)controller.GetData((int)GuiasController.ActionType.SaveData); if (response.MessCode == TransObj.MessCodes.Ok) //printObj = JsonConvert.DeserializeObject<JObject>(response.TransParms.Where(r => r.Key == "sGuia").FirstOrDefault().Value); { controller.RequestObj.TransParms.Clear(); if (controller.LastSearch == GuiasController.ActionType.GetDespachoByNumGuia) { int[] d = (int[])controller.LastSearchData; controller.RequestObj.TransParms.Add(new TransParm("ini", d[0].ToString())); controller.RequestObj.TransParms.Add(new TransParm("end", d[1].ToString())); } else { controller.RequestObj.TransParms.Add(new TransParm("id", controller.LastSearchData.ToString())); } dgvDespachos.DataSource = controller.GetData((int)controller.LastSearch); dgvDespachos.Rows[rIndex].Selected = true; MessageBox.Show("Datos guardados."); tbGuiaAliado.Text = string.Empty; } //else //{ // printObj = null; // MessageBox.Show(response.Mess); //} } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 将一个对象数据拷贝到另一个对象 /// 表达式树的方式拷贝 /// </summary> /// <typeparam name="TSource"></typeparam> /// <typeparam name="TTarget"></typeparam> /// <param name="source"></param> /// <param name="target"></param> /// <returns></returns> public static TTarget CopyToObj <TSource, TTarget>(this TSource source, TTarget target) { return(TransObj <TSource, TTarget> .Trans(source)); }