|
@@ -23,16 +23,19 @@ namespace JLHHJSvr.Excutor
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (request.profitrate == null)
|
|
|
|
|
|
+ if (!request.list.Any())
|
|
{
|
|
{
|
|
rslt.ErrMsg = "未提交工厂利润率信息";
|
|
rslt.ErrMsg = "未提交工厂利润率信息";
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (request.profitrate.profitrate < 0)
|
|
|
|
|
|
+ foreach(var profitrate in request.list)
|
|
{
|
|
{
|
|
- rslt.ErrMsg = "利润率有误,请检查!";
|
|
|
|
- return;
|
|
|
|
|
|
+ if (profitrate.profitrate < 0)
|
|
|
|
+ {
|
|
|
|
+ rslt.ErrMsg = "利润率有误,请检查!";
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
using (var con = new SqlConnection(GlobalVar.ConnectionString))
|
|
using (var con = new SqlConnection(GlobalVar.ConnectionString))
|
|
@@ -42,35 +45,39 @@ namespace JLHHJSvr.Excutor
|
|
|
|
|
|
var dtNow = DateTime.Now;
|
|
var dtNow = DateTime.Now;
|
|
|
|
|
|
- cmd.CommandText = @"SELECT COUNT(*) AS cnt
|
|
|
|
- FROM u_factory_profitrate
|
|
|
|
- WHERE u_factory_profitrate.deptid = @deptid
|
|
|
|
- AND u_factory_profitrate.bednettypeid_mattresstypeid = @typid
|
|
|
|
- AND u_factory_profitrate.bednet_or_mattress = @kind";
|
|
|
|
- cmd.Parameters.Clear();
|
|
|
|
- cmd.Parameters.AddWithValue("@deptid", request.profitrate.deptid);
|
|
|
|
- cmd.Parameters.AddWithValue("@typid", request.profitrate.bednettypeid_mattresstypeid);
|
|
|
|
- cmd.Parameters.AddWithValue("@kind", request.profitrate.bednet_or_mattress);
|
|
|
|
- var cnt = Convert.ToInt32(cmd.ExecuteScalar());
|
|
|
|
-
|
|
|
|
using (cmd.Transaction = con.BeginTransaction())
|
|
using (cmd.Transaction = con.BeginTransaction())
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- if(cnt <= 0)
|
|
|
|
|
|
+ foreach (var profitrate in request.list)
|
|
{
|
|
{
|
|
- AutoInit.AutoInitS(cmd, request.profitrate);
|
|
|
|
|
|
+ cmd.CommandText = @"SELECT COUNT(*) AS cnt
|
|
|
|
+ FROM u_factory_profitrate
|
|
|
|
+ WHERE u_factory_profitrate.deptid = @deptid
|
|
|
|
+ AND u_factory_profitrate.bednettypeid_mattresstypeid = @typid
|
|
|
|
+ AND u_factory_profitrate.bednet_or_mattress = @kind";
|
|
|
|
+ cmd.Parameters.Clear();
|
|
|
|
+ cmd.Parameters.AddWithValue("@deptid", profitrate.deptid);
|
|
|
|
+ cmd.Parameters.AddWithValue("@typid", profitrate.bednettypeid_mattresstypeid);
|
|
|
|
+ cmd.Parameters.AddWithValue("@kind", profitrate.bednet_or_mattress);
|
|
|
|
+ var cnt = Convert.ToInt32(cmd.ExecuteScalar());
|
|
|
|
|
|
- request.profitrate.createtime = dtNow;
|
|
|
|
- request.profitrate.createby = tokendata.username;
|
|
|
|
|
|
+ if (cnt <= 0)
|
|
|
|
+ {
|
|
|
|
+ AutoInit.AutoInitS(cmd, profitrate);
|
|
|
|
|
|
- var fields = "deptid,bednet_or_mattress,bednettypeid_mattresstypeid,createtime,profitrate,createby";
|
|
|
|
- DbSqlHelper.Insert(cmd, "u_factory_profitrate", null, request.profitrate, fields);
|
|
|
|
- } else
|
|
|
|
- {
|
|
|
|
- //修改
|
|
|
|
- var fields = "profitrate";
|
|
|
|
- DbSqlHelper.Update(cmd, "u_factory_profitrate", null, request.profitrate, "deptid,bednet_or_mattress,bednettypeid_mattresstypeid", fields);
|
|
|
|
|
|
+ profitrate.createtime = dtNow;
|
|
|
|
+ profitrate.createby = tokendata.username;
|
|
|
|
+
|
|
|
|
+ var fields = "deptid,bednet_or_mattress,bednettypeid_mattresstypeid,createtime,profitrate,createby";
|
|
|
|
+ DbSqlHelper.Insert(cmd, "u_factory_profitrate", null, profitrate, fields);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ //修改
|
|
|
|
+ var fields = "profitrate";
|
|
|
|
+ DbSqlHelper.Update(cmd, "u_factory_profitrate", null, profitrate, "deptid,bednet_or_mattress,bednettypeid_mattresstypeid", fields);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
cmd.Transaction.Commit();
|
|
cmd.Transaction.Commit();
|