修改
This commit is contained in:
@@ -34,9 +34,9 @@ namespace U8AppMain.Voucher
|
||||
|
||||
public DateTime dnverifytime { get; set; }
|
||||
|
||||
public IEnumerable<Vouchs> Vouchs { get; set; } = new List<Vouchs>();
|
||||
|
||||
public ICollection<Vouchs> Vouchs { get; set; } = new List<Vouchs>();
|
||||
|
||||
public string cDefine12 { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace U8AppMain.Voucher
|
||||
_connStr = connStr;
|
||||
}
|
||||
|
||||
public void Add(Vouch vouch)
|
||||
public bool Add(Vouch vouch)
|
||||
{
|
||||
|
||||
var conn = new SqlConnection(this._connStr);
|
||||
@@ -46,10 +46,12 @@ namespace U8AppMain.Voucher
|
||||
try
|
||||
{
|
||||
//获取ID
|
||||
var idEnity = new IdEnity();
|
||||
idEnity.cAcc_Id = "003";
|
||||
idEnity.cVouchType = "mv";
|
||||
idEnity.iAmount = vouch.Vouchs.Count();
|
||||
var idEnity = new IdEnity
|
||||
{
|
||||
cAcc_Id = "003",
|
||||
cVouchType = "mv",
|
||||
iAmount = vouch.Vouchs.Count()
|
||||
};
|
||||
DynamicParameters sp = new DynamicParameters(idEnity);
|
||||
sp.Add("@iFatherId", 0, System.Data.DbType.Int32, System.Data.ParameterDirection.Output);
|
||||
sp.Add("@iChildId", 0, System.Data.DbType.Int32, System.Data.ParameterDirection.Output);
|
||||
@@ -71,15 +73,16 @@ namespace U8AppMain.Voucher
|
||||
//组装Code
|
||||
var cCode = prefix + cSeed.Substring(2,cSeed.Length-2) + maxCode.ToString().PadLeft(5, '0');
|
||||
//主表
|
||||
var sql = @"insert into MaterialAppVouch(id,ddate,ccode,crdcode,cdepcode,cpersoncode,cmaker,vt_id,iswfcontrolled,dnmaketime)
|
||||
values(@id,@ddate,@ccode,@crdcode,@cdepcode,@cpersoncode,@cmaker,@vt_id,@iswfcontrolled, getdate())";
|
||||
var sql = @"insert into MaterialAppVouch(id,ddate,ccode,crdcode,cdepcode,cpersoncode,cmaker,vt_id,iswfcontrolled,dnmaketime,cDefine12)
|
||||
values(@id,@ddate,@ccode,@crdcode,@cdepcode,@cpersoncode,@cmaker,@vt_id,@iswfcontrolled, getdate(),@cDefine12)";
|
||||
vouch.ID = iFatherId;
|
||||
vouch.cDefine12 = vouch.CCode;
|
||||
vouch.CCode = cCode;
|
||||
conn.Execute(sql, vouch, trans);
|
||||
sql = @"INSERT INTO MaterialAppVouchs (autoid, id, cinvcode, inum, iquantity , cwhcode, iexpiratdatecalcu, irowno, iordertype, isotype , ipesotype)
|
||||
VALUES (@autoid, @id, @cinvcode, @inum, @iquantity , @cwhcode, @iexpiratdatecalcu, @irowno, @iordertype, @isotype , @ipesotype)";
|
||||
//明细
|
||||
var n = vouch.Vouchs.Count();
|
||||
var n = vouch.Vouchs.Count()-1;
|
||||
foreach (var item in vouch.Vouchs)
|
||||
{
|
||||
item.autoid = iChildId - n;
|
||||
@@ -90,18 +93,19 @@ namespace U8AppMain.Voucher
|
||||
conn.Execute(sql, vouch.Vouchs, trans);
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception err)
|
||||
catch (Exception err )
|
||||
{
|
||||
|
||||
trans.Rollback();
|
||||
throw err;
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
|
||||
conn.Close();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,12 +21,12 @@ namespace U8AppMain.Voucher
|
||||
|
||||
public int Iquantity { get; set; }
|
||||
|
||||
public string CwhCode { get; set; }
|
||||
public string CwhCode { get; set; } = "2";
|
||||
|
||||
public int IExpiratdatecalcu { get; set; }
|
||||
|
||||
|
||||
public int IRowNO { get; set; }
|
||||
public int IRowNO { get; set; }
|
||||
|
||||
public int IorderType { get; set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user