本文整理汇总了C#中SES.Service.OrmliteConnection.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# OrmliteConnection.Delete方法的具体用法?C# OrmliteConnection.Delete怎么用?C# OrmliteConnection.Delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SES.Service.OrmliteConnection
的用法示例。
在下文中一共展示了OrmliteConnection.Delete方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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(); }
}
示例2: 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(); }
}
示例3: 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(); }
}
示例4: Deactive
public ActionResult Deactive(string data)
{
if (userAsset.ContainsKey("Delete") && userAsset["Delete"])
{
IDbConnection dbConn = new OrmliteConnection().openConn();
try
{
var newdata = data.Split(',');
foreach (string id in newdata)
{
dbConn.Delete<Master_Announcement>(p => p.AnnouncementID == Convert.ToInt32(id));
}
return Json(new { success = true, });
}
catch (Exception ex)
{
return Json(new { success = false, message = ex.Message });
}
finally
{
dbConn.Close();
}
}
else
{
return Json(new { success = false, message = "You don't have permission" });
}
}
示例5: Update
//public ActionResult ReadDetail([DataSourceRequest] DataSourceRequest request, string SONumber)
//{
// log4net.Config.XmlConfigurator.Configure();
// string whereCondition = "";
// if (request.Filters.Count > 0)
// {
// whereCondition = " AND " + new KendoApplyFilter().ApplyFilter(request.Filters[0]);
// }
// var data = new DC_AD_SO_Detail().GetPage(request, whereCondition, SONumber);
// return Json(data);
//}
public ActionResult Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable<Products> list, string SONumber)
{
var dbConn = new OrmliteConnection().openConn();
try
{
if (list != null && ModelState.IsValid)
{
foreach (var item in list)
{
if (item.Qty > 0)
{
//string SONumber = Request["SONumber"];
var header = new SOHeader();
var detail = new SODetail();
if (dbConn.Select<SODetail>(s => s.SONumber == SONumber && s.ItemCode == item.Code).Count() > 0)
{
dbConn.Update<SODetail>(set: "Qty = '" + item.Qty + "', TotalAmt = '" + item.Qty * item.Price + "'", where: "SONumber = '" + SONumber + "'");
}
else
{
var data = new SODetail();
data.ItemName = item.Name;
data.ItemCode = item.Code;
data.Note = "";
data.Price = item.VATPrice;
data.Qty = item.Qty;
data.SONumber = SONumber;
data.UnitID = item.Unit;
data.UnitName = dbConn.Select<INUnit>(s => s.UnitID == item.Unit).FirstOrDefault().UnitName;
data.TotalAmt = item.Qty * item.VATPrice;
data.Status = "";
data.CreatedAt = DateTime.Now;
data.CreatedBy = currentUser.UserID;
//data.UpdatedAt = DateTime.Parse("1900-01-01");
data.UpdatedAt = DateTime.Now;
data.UpdatedBy = "";
dbConn.Insert<SODetail>(data);
}
dbConn.Update<SOHeader>(set: "TotalQty ='" + dbConn.Select<SODetail>(s => s.SONumber == SONumber).Sum(s => s.Qty) + "', TotalAmt = '" + +dbConn.Select<SODetail>(s => s.SONumber == SONumber).Sum(s => s.TotalAmt) + "'", where: "SONumber ='" + SONumber + "'");
}
else
{
dbConn.Delete<SOHeader>(s => s.SONumber == SONumber);
ModelState.AddModelError("error", "Đơn hàng được tạo khi số lượng > 0");
return Json(list.ToDataSourceResult(request, ModelState));
}
}
}
dbConn.Close();
}
catch (Exception e)
{
dbConn.Close();
ModelState.AddModelError("error", e.Message);
return Json(list.ToDataSourceResult(request, ModelState));
}
return Json(new { sussess = true });
}
示例6: DeleteDetail
public ActionResult DeleteDetail(string data, string SONumber)
{
var dbConn = new OrmliteConnection().openConn();
if (userAsset.ContainsKey("Delete") && userAsset["Delete"])
{
try
{
string[] separators = { "@@" };
var listdata = data.Split(separators, StringSplitOptions.RemoveEmptyEntries);
if (dbConn.Select<SOHeader>(s => s.SONumber == SONumber && s.Status != "Mới").Count() > 0)
{
return Json(new { success = false, message = "Đơn hàng đã xác nhận nên không được xóa." });
}
foreach (var item in listdata)
{
dbConn.Delete<SODetail>(s => s.Id == int.Parse(item));
}
if (dbConn.Select<SODetail>(s => s.SONumber == SONumber).Count() <= 0)
{
dbConn.Delete<SOHeader>(s => s.SONumber == SONumber);
}
return Json(new { success = true });
}
catch (Exception e)
{
return Json(new { success = false, message = e.Message });
}
dbConn.Close();
}
else
{
dbConn.Close();
return Json(new { success = false, message = "Bạn không có quyền xóa dữ liệu." });
}
}