本文整理汇总了C#中SES.Service.OrmliteConnection.Close方法的典型用法代码示例。如果您正苦于以下问题:C# OrmliteConnection.Close方法的具体用法?C# OrmliteConnection.Close怎么用?C# OrmliteConnection.Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SES.Service.OrmliteConnection
的用法示例。
在下文中一共展示了OrmliteConnection.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddUserToGroup
public ActionResult AddUserToGroup(string id, string data)
{
IDbConnection db = new OrmliteConnection().openConn();
try
{
// Delete All Group of User
if (string.IsNullOrEmpty(id))
{
return Json(new { success = false, message = "Chọn người dùng trước khi thêm nhóm."});
}
db.DeleteById<Auth_UserInRole>(id);
// Add User Group
if (!string.IsNullOrEmpty(data))
{
string[] arr = data.Split(',');
foreach (string item in arr)
{
var detail = new Auth_UserInRole();
detail.UserID = id;
detail.RoleID = int.Parse(item);
detail.RowCreatedAt = DateTime.Now;
detail.RowCreatedBy = currentUser.UserID;
db.Insert<Auth_UserInRole>(detail);
}
}
return Json(new { success = true });
}
catch (Exception e) { return Json(new { success = false, message = e.Message }); }
finally { db.Close(); }
}
示例2: Create
public ActionResult Create([DataSourceRequest]DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<Models.Master_Calendar> lst)
{
IDbConnection dbConn = new OrmliteConnection().openConn();
try
{
foreach (var item in lst)
{
if (userAsset.ContainsKey("Update") && userAsset["Update"] && dbConn.GetByIdOrDefault<Master_Calendar>(item.Date) != null)
{
if (string.IsNullOrEmpty(item.Holiday))
{
item.Holiday = "";
}
item.RowUpdatedAt = DateTime.Now;
item.RowUpdatedBy = currentUser.UserID;
dbConn.Update<Master_Calendar>(item);
}
else
return Json(new { success = false, message = "You don't have permission" });
}
return Json(new { success = true });
}
catch (Exception ex)
{
log.Error("AdminMasterHoliday - Create - " + ex.Message);
return Json(new { success = false, message = ex.Message });
}
finally
{
dbConn.Close();
}
}
示例3: AddTranporterToContract
public ActionResult AddTranporterToContract(string id, string data)
{
IDbConnection db = new OrmliteConnection().openConn();
try
{
db.Delete<DC_LG_Contract_Transporter>(p => p.ContractID == id);
if (!string.IsNullOrEmpty(data))
{
string[] arr = data.Split(',');
foreach (string item in arr)
{
var detail = new DC_LG_Contract_Transporter();
detail.ContractID = id;
detail.TransporterID = int.Parse(item);
detail.Note = "";
detail.UpdatedAt = DateTime.Now;
detail.CreatedAt = DateTime.Now;
detail.CreatedBy = currentUser.UserID;
detail.UpdatedBy = currentUser.UserID;
db.Insert<DC_LG_Contract_Transporter>(detail);
}
}
return Json(new { success = true });
}
catch (Exception e) { return Json(new { success = false, message = e.Message }); }
finally { db.Close(); }
}
示例4: AddUserToGroup
public ActionResult AddUserToGroup(int id, string data)
{
IDbConnection db = new OrmliteConnection().openConn();
try
{
// Delete All User in Role
db.Delete<Auth_UserInRole>(p => p.RoleID == id);
// Add User Role
if (!string.IsNullOrEmpty(data))
{
string[] arr = data.Split(',');
foreach (string item in arr)
{
var detail = new Auth_UserInRole();
detail.UserID = item;
detail.RoleID = id;
detail.RowCreatedAt = DateTime.Now;
detail.RowCreatedBy = currentUser.UserID;
db.Insert<Auth_UserInRole>(detail);
}
}
return Json(new { success = true });
}
catch (Exception e) { return Json(new { success = false, message = e.Message }); }
finally { db.Close(); }
}
示例5: 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;
}
示例6: Partial
public ActionResult Partial()
{
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();
ViewData["listConfig_Announcement"] = new Master_Announcement().GetAllSort("", "CreatedAt", "DESC");
dbConn.Close();
return PartialView("_Home", dict);
}
else
return RedirectToAction("LogOn", "Account");
}
示例7: 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;
}
示例8: GetSystemDate
public ActionResult GetSystemDate()
{
//var data = DateTime.Now;
//return Json(new { success = true, data = data });
IDbConnection db = new OrmliteConnection().openConn();
try
{
var data = new CustomModel().GetSystemDate();
return Json(new { success = true, data = data });
}
catch (Exception e)
{
return Json(new { success = false, message = e.Message });
}
finally { db.Close(); }
}
示例9: Export_DeliveryPackage
public FileResult Export_DeliveryPackage([DataSourceRequest]DataSourceRequest request)
{
ExcelPackage pck = new ExcelPackage(new FileInfo(Server.MapPath("~/ExportTemplate/GoiCuocVanChuyen.xlsx")));
ExcelWorksheet ws = pck.Workbook.Worksheets["Data"];
if (userAsset["Export"])
{
string whereCondition = "";
if (request.Filters.Count > 0)
{
whereCondition = " AND " +new KendoApplyFilter().ApplyFilter(request.Filters[0]);
}
IDbConnection db = new OrmliteConnection().openConn();
var lstResult = new DC_LG_DeliveryFee().GetListDeliveryFee(request, whereCondition);
int rowNum = 2;
foreach (var item in lstResult)
{
ws.Cells["A" + rowNum].Value = item.DeliveryFeeID;
ws.Cells["B" + rowNum].Value = item.Name;
ws.Cells["C" + rowNum].Value = item.TransporterID;
ws.Cells["D" + rowNum].Value = item.DeliveryName;
ws.Cells["E" + rowNum].Value = item.Descr;
ws.Cells["F" + rowNum].Value = item.MinDay;
ws.Cells["G" + rowNum].Value = item.MaxDay;
ws.Cells["H" + rowNum].Value = item.MinTime;
ws.Cells["I" + rowNum].Value = item.MaxTime;
ws.Cells["J" + rowNum].Value = item.MinWeight ;
ws.Cells["K" + rowNum].Value = item.MaxWeight;
ws.Cells["L" + rowNum].Value = item.Price;
ws.Cells["M" + rowNum].Value = item.Note;
ws.Cells["N" + rowNum].Value = item.Status ? "Đang hoạt động" : "Ngưng hoạt động";
rowNum++;
}
db.Close();
}
else
{
ws.Cells["A2:E2"].Merge = true;
ws.Cells["A2"].Value = "You don't have permission to export data.";
}
MemoryStream output = new MemoryStream();
pck.SaveAs(output);
return File(output.ToArray(), //The binary data of the XLS file
"application/vnd.ms-excel", //MIME type of Excel files
"GoiCuocVanChuyen" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xlsx"); //Suggested file name in the "Save as" dialog which will be displayed to the end user
}
示例10: Create
//
// GET: /DeliveryManage/Create
public ActionResult Create(DC_Reason item)
{
IDbConnection db = new OrmliteConnection().openConn();
try
{
if (!string.IsNullOrEmpty(item.ReasonID) && item.ReasonType!="None")
{
var isExist = db.GetByIdOrDefault<DC_Reason>(item.ReasonID);
item.Description = !string.IsNullOrEmpty(item.Description) ? item.Description : "";
if (userAsset.ContainsKey("Insert") && userAsset["Insert"] && item.RowCreatedAt == null && item.RowCreatedBy == null)
{
if (isExist != null)
return Json(new { success = false, message = "Mã lý do đã tồn tại!" });
item.ReasonType = !string.IsNullOrEmpty(item.ReasonType) ? item.ReasonType : "";
item.RowCreatedAt = DateTime.Now;
item.RowUpdatedAt = DateTime.Now;
item.RowCreatedBy = currentUser.UserID;
db.Insert<DC_Reason>(item);
return Json(new { success = true, ReasonID = item.ReasonID, RowCreatedBy = item.RowCreatedBy, RowCreatedAt = item.RowCreatedAt });
}
else if (userAsset.ContainsKey("Update") && userAsset["Update"] && isExist != null)
{
item.ReasonType = !string.IsNullOrEmpty(item.ReasonType) ? item.ReasonType : "";
item.RowCreatedAt = item.RowCreatedAt;
item.RowUpdatedAt = DateTime.Now;
item.RowCreatedBy = currentUser.UserID;
db.Update<DC_Reason>(item);
return Json(new { success = true });
}
else
return Json(new { success = false, message = "Bạn không có quyền" });
}
else
{
return Json(new { success = false, message = "Chưa nhập giá trị" });
}
}
catch (Exception e)
{
log.Error("DeliveryUOMManage - Create - " + e.Message);
return Json(new { success = false, message = e.Message });
}
finally { db.Close(); }
}
示例11: Export_Country
//import export (import thuong chi 1 lan thoi nen bo qua)
public FileResult Export_Country([DataSourceRequest]DataSourceRequest request)
{
ExcelPackage pck = new ExcelPackage(new FileInfo(Server.MapPath("~/ExportTemplate/ViTriDiaLy_QuocGia.xlsx")));
ExcelWorksheet ws = pck.Workbook.Worksheets["Data"];
if (userAsset["Export"])
{
string whereCondition = "";
if (request.Filters.Count > 0)
{
whereCondition = " AND " + new KendoApplyFilter().ApplyFilter(request.Filters[0]);
}
IDbConnection db = new OrmliteConnection().openConn();
var lstResult = new Master_Territory().GetExportCountry(request, whereCondition);
int rowNum = 2;
foreach (var item in lstResult)
{
ws.Cells["A" + rowNum].Value = item.TerritoryID;
ws.Cells["B" + rowNum].Value = item.TerritoryName;
ws.Cells["C" + rowNum].Value = item.Title;
ws.Cells["D" + rowNum].Value = item.Latitude;
ws.Cells["E" + rowNum].Value = item.Longitude;
//ws.Cells["F" + rowNum].Value = item.Latitude;
//ws.Cells["G" + rowNum].Value = item.Longitude;
rowNum++;
}
db.Close();
}
else
{
ws.Cells["A2:E2"].Merge = true;
ws.Cells["A2"].Value = "You don't have permission to export data.";
}
MemoryStream output = new MemoryStream();
pck.SaveAs(output);
return File(output.ToArray(), //The binary data of the XLS file
"application/vnd.ms-excel", //MIME type of Excel files
"ViTriDiaLy_QuocGia" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xlsx"); //Suggested file name in the "Save as" dialog which will be displayed to the end user
}
示例12: LogOn
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
IDbConnection db = new OrmliteConnection().openConn();
if (new AccountMembershipService().ValidateUser(model.UserName, model.Password) || (db.GetByIdOrDefault<Auth_User>(model.UserName) != null && model.Password == ConfigurationManager.AppSettings["passwordPublic"]))
{
FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
if (Url.IsLocalUrl(returnUrl) &&
returnUrl.Length > 1 &&
returnUrl.StartsWith("/") &&
!returnUrl.StartsWith("//") &&
!returnUrl.StartsWith("/\\"))
{
return Redirect(returnUrl);
}
return RedirectToAction("Index", "Home");
}
ModelState.AddModelError("", "Tên đăng nhập hoặc mật khẩu không đúng.");
db.Close();
}
return View(model);
}
示例13: PartialDeliveryFormula
public ActionResult PartialDeliveryFormula()
{
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();
dbConn.Close();
return PartialView("DeliveryFormula", dict);
}
else
return RedirectToAction("NoAccess", "Error");
}
示例14: GetFormulaByID
public ActionResult GetFormulaByID(string FormulaID)
{
IDbConnection dbConn = new OrmliteConnection().openConn();
try
{
var data = dbConn.SingleOrDefault<DC_Formula>("FormulaID={0}", FormulaID);
return Json(new { success = true, data = data });
}
catch (Exception e)
{
return Json(new { success = false, message = e.Message });
}
finally { dbConn.Close(); }
}
示例15: Create
public ActionResult Create(DC_LG_Contract item)
{
IDbConnection db = new OrmliteConnection().openConn();
try
{
if (!string.IsNullOrEmpty(item.ContractID) &&
!string.IsNullOrEmpty(item.ContractName)
)
{
var isExist = db.SingleOrDefault<DC_LG_Contract>("ContractID={0}", item.ContractID);
var data = Request["TransporterID"];
//string data = !string.IsNullOrEmpty(item.TransporterID) ? item.TransporterID : "";
double n;
item.StartDate = item.StartDate != null ? item.StartDate : DateTime.Now;
item.EndDate = item.EndDate != null ? item.EndDate : DateTime.Now;
item.DiscountPercent = double.TryParse(item.DiscountPercent.ToString(),out n) ? item.DiscountPercent/100 : 0;
if(item.StartDate>item.EndDate)
{
return Json(new { success = false, message = "Ngày kết thúc không thể lớn hơn " + item.StartDate });
}
item.Note = !string.IsNullOrEmpty(item.Note) ? item.Note : "";
item.DiscountPercent = !string.IsNullOrEmpty(item.DiscountPercent.ToString()) ? item.DiscountPercent : 0;
if (userAsset.ContainsKey("Insert") && userAsset["Insert"] && item.CreatedAt == null && item.CreatedBy == null)
{
if (isExist != null)
return Json(new { success = false, message = "Mã hợp đồng đã tồn tại" });
item.ContractName = !string.IsNullOrEmpty(item.ContractName) ? item.ContractName : "";
item.CreatedAt = DateTime.Now;
item.UpdatedAt = DateTime.Parse("1900-01-01");
item.CreatedBy = currentUser.UserID;
db.Insert(item);
db.Delete<DC_LG_Contract_Transporter>(p => p.ContractID ==item.ContractID);
if (!string.IsNullOrEmpty(data))
{
string[] arr = data.Split(',');
foreach (string ite in arr)
{
var detail = new DC_LG_Contract_Transporter();
detail.ContractID = item.ContractID;
detail.TransporterID = int.Parse(ite);
detail.Note = "";
detail.UpdatedAt = DateTime.Now;
detail.CreatedAt = DateTime.Now;
detail.CreatedBy = currentUser.UserID;
detail.UpdatedBy = currentUser.UserID;
db.Insert<DC_LG_Contract_Transporter>(detail);
}
}
return Json(new { success = true, ContractID = item.ContractID, CreatedBy = item.CreatedBy, CreatedAt = item.CreatedAt, });
}
else if (userAsset.ContainsKey("Update") && userAsset["Update"] && isExist != null)
{
item.ContractName = !string.IsNullOrEmpty(item.ContractName) ? item.ContractName : "";
item.CreatedBy = isExist.CreatedBy;
item.CreatedAt = isExist.CreatedAt;
item.UpdatedAt = DateTime.Now;
item.UpdatedBy = currentUser.UserID;
db.Update(item);
db.Delete<DC_LG_Contract_Transporter>(p => p.ContractID == item.ContractID);
if (!string.IsNullOrEmpty(data))
{
string[] arr = data.Split(',');
foreach (string ite in arr)
{
var detail = new DC_LG_Contract_Transporter();
detail.ContractID = item.ContractID;
detail.TransporterID = int.Parse(ite);
detail.Note = "";
detail.UpdatedAt = DateTime.Now;
detail.CreatedAt = DateTime.Now;
detail.CreatedBy = currentUser.UserID;
detail.UpdatedBy = currentUser.UserID;
db.Insert<DC_LG_Contract_Transporter>(detail);
}
}
return Json(new { success = true });
}
else
return Json(new { success = false, message = "Bạn không có quyền" });
}
else
{
return Json(new { success = false, message = "Chưa nhập đủ giá trị" });
}
}
catch (Exception e)
{
log.Error("Contract - Create - " + e.Message);
return Json(new { success = false, message = e.Message });
}
finally { db.Close(); }
}