public ActionResult List(string Method, string Key, string NodeId) { object objResult = null; try { List <ModelForGasCardWithCommInfo> list = new List <ModelForGasCardWithCommInfo>(); if (string.IsNullOrWhiteSpace(NodeId)) { list = DataLoader.GetAllGasCardWithCommInfoList(); int page = string.IsNullOrWhiteSpace(Request["page"]) ? 1 : Int32.Parse(Request["page"]); int rows = string.IsNullOrWhiteSpace(Request["rows"]) ? 1 : Int32.Parse(Request["rows"]); string order = string.IsNullOrWhiteSpace(Request["order"]) ? "DESC" : Request["order"].ToUpper(); string sort = string.IsNullOrWhiteSpace(Request["sort"]) ? "Id" : Request["sort"]; IQueryable <GasCardWithCommInfo> query = CommonTools.DataSorting <GasCardWithCommInfo>(list.AsQueryable(), sort, order).Skip((page - 1) * rows).Take(rows); objResult = new { total = list.Count, rows = query }; } else { string[] strNodeIdSplit = NodeId.Split('_'); string strType = strNodeIdSplit[0]; string strId = strNodeIdSplit[1]; int iId = DataFormat.ConvertDBNullToInt32(strId); using (LedDb db = new LedDb()) { if (Method == "FirstLoad") { if (string.IsNullOrWhiteSpace(NodeId)) { list = DataLoader.GetAllGasCardWithCommInfoList(); } else { if (strType == "org") { list = DataLoader.GetGasCardWithCommInfoByOrgId(strId); } else if (strType == "group") { list = DataLoader.GetGasCardWithCommInfoByGorupID(strId); } else if (strType == "project") { list = DataLoader.GetGasCardWithCommInfoByProjectID(strId); } } } else if (Method == "SearchLoad") { //list = db.GasCardWithCommInfo.Where(p => p.Name.Contains(Key) && p.IsDel != 1).ToList(); } int page = string.IsNullOrWhiteSpace(Request["page"]) ? 1 : Int32.Parse(Request["page"]); int rows = string.IsNullOrWhiteSpace(Request["rows"]) ? 1 : Int32.Parse(Request["rows"]); string order = string.IsNullOrWhiteSpace(Request["order"]) ? "DESC" : Request["order"].ToUpper(); string sort = string.IsNullOrWhiteSpace(Request["sort"]) ? "Id" : Request["sort"]; IQueryable <GasCardWithCommInfo> query = CommonTools.DataSorting <GasCardWithCommInfo>(list.AsQueryable(), sort, order).Skip((page - 1) * rows).Take(rows); objResult = new { total = list.Count, rows = query }; } } } catch (Exception ex) { objResult = new ResultHelper() { Desc = ex.Message, Msg = ex.Message, Obj = null, Ret = -1, Status = false }; //throw; } return(Json(objResult)); }
public ActionResult SaveBatchOilPrice(string Price1, string Price2, string Price3, string Price4, string Price5, string Price6, string Price7, string Price8, string Price9, string Price10, string Price11, string Price12, string BatchIds) { ResultHelper objResult = null; try { string Context = Price1 + "-" + Price2 + "-" + Price3 + "-" + Price4 + "-" + Price5 + "-" + Price6 + "-" + Price7 + "-" + Price8 + "-" + Price9 + "-" + Price10 + "-" + Price11 + "-" + Price12; using (LedDb db = new LedDb()) { if (ModelState.IsValid) { StringBuilder strSql = new StringBuilder(); strSql.AppendFormat(@"UPDATE GasCardWithCommInfo SET CardContext = {0} WHERE Id IN ({1})", Context, BatchIds); if (db.Database.ExecuteSqlCommand(strSql.ToString()) > 0) { objResult = new ResultHelper() { Status = true, Ret = 0, Obj = BatchIds, Msg = "Batch Upadate Success!", Desc = "Batch Upadate Success!" }; string[] id = BatchIds.Split(','); for (int i = 0; i < id.Length; i++) { int iID = DataFormat.ConvertDBNullToInt32(id[i]); SendCMD(iID, Context); } } else { objResult = new ResultHelper() { Desc = "Batch Upadate Faile,please try again.", Msg = "Batch Upadate Faile,please try again.", Obj = null, Ret = -1, Status = false }; } } else { objResult = new ResultHelper() { Desc = " Faile,please try again", Msg = " Faile,please try again", Obj = null, Ret = -1, Status = false }; } } } catch (Exception ex) { objResult = new ResultHelper() { Desc = ex.Message, Msg = ex.Message, Obj = null, Ret = -1, Status = false }; } return(Json(objResult)); }