本文整理汇总了C#中SES.Service.OrmliteConnection.Select方法的典型用法代码示例。如果您正苦于以下问题:C# OrmliteConnection.Select方法的具体用法?C# OrmliteConnection.Select怎么用?C# OrmliteConnection.Select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SES.Service.OrmliteConnection
的用法示例。
在下文中一共展示了OrmliteConnection.Select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAllCustomerHirerachy
public List<CustomerHirerachy> GetAllCustomerHirerachy()
{
IDbConnection db = new OrmliteConnection().openConn();
var lst = db.Select<CustomerHirerachy>().Where(p => p.Status == true).ToList();
db.Close();
return lst;
}
示例2: CancelSalesOrder
public ActionResult CancelSalesOrder(string data)
{
var dbConn = new OrmliteConnection().openConn();
if (userAsset.ContainsKey("Insert") && userAsset["Insert"])
{
try
{
string[] separators = { "@@" };
var listdata = data.Split(separators, StringSplitOptions.RemoveEmptyEntries);
foreach (var item in listdata)
{
if (dbConn.Select<SOHeader>("Select * from SOHeader where Status <> N'Mới' AND SONumber = '"+item+"'").Count() > 0)
{
return Json(new { success = false, message = "Chỉ hủy được các mẫu tin có trạng thái Mới" });
}
dbConn.Update<SOHeader>(set: "Status = N'Hủy'", where: "SONumber = '" + item + "'");
}
}
catch (Exception e)
{
return Json(new { success = false, message = e.Message });
}
return Json(new{success = true});
}
else{
return Json(new { success = false, message = "Bạn không có quyền hủy." });
}
}
示例3: CompletePicking
public ActionResult CompletePicking(string data)
{
var dbConn = new OrmliteConnection().openConn();
if (userAsset.ContainsKey("Update") && userAsset["Update"])
{
try
{
string[] separators = { "@@" };
var listdata = data.Split(separators, StringSplitOptions.RemoveEmptyEntries);
foreach (var item in listdata)
{
if (dbConn.Select<DC_AD_Picking_Header>(s => s.Status == "Hoàn thành" && s.PickingNumber == item).Count() > 0)
{
return Json(new { success = false, message = item + " đã được hoàn thành trước đó." });
}
if (dbConn.Select<DC_AD_Picking_Header>(s =>s.Status != "Đang giao hàng" && s.PickingNumber==item).Count() > 0)
{
return Json(new { success = false, message = item + " vui lòng nhập kho trước khi hoàn thành." });
}
dbConn.Update<DC_AD_Picking_Header>(set: "Status = N'Hoàn thành', UpdatedBy ='" + currentUser.UserID + "', UpdatedAt= '"+DateTime.Now+"'", where: "PickingNumber = '" + item + "'");
foreach (var so in dbConn.Select<DC_AD_Picking_Detail>(s => s.PickingNumber == item).ToList())
{
dbConn.Update<SOHeader>(set: "Status = N'Hoàn thành'", where: "SONumber = '" + so.SONumber + "'");
}
//dbConn.Update<DC_AD_SO_Header>(set: "Status = N'Hoàn thành'", where: "SONumber = '" + item + "'");
}
}
catch (Exception e)
{
return Json(new { success = false, message = e.Message });
}
return Json(new { success = true });
}
else
{
return Json(new { success = false, message = "Bạn không có quyền hủy." });
}
}
示例4: GetActiveStatus
public List<ActiveStatus> GetActiveStatus()
{
IDbConnection dbConn = new OrmliteConnection().openConn();
var list = new List<ActiveStatus>();
try
{
list = dbConn.Select<ActiveStatus>("SELECT StatusValue, StatusName,IsAllMerchant,IsAllDistric FROM vw_List_Active_Status");
}
catch (Exception)
{
throw;
}
finally { dbConn.Close(); }
return list;
}
示例5: ConfirmCreate
public ActionResult ConfirmCreate()
{
var dbConn = new OrmliteConnection().openConn();
if (userAsset.ContainsKey("Insert") && userAsset["Insert"])
{
try
{
string SONumber = Request["SONumber"];
var header = new SOHeader();
var detail = new SODetail();
if (string.IsNullOrEmpty(SONumber))
{
string datetimeSO = DateTime.Now.ToString("yyMMdd");
var existSO = dbConn.SingleOrDefault<SOHeader>("SELECT id, SONumber FROM SOHeader ORDER BY Id DESC");
if (existSO != null)
{
var nextNo = Int32.Parse(existSO.SONumber.Substring(8, 5)) + 1;
SONumber = "SO" + datetimeSO + String.Format("{0:00000}", nextNo);
}
else
{
SONumber = "SO" + datetimeSO + "00001";
}
}
if (!string.IsNullOrEmpty(Request["SODate"]))
{
DateTime fromDateValue;
if (!DateTime.TryParseExact(Request["SODate"], "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out fromDateValue))
{
return Json(new { message = "Ngày tạo không đúng." });
}
}
if (dbConn.Select<DC_OCM_Merchant>(p => p.MerchantID == Request["MerchantID"]).Count() <= 0)
{
return Json(new { success = false, message = "Nhà cung cấp không tồn tại." });
}
if (dbConn.Select<SODetail>(p => p.SONumber == SONumber).Count() > 0)
{
if (!string.IsNullOrEmpty(Request["ItemCode"]))
{
if (dbConn.Select<Products>(p => p.Code == Request["ItemCode"]).Count() <= 0)
{
return Json(new { success = false, message = "Ấn phẩm không tồn tại." });
}
var itemcode = dbConn.Select<Products>(s => s.Code == Request["ItemCode"]).FirstOrDefault();
var itemunit = dbConn.Select<Products>(s => s.UnitID == itemcode.Unit).FirstOrDefault();
if (dbConn.Select<SODetail>(p => p.ItemCode == Request["ItemCode"] && p.SONumber == SONumber).Count() > 0)
{
var success = dbConn.Execute(@"UPDATE SODetail Set Qty = @Qty, TotalAmt [email protected] ,UpdatedAt = @UpdatedAt, UpdatedBy = @UpdatedBy, Price = @Price
WHERE SONumber = '" + SONumber + "' AND ItemCode = '" + Request["ItemCode"] + "'", new
{
Qty = dbConn.Select<SODetail>(s => s.ItemCode == Request["ItemCode"] && s.SONumber == SONumber).Sum(s => s.Qty) + int.Parse(Request["Qty"]),
TotalAmt = itemcode != null ? itemcode.VATPrice * (dbConn.Select<SODetail>(s => s.ItemCode == Request["ItemCode"] && s.SONumber == SONumber).Sum(s => s.Qty) + int.Parse(Request["Qty"])) : 0,
Price = itemcode.VATPrice,
UpdatedBy = currentUser.UserID,
UpdatedAt = DateTime.Now,
}) == 1;
if (!success)
{
return Json(new { success = false, message = "Không thể lưu" });
}
}
else
{
detail.SONumber = SONumber;
detail.ItemCode = !string.IsNullOrEmpty(Request["ItemCode"]) ? Request["ItemCode"] : "";
detail.ItemName = !string.IsNullOrEmpty(itemcode.Name) ? itemcode.Name : "";
detail.Price = itemcode != null ? itemcode.VATPrice : 0;
detail.Qty = int.Parse(Request["Qty"]);
detail.TotalAmt = itemcode.VATPrice * int.Parse(Request["Qty"]);
detail.UnitID = !string.IsNullOrEmpty(itemunit.UnitID) ? itemunit.UnitID : "";
detail.UnitName = !string.IsNullOrEmpty(itemunit.UnitName) ? itemunit.UnitName : "";
detail.Note = "";
detail.Status = "";
detail.CreatedBy = currentUser.UserID;
detail.CreatedAt = DateTime.Now;
detail.UpdatedBy = "";
detail.UpdatedAt = DateTime.Parse("1900-01-01");
dbConn.Insert<SODetail>(detail);
}
}
}
else
{
if (string.IsNullOrEmpty(Request["ItemCode"]) || dbConn.Select<Products>(p => p.Code == Request["ItemCode"]).Count() <= 0)
{
return Json(new { success = false, message = "Ấn phẩm không tồn tại." });
}
var itemcode = dbConn.Select<Products>(s => s.Code == Request["ItemCode"]).FirstOrDefault();
var itemunit = dbConn.Select<Products>(s => s.UnitID == itemcode.Unit).FirstOrDefault();
detail.SONumber = SONumber;
detail.ItemCode = !string.IsNullOrEmpty(Request["ItemCode"]) ? Request["ItemCode"] : "";
detail.ItemName = !string.IsNullOrEmpty(itemcode.Name) ? itemcode.Name : "";
detail.Price = itemcode != null ? itemcode.VATPrice :0 ;
detail.Qty = int.Parse(Request["Qty"]);
detail.TotalAmt = itemcode.VATPrice * int.Parse(Request["Qty"]);
detail.UnitID = !string.IsNullOrEmpty(itemunit.UnitID) ? itemunit.UnitID : "";
detail.UnitName = !string.IsNullOrEmpty(itemunit.UnitName) ? itemunit.UnitName : "";
//.........这里部分代码省略.........
示例6: ReadHeader
public ActionResult ReadHeader([DataSourceRequest] DataSourceRequest request)
{
var dbConn = new OrmliteConnection().openConn();
var data = new List<SOHeader>();
if(request.Filters.Any())
{
var where = new KendoApplyFilter().ApplyFilter(request.Filters[0]);
data = dbConn.Select<SOHeader>(where);
}
else{
data = dbConn.Select<SOHeader>();
}
return Json(data.ToDataSourceResult(request));
}
示例7: PartialCustomer
public ActionResult PartialCustomer()
{
if (userAsset.ContainsKey("View") && userAsset["View"])
{
IDbConnection dbConn = new OrmliteConnection().openConn();
var dict = new Dictionary<string, object>();
dict["asset"] = userAsset;
dict["activestatus"] = new CommonLib().GetActiveStatus();
dict["listprovince"] = dbConn.Select<Master_Territory>("Select TerritoryID,TerritoryName From Master_Territory where Level ='Province'");
dict["listdistrict"] = dbConn.Select<Master_Territory>("Select TerritoryID,TerritoryName From Master_Territory where Level ='District'");
dbConn.Close();
return PartialView("_Customer", dict);
}
else
return RedirectToAction("NoAccess", "Error");
}
示例8: PartialRole
public ActionResult PartialRole()
{
if (userAsset.ContainsKey("View") && userAsset["View"])
{
IDbConnection dbConn = new OrmliteConnection().openConn();
var dict = new Dictionary<string, object>();
dict["asset"] = userAsset;
dict["activestatus"] = new CommonLib().GetActiveStatus();
dict["user"] = dbConn.Select<Auth_User>(p => p.IsActive == true);
dict["listWH"] = dbConn.Select<WareHouse>(p => p.Status == true);
dict["listWHL"] = dbConn.Select<WareHouseLocation>(p => p.Status == true);
dict["listUnit"] = dbConn.Select<DC_AD_Unit>(p => p.Status == true);
dbConn.Close();
return PartialView("_ListPublication", dict);
}
else
return RedirectToAction("NoAccess", "Error");
}
示例9: Export
public ActionResult Export([DataSourceRequest]DataSourceRequest request)
{
if (userAsset["Export"])
{
using (var dbConn = new OrmliteConnection().openConn())
{
//using (ExcelPackage excelPkg = new ExcelPackage())
FileInfo fileInfo = new FileInfo(Server.MapPath(@"~\ExportTemplate\DanhMucAnPham.xlsx"));
var excelPkg = new ExcelPackage(fileInfo);
string fileName = "ThongTinKho_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xlsx";
string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
var data = new List<Products>();
if (request.Filters.Any())
{
var where = new KendoApplyFilter().ApplyFilter(request.Filters[0], "data.");
//data = dbConn.Select<Products>(where);
data = dbConn.Query<Products>("p_SelectDC_AD_Item_Export", new { WhereCondition = where}, commandType:System.Data.CommandType.StoredProcedure).ToList();
}
else
{
//data = dbConn.Select<Products>();
data = dbConn.Query<Products>("p_SelectDC_AD_Item_Export", new { WhereCondition = "1=1" }, commandType: System.Data.CommandType.StoredProcedure).ToList();
}
ExcelWorksheet expenseSheet = excelPkg.Workbook.Worksheets["Data"];
int rowData = 1;
foreach (var item in data)
{
int i = 1;
rowData++;
expenseSheet.Cells[rowData, i++].Value = item.Code;
expenseSheet.Cells[rowData, i++].Value = item.Name;
expenseSheet.Cells[rowData, i++].Value = item.Size;
expenseSheet.Cells[rowData, i++].Value = item.VATPrice;
expenseSheet.Cells[rowData, i++].Value = item.Type;
expenseSheet.Cells[rowData, i++].Value = item.UnitName+"/"+item.UnitID;
expenseSheet.Cells[rowData, i++].Value = item.WHName +"/"+item.WHID;
expenseSheet.Cells[rowData, i++].Value = item.WHLName + "/" +item.WHLID;
expenseSheet.Cells[rowData, i++].Value = item.ShapeTemplate;
if (item.Status == true)
{
expenseSheet.Cells[rowData, i++].Value = "Đang hoạt động";
}
else
{
expenseSheet.Cells[rowData, i++].Value = "Ngưng hoạt động";
}
expenseSheet.Cells[rowData, i++].Value = item.CreatedBy;
expenseSheet.Cells[rowData, i++].Value = item.CreatedAt;
expenseSheet.Cells[rowData, i++].Value = item.UpdatedBy;
if (item.UpdatedAt != DateTime.Parse("1900-01-01"))
{
expenseSheet.Cells[rowData, i++].Value = item.UpdatedAt;
}
else
{
expenseSheet.Cells[rowData, i++].Value = "";
}
//expenseSheet.Cells[rowData, i++].Value = item.RowLastUpdatedTime;
}
expenseSheet = excelPkg.Workbook.Worksheets["Warehouse"];
var listWH = dbConn.Select<WareHouse>("SELECT * FROM WareHouse WHERE Status = 1");
rowData = 1;
foreach (var item in listWH)
{
int i = 1;
rowData++;
expenseSheet.Cells[rowData, i++].Value = item.WHName + "/" + item.WHID;
}
expenseSheet = excelPkg.Workbook.Worksheets["Location"];
var listWHL = dbConn.Select<WareHouseLocation>("SELECT * FROM WareHouseL WHERE Status = 1");
rowData = 1;
foreach (var item in listWHL)
{
int i = 1;
rowData++;
expenseSheet.Cells[rowData, i++].Value = item.WHLName + "/" + item.WHLID;
}
expenseSheet = excelPkg.Workbook.Worksheets["Unit"];
var listUnit = dbConn.Select<DC_AD_Unit>("SELECT * FROM DC_AD_Unit WHERE Status = 1");
rowData = 1;
foreach (var item in listUnit)
{
int i = 1;
rowData++;
expenseSheet.Cells[rowData, i++].Value = item.UnitName + "/" + item.UnitID;
}
MemoryStream output = new MemoryStream();
excelPkg.SaveAs(output);
output.Position = 0;
return File(output.ToArray(), contentType, fileName);
}
}
else
{
//.........这里部分代码省略.........
示例10: Read
//
// GET: /DeliveryManage/Details/5
public ActionResult Read([DataSourceRequest]DataSourceRequest request)
{
var dbConn = new OrmliteConnection().openConn();
string whereCondition = "";
if (request.Filters.Count > 0)
{
whereCondition = new KendoApplyFilter().ApplyFilter(request.Filters[0]);
}
var data = dbConn.Select<DC_LG_Transporter>(whereCondition).OrderBy(p=>p.Weight);
return Json(data.ToDataSourceResult(request));
}
示例11: Initialize
protected override void Initialize(System.Web.Routing.RequestContext requestContext)
{
base.Initialize(requestContext);
if (this.User.Identity.IsAuthenticated)
{
IDbConnection dbConn = new OrmliteConnection().openConn();
lstAssetDefault = InitAssetDefault();
currentUser = dbConn.GetByIdOrDefault<Auth_User>(User.Identity.Name);
currentUserRole = dbConn.SqlList<Auth_Role>("EXEC p_Auth_UserInRole_Select_By_UserID @UserID", new { UserID = User.Identity.Name });
string controllerName = this.GetType().Name;
controllerName = controllerName.Substring(0, controllerName.IndexOf("Controller"));
var lstAsset = new List<Auth_Action>();
// Get MenuID from controller name
string menuID = dbConn.SingleOrDefault<Auth_Menu>("ControllerName = {0}", controllerName).MenuID;
foreach (var g in currentUserRole)
{
// Get List Asset
var temp = dbConn.Select<Auth_Action>(p => p.RoleID == g.RoleID && p.MenuID == menuID);
if (temp.Count > 0)
lstAsset.AddRange(temp);
}
if(lstAsset.Count == 0)
{
var item = new Auth_Action();
item.MenuID = menuID;
item.Note = "";
item.RowCreatedAt = DateTime.Now;
item.RowCreatedBy = "System";
if (currentUser.UserID == ConfigurationManager.AppSettings["superadmin"])
{
item.RoleID = 1;
item.IsAllowed = true;
foreach(var asset in lstAssetDefault)
{
item.Action = asset;
dbConn.Insert<Auth_Action>(item);
}
}
else
{
item.RoleID = currentUserRole.FirstOrDefault().RoleID;
item.IsAllowed = false;
foreach (var asset in lstAssetDefault)
{
item.Action = asset;
dbConn.Insert<Auth_Action>(item);
}
}
}
else
{
foreach (var g in currentUserRole)
{
// Asset
var lst = lstAsset.Where(p => p.RoleID == g.RoleID).ToList();
foreach(var item in lst)
{
if (!userAsset.ContainsKey(item.Action))
userAsset.Add(item.Action, item.IsAllowed);
else if(item.IsAllowed)
{
userAsset.Remove(item.Action);
userAsset.Add(item.Action, item.IsAllowed);
}
}
}
}
// Get Asset View Menu
foreach (var g in currentUserRole)
{
var lstView = dbConn.Select<Auth_Action>(p => p.RoleID == g.RoleID && p.Action == "View");
//var lstView = new Auth_Menu().GetMenuByRoleID(g.RoleID);
foreach (var i in lstView)
{
if (!dictView.ContainsKey("menu_" + i.MenuID))
{
if(i.IsAllowed)
{
dictView.Add("menu_" + i.MenuID, true);
}
}
}
}
ViewData["menuView"] = dictView;
dbConn.Close();
}
}
示例12: GetTransByID
public ActionResult GetTransByID(string id)
{
IDbConnection dbConn = new OrmliteConnection().openConn();
try
{
var listStran = dbConn.Select<DC_LG_Contract_Transporter>("ContractID={0}",id);
return Json(new { success = true, listtran = listStran });
}
catch (Exception e)
{
return Json(new { success = false, message = e.Message });
}
finally { dbConn.Close(); }
}
示例13: CreatePO
public ActionResult CreatePO(string data, string printer, string delivery)
{
var dbConn = new OrmliteConnection().openConn();
if (userAsset.ContainsKey("Insert") && userAsset["Insert"])
{
try
{
string[] separators = { "@@" };
var listdata = data.Split(separators, StringSplitOptions.RemoveEmptyEntries);
string PONumber = "";
string datetimeSO = DateTime.Now.ToString("yyMMdd");
var existSO = dbConn.SingleOrDefault<DC_AD_PO_Header>("SELECT id, PONumber FROM DC_AD_PO_Header ORDER BY Id DESC");
if (existSO != null)
{
var nextNo = Int32.Parse(existSO.PONumber.Substring(8, 5)) + 1;
PONumber = "PO" + datetimeSO + String.Format("{0:00000}", nextNo);
}
else
{
PONumber = "PO" + datetimeSO + "00001";
}
if (!string.IsNullOrEmpty(delivery))
{
DateTime fromDateValue;
if (!DateTime.TryParseExact(delivery, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out fromDateValue))
{
return Json(new { message = "Ngày tạo không đúng." });
}
}
var detail = new DC_AD_PO_Detail();
foreach (var item in listdata)
{
if (dbConn.Select<SOHeader>(s => s.Status != "Mới" && s.SONumber == item).Count() > 0)
{
return Json(new { success = false, message = "Không thể đặt hàng." });
}
foreach (var dtSO in dbConn.Select<SODetail>(s => s.SONumber == item).ToList())
{
if (dbConn.Select<DC_AD_PO_Detail>(s => s.PONumber == PONumber && s.ItemCode == dtSO.ItemCode).Count() > 0)
{
var success = dbConn.Execute(@"UPDATE DC_AD_PO_Detail Set Qty = @Qty, TotalAmt [email protected] ,UpdatedAt = @UpdatedAt, UpdatedBy = @UpdatedBy, Price = @Price
WHERE PONumber = '" + PONumber + "' AND ItemCode = '" + dtSO.ItemCode + "'", new
{
Qty = dbConn.Select<DC_AD_PO_Detail>(s => s.PONumber == PONumber && s.ItemCode == dtSO.ItemCode).Sum(s => s.Qty) + dtSO.Qty,
TotalAmt = dbConn.Select<DC_AD_PO_Detail>(s => s.PONumber == PONumber && s.ItemCode == dtSO.ItemCode).Sum(s => s.TotalAmt)+dtSO.TotalAmt,
Price = dtSO.Price,
UpdatedBy = currentUser.UserID,
UpdatedAt = DateTime.Now,
}) == 1;
if (!success)
{
return Json(new { success = false, message = "Không thể lưu" });
}
}
else
{
detail.PONumber = PONumber;
detail.ItemCode = !string.IsNullOrEmpty(dtSO.ItemCode) ? dtSO.ItemCode : "";
detail.ItemName = !string.IsNullOrEmpty(dtSO.ItemName) ? dtSO.ItemName : "";
detail.Price = dtSO.Price;
detail.Qty = dtSO.Qty;
detail.TotalAmt = dtSO.TotalAmt;
detail.UnitID = !string.IsNullOrEmpty(dtSO.UnitID) ? dtSO.UnitID : "";
detail.UnitName = !string.IsNullOrEmpty(dtSO.UnitName) ? dtSO.UnitName : "";
detail.Note = "";
detail.Status = "Mới";
detail.CreatedBy = currentUser.UserID;
detail.CreatedAt = DateTime.Now;
detail.UpdatedBy = "";
detail.UpdatedAt = DateTime.Parse("1900-01-01");
dbConn.Insert<DC_AD_PO_Detail>(detail);
}
}
dbConn.Update<SOHeader>(set: "Status = N'Đã đặt hàng'", where: "SONumber = '" + item + "'");
}
var header = new DC_AD_PO_Header();
header.PONumber = PONumber;
header.PODate = DateTime.Now;
header.DeliveryDate = !string.IsNullOrEmpty(delivery) ? DateTime.Parse(DateTime.ParseExact(delivery, "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("yyyy-MM-dd")) : DateTime.Now;
header.PrinterID = printer;
header.PrinterName = dbConn.Select<DC_AD_Printer>(s => s.PrinterID == printer).FirstOrDefault().PrinterName;
header.TotalQty = dbConn.Select<DC_AD_PO_Detail>(s => s.PONumber == PONumber).Sum(s => s.Qty);
header.TotalAmt = dbConn.Select<DC_AD_PO_Detail>(s => s.PONumber == PONumber).Sum(s => s.TotalAmt);
header.Note = "";
header.Status = "Nhà in đang xử lý";
header.CreatedBy = currentUser.UserID;
header.CreatedAt = DateTime.Now;
header.UpdatedBy = "";
header.UpdatedAt = DateTime.Parse("1900-01-01");
dbConn.Insert<DC_AD_PO_Header>(header);
}
catch (Exception ex)
{
return Json(new { success = false, message = ex.Message });
}
return Json(new { success = true });
}
else
{
//.........这里部分代码省略.........
示例14: ReadAction
//========================================== Tab Phân quyền chức năng =================================
public ActionResult ReadAction([DataSourceRequest]DataSourceRequest request, int roleid, string menuid)
{
var data = new List<Auth_Action>();
if (roleid > 0 && !string.IsNullOrEmpty(menuid))
{
IDbConnection db = new OrmliteConnection().openConn();
data = db.Select<Auth_Action>(p => p.RoleID == roleid && p.MenuID == menuid &&
p.Action != "View" &&
p.Action != "Insert" &&
p.Action != "Update" &&
p.Action != "Delete" &&
p.Action != "Export" &&
p.Action != "Import");
db.Close();
}
return Json(data.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
示例15: GetMenu
//public JsonResult GetMenu([DataSourceRequest] DataSourceRequest request)
//{
// IDbConnection db = new OrmliteConnection().openConn();
// try
// {
// var listMenu = db.Select<Auth_Menu>(p => p.IsVisible == true).OrderBy(p => p.MenuIndex).ToList();
// DataSourceResult dsr = new DataSourceResult();
// dsr.Data = listMenu;
// return Json(dsr, JsonRequestBehavior.AllowGet);
// }
// catch (Exception e)
// {
// return Json(new { success = false, message = e.Message });
// }
// finally { db.Close(); }
//}
//[HttpPost]
public JsonResult GetMenu(string action, int roleID)
{
IDbConnection db = new OrmliteConnection().openConn();
try
{
//select list menu cha
List<Auth_Menu> lstFirstMenu = db.Select<Auth_Menu>("IsVisible = 1 AND ParentMenuID ='' AND MenuID <> 'Home'").OrderBy(p => p.MenuIndex).ToList();
List<Auth_Menu> allAuthMenu = db.Select<Auth_Menu>("IsVisible = 1 AND MenuID <> 'Home'").OrderBy(p => p.MenuIndex).ToList();
var listAction = new List<Auth_Menu>();
if (!string.IsNullOrEmpty(action))
{
listAction = db.SqlList<Auth_Menu>("p_Auth_Menu_Select_By_Action '" + action + "', " + roleID);
}
List<AuthMenuViewModel> lstMenuView = new List<AuthMenuViewModel>();
foreach (Auth_Menu der in lstFirstMenu)
{
AuthMenuViewModel node = new AuthMenuViewModel();
node.id = der.MenuID;
node.text = der.MenuName;
node.items = new List<AuthMenuViewModel>();
AddChidrenNode(ref node, allAuthMenu,listAction);
lstMenuView.Add(node);
}
return Json(new { success = true, Data = lstMenuView });
}
catch (Exception e)
{
return Json(new { success = false, message = e.Message });
}
finally { db.Close(); }
}