109 lines
3.4 KiB
C#
109 lines
3.4 KiB
C#
namespace YLErp.Web.Controllers
|
|
{
|
|
public class eod_trade_vol_overrideController : BaseController
|
|
{
|
|
readonly YLContext db = new YLContext();
|
|
|
|
[MyAuthorize("结算管理-收盘操作")]
|
|
public ActionResult eod_trade_vol_overrideList()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult eod_trade_vol_overrideQuery(EodTradeVolOverrideReq req)
|
|
{
|
|
var sList = new EodTradeVolOverrideBLL().SearchList(req);
|
|
return Json(sList);
|
|
}
|
|
|
|
public ActionResult eod_trade_vol_overrideView(string enid)
|
|
{
|
|
var intid = DataProtectHelper.DecryptInt(enid);
|
|
var r = db.eod_trade_vol_override.Find(intid);
|
|
return View(r);
|
|
}
|
|
|
|
public ActionResult eod_trade_vol_overrideEdit(string enid)
|
|
{
|
|
var isAdd = string.IsNullOrEmpty(enid) || enid == "0";
|
|
eod_trade_vol_override r;
|
|
if (isAdd)
|
|
{
|
|
r = new eod_trade_vol_override() { valuedate = valuedateBLL.ValueDate };
|
|
return View(r);
|
|
}
|
|
var intid = DataProtectHelper.DecryptInt(enid);
|
|
r = db.eod_trade_vol_override.Find(intid);
|
|
|
|
return View(r);
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult eod_trade_vol_overrideEditJson(string EncryptId)
|
|
{
|
|
var id = 0;
|
|
if (!string.IsNullOrEmpty(EncryptId))
|
|
{
|
|
id = DataProtectHelper.DecryptInt(EncryptId);
|
|
}
|
|
|
|
var r = saveeod_trade_vol_override(id);
|
|
return JsonSuccess("更新成功", r);
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<ActionResult> eod_trade_vol_overrideEdit(IFormCollection collection, string EncryptId)
|
|
{
|
|
var id = DataProtectHelper.DecryptInt(EncryptId);
|
|
var r = await saveeod_trade_vol_override(id);
|
|
return Redirect("~/eod_trade_vol_override/eod_trade_vol_overrideView/?id=" + r.EncryptId);
|
|
}
|
|
|
|
private async Task<eod_trade_vol_override> saveeod_trade_vol_override(int? id)
|
|
{
|
|
eod_trade_vol_override r;
|
|
var isAddNew = id == null || id == 0;
|
|
if (isAddNew)
|
|
{
|
|
db.eod_trade_vol_override.Add(r = new eod_trade_vol_override());
|
|
}
|
|
else
|
|
{
|
|
r = db.eod_trade_vol_override.Find(id);
|
|
}
|
|
|
|
await TryUpdateModelAsync(r);
|
|
|
|
r.OptId = UserId;
|
|
r.OptName = UserName;
|
|
r.OptDate = DateTime.Now;
|
|
|
|
if (isAddNew)
|
|
{
|
|
//新增判断下,当天是否已经有其它相同的波动率设置
|
|
var existoverride = db.eod_trade_vol_override.Where(e => e.valuedate == r.valuedate && e.tradeid == r.tradeid);
|
|
db.eod_trade_vol_override.RemoveRange(existoverride);
|
|
}
|
|
|
|
db.SaveChanges();
|
|
|
|
return r;
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult Deleteeod_trade_vol_override(string id)
|
|
{
|
|
var intid = DataProtectHelper.DecryptInt(id);
|
|
var r = db.eod_trade_vol_override.Find(intid);
|
|
if (r == null)
|
|
{
|
|
return JsonError("找不到结算波动率设置");
|
|
}
|
|
db.eod_trade_vol_override.Remove(r);
|
|
db.SaveChanges();
|
|
return JsonSuccess("删除成功");
|
|
}
|
|
}
|
|
}
|