/// <summary>
///描述:保存其它收支信息
///作者:许
///时间:2018-05-11
/// </summary>
///
private string SaveOtherInout()
{
int int_otherId = int.Parse(pi.PPV("str_otherId", "0"));
string str_remark = pi.PPV("str_remark");/*备注*/
string str_no = pi.PPV("VC_NO");/*单号*/
DateTime Dt_indate = Convert.ToDateTime(pi.PPV("DT_MONEY"));/*日期*/
string str_supply = pi.PPV("I_ID_SUPPLY");
string array_GoodsData = pi.PPV("array_GoodsData", "0");
string str_delotherIds = PPV("str_delOtherIds");/*删除的收支明细*/
var list_otherdetail = Json.ToObject<List<T_CW_OTHERINOUTDETAIL>>(array_GoodsData);
if (str_supply == null || str_supply == "undefined" || str_supply == "")
{
JsonValue.msg = "供应商为空";
JsonValue.success = false;
return Value = JsonValue.ToJson();
}
BLL_T_CW_OTHERINOUT bll_otherinout = new BLL_T_CW_OTHERINOUT(this.ol);
BLL_T_CW_OTHERINOUTDETAIL bll_otherdetail = new BLL_T_CW_OTHERINOUTDETAIL(this.ol);
T_CW_OTHERINOUT t_otherinout=new T_CW_OTHERINOUT();
List<T_CW_OTHERINOUTDETAIL> list_adddetail = new List<T_CW_OTHERINOUTDETAIL>();
List<T_CW_OTHERINOUTDETAIL> list_updatedetail = new List<T_CW_OTHERINOUTDETAIL>();
string str_actiontype = int_otherId == -1 ? "add" : "edit";
var trans = bll_otherinout.BeginTrans();
try
{
if (!string.IsNullOrWhiteSpace(str_delotherIds) && str_delotherIds != "0")
{
var list_delDetailIds = str_delotherIds.Split(',').Select(e => int.Parse(e)).ToList();
foreach (var item1 in list_delDetailIds)
{
bll_otherdetail.Delete(item1);
}
}
if (str_actiontype == "add")
{
int ID = bll_otherinout.GetNextId();
t_otherinout.ID = ID;
t_otherinout.I_STATE = 0;
}
else
{
t_otherinout= bll_otherinout.FindByKey(int_otherId);
}
t_otherinout.I_ID_SUPPLY = decimal.Parse(str_supply);
t_otherinout.VC_NO = str_no;
t_otherinout.VC_REMARK = str_remark;
t_otherinout.DT_MONEY = Dt_indate;
t_otherinout.N_MONEY = 0;
if (str_actiontype == "add")
bll_otherinout.Insert(t_otherinout);
else
bll_otherinout.Update(t_otherinout);
foreach (var item in list_otherdetail)
{
T_CW_OTHERINOUTDETAIL t_otherdetail = new T_CW_OTHERINOUTDETAIL();
if (item.ID == 0)
{
t_otherdetail.ID = bll_otherdetail.GetNextId();
}
else
{
t_otherdetail = bll_otherdetail.FindByKey(item.ID);
}
t_otherdetail.I_ID_SUPPLY = item.I_ID_SUPPLY;
t_otherdetail.I_ID_MAIN = t_otherinout.ID;
t_otherdetail.I_TYPE = item.I_TYPE;
t_otherdetail.N_MONEY = item.N_MONEY;
t_otherdetail.VC_MONEY = item.VC_MONEY;
t_otherdetail.VC_REMARK = item.VC_REMARK;
if (item.I_TYPE < 0)
{
t_otherinout.N_MONEY -= item.N_MONEY;
}
else
{
t_otherinout.N_MONEY += item.N_MONEY;
}
if (item.ID == 0)
list_adddetail.Add(t_otherdetail);
else
list_updatedetail.Add(t_otherdetail);
}
bll_otherdetail.InsertMore(list_adddetail);
bll_otherdetail.UpdateMore(list_updatedetail);
bll_otherinout.Update(t_otherinout);
trans.Commit(); /*事务完成*/
JsonValue.success = true;
JsonValue.msg = "操作成功";
}
catch (Exception ex)
{
trans.Rollback();
var aa = ex.Message;
JsonValue.msg = "操作失败,原因:" + aa;
JsonValue.success = false;
}
finally
{
trans.Dispose(); /*释放事务*/
}
return Value = JsonValue.ToJson();
}
///描述:保存其它收支信息
///作者:许
///时间:2018-05-11
/// </summary>
///
private string SaveOtherInout()
{
int int_otherId = int.Parse(pi.PPV("str_otherId", "0"));
string str_remark = pi.PPV("str_remark");/*备注*/
string str_no = pi.PPV("VC_NO");/*单号*/
DateTime Dt_indate = Convert.ToDateTime(pi.PPV("DT_MONEY"));/*日期*/
string str_supply = pi.PPV("I_ID_SUPPLY");
string array_GoodsData = pi.PPV("array_GoodsData", "0");
string str_delotherIds = PPV("str_delOtherIds");/*删除的收支明细*/
var list_otherdetail = Json.ToObject<List<T_CW_OTHERINOUTDETAIL>>(array_GoodsData);
if (str_supply == null || str_supply == "undefined" || str_supply == "")
{
JsonValue.msg = "供应商为空";
JsonValue.success = false;
return Value = JsonValue.ToJson();
}
BLL_T_CW_OTHERINOUT bll_otherinout = new BLL_T_CW_OTHERINOUT(this.ol);
BLL_T_CW_OTHERINOUTDETAIL bll_otherdetail = new BLL_T_CW_OTHERINOUTDETAIL(this.ol);
T_CW_OTHERINOUT t_otherinout=new T_CW_OTHERINOUT();
List<T_CW_OTHERINOUTDETAIL> list_adddetail = new List<T_CW_OTHERINOUTDETAIL>();
List<T_CW_OTHERINOUTDETAIL> list_updatedetail = new List<T_CW_OTHERINOUTDETAIL>();
string str_actiontype = int_otherId == -1 ? "add" : "edit";
var trans = bll_otherinout.BeginTrans();
try
{
if (!string.IsNullOrWhiteSpace(str_delotherIds) && str_delotherIds != "0")
{
var list_delDetailIds = str_delotherIds.Split(',').Select(e => int.Parse(e)).ToList();
foreach (var item1 in list_delDetailIds)
{
bll_otherdetail.Delete(item1);
}
}
if (str_actiontype == "add")
{
int ID = bll_otherinout.GetNextId();
t_otherinout.ID = ID;
t_otherinout.I_STATE = 0;
}
else
{
t_otherinout= bll_otherinout.FindByKey(int_otherId);
}
t_otherinout.I_ID_SUPPLY = decimal.Parse(str_supply);
t_otherinout.VC_NO = str_no;
t_otherinout.VC_REMARK = str_remark;
t_otherinout.DT_MONEY = Dt_indate;
t_otherinout.N_MONEY = 0;
if (str_actiontype == "add")
bll_otherinout.Insert(t_otherinout);
else
bll_otherinout.Update(t_otherinout);
foreach (var item in list_otherdetail)
{
T_CW_OTHERINOUTDETAIL t_otherdetail = new T_CW_OTHERINOUTDETAIL();
if (item.ID == 0)
{
t_otherdetail.ID = bll_otherdetail.GetNextId();
}
else
{
t_otherdetail = bll_otherdetail.FindByKey(item.ID);
}
t_otherdetail.I_ID_SUPPLY = item.I_ID_SUPPLY;
t_otherdetail.I_ID_MAIN = t_otherinout.ID;
t_otherdetail.I_TYPE = item.I_TYPE;
t_otherdetail.N_MONEY = item.N_MONEY;
t_otherdetail.VC_MONEY = item.VC_MONEY;
t_otherdetail.VC_REMARK = item.VC_REMARK;
if (item.I_TYPE < 0)
{
t_otherinout.N_MONEY -= item.N_MONEY;
}
else
{
t_otherinout.N_MONEY += item.N_MONEY;
}
if (item.ID == 0)
list_adddetail.Add(t_otherdetail);
else
list_updatedetail.Add(t_otherdetail);
}
bll_otherdetail.InsertMore(list_adddetail);
bll_otherdetail.UpdateMore(list_updatedetail);
bll_otherinout.Update(t_otherinout);
trans.Commit(); /*事务完成*/
JsonValue.success = true;
JsonValue.msg = "操作成功";
}
catch (Exception ex)
{
trans.Rollback();
var aa = ex.Message;
JsonValue.msg = "操作失败,原因:" + aa;
JsonValue.success = false;
}
finally
{
trans.Dispose(); /*释放事务*/
}
return Value = JsonValue.ToJson();
}