124 lines
4.2 KiB
C#
124 lines
4.2 KiB
C#
using YLErp.Modules.ClientModule;
|
|
using YLErp.QdpModule;
|
|
|
|
namespace YLErp.Web.Controllers
|
|
{
|
|
public class client_pricing_paramController : BaseController
|
|
{
|
|
protected YLContext db = new YLContext();
|
|
|
|
[MyAuthorize("报价管理-客户报价参数")]
|
|
public ActionResult client_pricing_paramList()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult client_pricing_paramQuery(ClientPricingParamReq req)
|
|
{
|
|
var sList = new ClientPricingParamService(CurUser).SearchList(req);
|
|
return Json(sList);
|
|
}
|
|
|
|
public ActionResult client_pricing_paramView(string enid)
|
|
{
|
|
var intid = DataProtectHelper.DecryptInt(enid);
|
|
var r = db.client_pricing_param.Find(intid);
|
|
return View(r);
|
|
}
|
|
|
|
public ActionResult client_pricing_paramEdit(string enid)
|
|
{
|
|
ClientPricingParam r;
|
|
var isAdd = string.IsNullOrEmpty(enid) || enid == "0";
|
|
if (isAdd)
|
|
{
|
|
r = new ClientPricingParam { option_startdate = valuedateBLL.ValueDate.Date, ask_tuning_day = 0, bid_tuning_day = 0 };
|
|
return View(r);
|
|
}
|
|
var intid = DataProtectHelper.DecryptInt(enid);
|
|
r = db.client_pricing_param.Find(intid);
|
|
|
|
return View(r);
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult client_pricing_paramEditJson(ClientPricingParamReq req)
|
|
{
|
|
var id = 0;
|
|
if (!string.IsNullOrEmpty(req.EncryptId))
|
|
{
|
|
id = DataProtectHelper.DecryptInt(req.EncryptId);
|
|
}
|
|
|
|
var r = saveclient_pricing_param(id);
|
|
return JsonSuccess("更新成功", r);
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<ActionResult> client_pricing_paramEdit(ClientPricingParamReq req)
|
|
{
|
|
var id = DataProtectHelper.DecryptInt(req.EncryptId);
|
|
var r = await saveclient_pricing_param(id);
|
|
return Redirect("~/client_pricing_param/client_pricing_paramView/?id=" + r.EncryptId);
|
|
}
|
|
|
|
private async Task<ClientPricingParam> saveclient_pricing_param(int? id)
|
|
{
|
|
ClientPricingParam r;
|
|
var isAddNew = id == null || id == 0;
|
|
if (isAddNew)
|
|
{
|
|
r = new ClientPricingParam
|
|
{
|
|
createdate = DateTime.Now,
|
|
optname = CurUser.UserName,
|
|
optid = CurUser.UserId
|
|
};
|
|
db.client_pricing_param.Add(r);
|
|
}
|
|
else
|
|
{
|
|
r = db.client_pricing_param.Find(id);
|
|
}
|
|
r.updatedate = DateTime.Now;
|
|
|
|
await TryUpdateModelAsync(r);
|
|
if (!isAddNew)
|
|
{
|
|
if (db.client_pricing_param.Any(c => c.id != r.id && (c.option_startdate == r.option_startdate && c.option_exercisedate == r.option_exercisedate)))
|
|
{
|
|
throw new Exception("已经存在相同开始日和到期日的设置,请检查");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (db.client_pricing_param.Any(c => c.option_startdate == r.option_startdate && c.option_exercisedate == r.option_exercisedate))
|
|
{
|
|
throw new Exception("已经存在相同开始日和到期日的设置,不能重复新增,请检查");
|
|
}
|
|
}
|
|
//计算期权工作日天数
|
|
var workDays = QdpCalendarHelper.GetWorkDayCount(r.option_startdate.Value, r.option_exercisedate.Value);
|
|
var csub = new ClientSubParam { WorkDays = workDays };
|
|
r.otherinfo = csub.ToJson();
|
|
db.SaveChanges();
|
|
return r;
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult Deleteclient_pricing_param(string id)
|
|
{
|
|
var intid = DataProtectHelper.DecryptInt(id);
|
|
var r = db.client_pricing_param.Find(intid);
|
|
if (r == null)
|
|
{
|
|
return JsonError("找不到客户报价参数");
|
|
}
|
|
db.client_pricing_param.Remove(r);
|
|
db.SaveChanges();
|
|
return JsonSuccess("删除成功");
|
|
}
|
|
}
|
|
}
|