public void AddNewDLItem(DLItemInfo oParam) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { string sql = "select * from dl_item where dlsysno=" + oParam.DLSysNo + " and ItemID=" + Util.ToSqlString(oParam.ItemID); DataSet ds = SqlHelper.ExecuteDataSet(sql); if (Util.HasMoreRow(ds)) //先判断是否存在,存在就修改为valid状态 { oParam.SysNo = Util.TrimIntNull(ds.Tables[0].Rows[0][0].ToString()); oParam.Status = (int)AppEnum.BiStatus.Valid; new DLDac().Update(oParam); } else { new DLDac().Insert(oParam); } CalcDLMaster(oParam.DLSysNo); scope.Complete(); } }
public DLInfo Load(int sysno) { string sql = "select * from DL_Master where sysno =" + sysno; DataSet ds = SqlHelper.ExecuteDataSet(sql); DLInfo oInfo = new DLInfo(); if (Util.HasMoreRow(ds)) { map(oInfo, ds.Tables[0].Rows[0]); //load dlitems string sqlItem = "select * from dl_item where dlsysno =" + oInfo.SysNo; DataSet dsItem = SqlHelper.ExecuteDataSet(sqlItem); if (Util.HasMoreRow(dsItem)) { foreach (DataRow dr in dsItem.Tables[0].Rows) { DLItemInfo oDLItem = new DLItemInfo(); map(oDLItem, dr); oInfo.ItemHash.Add(oDLItem.SysNo, oDLItem); } } return(oInfo); } else { return(null); } }
private void map(DLItemInfo oParam, DataRow tempdr) { oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]); oParam.DLSysNo = Util.TrimIntNull(tempdr["DLSysNo"]); oParam.ItemID = Util.TrimNull(tempdr["ItemID"]); oParam.ItemType = Util.TrimIntNull(tempdr["ItemType"]); oParam.PayType = Util.TrimIntNull(tempdr["PayType"]); oParam.PayAmt = Util.TrimDecimalNull(tempdr["PayAmt"]); oParam.Status = Util.TrimIntNull(tempdr["Status"]); }
public void AddItemRelated(int sysno, int freightUserSysNo, DLItemInfo dlItem, int DLItemType, int updateUser) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { Hashtable ht = new Hashtable(); ht.Add("SysNo", sysno); ht.Add("FreightUserSysNo", freightUserSysNo); ht.Add("SetDeliveryManTime", DateTime.Now); ht.Add("DLSysNo", dlItem.DLSysNo); if (DLItemType == (int)AppEnum.DLItemType.SaleOrder) { SaleManager.GetInstance().UpdateSOMaster(ht); } else if (DLItemType == (int)AppEnum.DLItemType.RMARequest) { RMARequestManager.GetInstance().SetDeliveryMen(ht); } else if (DLItemType == (int)AppEnum.DLItemType.RMARevert) { RMARevertManager.GetInstance().SetDeliveryMen(ht); } else if (DLItemType == (int)AppEnum.DLItemType.RMAOutbound) { RMAOutBoundManager.GetInstance().SetDeliveryMen(ht); } else if (DLItemType == (int)AppEnum.DLItemType.RMASendAccessory) { RMASendAccessoryManager.GetInstance().SetDeliveryMen(ht); } else if (DLItemType == (int)AppEnum.DLItemType.StShift) { ShiftManager.GetInstance().UpdateShiftMaster(ht); } DeliveryManSetListInfo oInfo = new DeliveryManSetListInfo(); oInfo.ItemID = dlItem.ItemID; oInfo.SetUserSysNo = updateUser; oInfo.FreightUserSysNo = freightUserSysNo; oInfo.CreateTime = DateTime.Now; oInfo.DLSysNo = dlItem.DLSysNo; DeliveryManager.GetInstance().InsertDeliveryMenSetList(oInfo); DLManager.GetInstance().AddNewDLItem(dlItem); scope.Complete(); } }
public void UpdateDLItem(DLItemInfo oParam) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { new DLDac().Update(oParam); scope.Complete(); } }
public void DeleteDLItem(DLItemInfo oParam) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { oParam.Status = (int)AppEnum.BiStatus.InValid; new DLDac().Update(oParam); CalcDLMaster(oParam.DLSysNo); scope.Complete(); } }
public DLItemInfo LoadDLItem(int sysno) { string sql = "select * from DL_Item where sysno =" + sysno; DataSet ds = SqlHelper.ExecuteDataSet(sql); DLItemInfo oInfo = new DLItemInfo(); if (Util.HasMoreRow(ds)) { map(oInfo, ds.Tables[0].Rows[0]); } else { oInfo = null; } return(oInfo); }
public void CalcDLMaster(int SysNo) { string sql1 = "select * from dl_master where sysno=" + SysNo; DataSet ds1 = SqlHelper.ExecuteDataSet(sql1); DLInfo dlInfo = new DLInfo(); if (Util.HasMoreRow(ds1)) { map(dlInfo, ds1.Tables[0].Rows[0]); } else { return; } dlInfo.ItemHash.Clear(); string sql2 = "select * from dl_item where dlsysno=" + SysNo + " and status=@valid"; sql2 = sql2.Replace("@valid", ((int)AppEnum.BiStatus.Valid).ToString()); DataSet ds2 = SqlHelper.ExecuteDataSet(sql2); if (Util.HasMoreRow(ds2)) { foreach (DataRow dr in ds2.Tables[0].Rows) { DLItemInfo item = new DLItemInfo(); map(item, dr); dlInfo.ItemHash.Add(item.SysNo, item); } } try { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { int HasPaidQty = 0; decimal HasPaidAmt = 0; int CODQty = 0; decimal CODAmt = 0; foreach (DLItemInfo item in dlInfo.ItemHash.Values) { if (item.PayType == 1) //货到付款 { CODQty++; CODAmt += item.PayAmt; } else { HasPaidQty++; HasPaidAmt += item.PayAmt; } } dlInfo.HasPaidQty = HasPaidQty; dlInfo.HasPaidAmt = HasPaidAmt; dlInfo.CODQty = CODQty; dlInfo.CODAmt = CODAmt; UpdateDLMaster(dlInfo); scope.Complete(); } } catch (Exception ex) { dlInfo.SysNo = AppConst.IntNull; throw ex; } }
public int Update(DLItemInfo oParam) { string sql = @"UPDATE DL_Item SET DLSysNo=@DLSysNo, ItemID=@ItemID, ItemType=@ItemType, PayType=@PayType, PayAmt=@PayAmt, Status=@Status WHERE SysNo=@SysNo"; SqlCommand cmd = new SqlCommand(sql); SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int, 4); SqlParameter paramDLSysNo = new SqlParameter("@DLSysNo", SqlDbType.Int, 4); SqlParameter paramItemID = new SqlParameter("@ItemID", SqlDbType.NVarChar, 50); SqlParameter paramItemType = new SqlParameter("@ItemType", SqlDbType.Int, 4); SqlParameter paramPayType = new SqlParameter("@PayType", SqlDbType.Int, 4); SqlParameter paramPayAmt = new SqlParameter("@PayAmt", SqlDbType.Decimal, 9); SqlParameter paramStatus = new SqlParameter("@Status", SqlDbType.Int, 4); if (oParam.SysNo != AppConst.IntNull) { paramSysNo.Value = oParam.SysNo; } else { paramSysNo.Value = System.DBNull.Value; } if (oParam.DLSysNo != AppConst.IntNull) { paramDLSysNo.Value = oParam.DLSysNo; } else { paramDLSysNo.Value = System.DBNull.Value; } if (oParam.ItemID != AppConst.StringNull) { paramItemID.Value = oParam.ItemID; } else { paramItemID.Value = System.DBNull.Value; } if (oParam.ItemType != AppConst.IntNull) { paramItemType.Value = oParam.ItemType; } else { paramItemType.Value = System.DBNull.Value; } if (oParam.PayType != AppConst.IntNull) { paramPayType.Value = oParam.PayType; } else { paramPayType.Value = System.DBNull.Value; } if (oParam.PayAmt != AppConst.DecimalNull) { paramPayAmt.Value = oParam.PayAmt; } else { paramPayAmt.Value = System.DBNull.Value; } if (oParam.Status != AppConst.IntNull) { paramStatus.Value = oParam.Status; } else { paramStatus.Value = System.DBNull.Value; } cmd.Parameters.Add(paramSysNo); cmd.Parameters.Add(paramDLSysNo); cmd.Parameters.Add(paramItemID); cmd.Parameters.Add(paramItemType); cmd.Parameters.Add(paramPayType); cmd.Parameters.Add(paramPayAmt); cmd.Parameters.Add(paramStatus); return(SqlHelper.ExecuteNonQuery(cmd)); }
public int Insert(DLItemInfo oParam) { string sql = @"INSERT INTO DL_Item ( DLSysNo, ItemID, ItemType, PayType, PayAmt, Status ) VALUES ( @DLSysNo, @ItemID, @ItemType, @PayType, @PayAmt, @Status );set @SysNo = SCOPE_IDENTITY();"; SqlCommand cmd = new SqlCommand(sql); SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int, 4); SqlParameter paramDLSysNo = new SqlParameter("@DLSysNo", SqlDbType.Int, 4); SqlParameter paramItemID = new SqlParameter("@ItemID", SqlDbType.NVarChar, 50); SqlParameter paramItemType = new SqlParameter("@ItemType", SqlDbType.Int, 4); SqlParameter paramPayType = new SqlParameter("@PayType", SqlDbType.Int, 4); SqlParameter paramPayAmt = new SqlParameter("@PayAmt", SqlDbType.Decimal, 9); SqlParameter paramStatus = new SqlParameter("@Status", SqlDbType.Int, 4); paramSysNo.Direction = ParameterDirection.Output; if (oParam.DLSysNo != AppConst.IntNull) { paramDLSysNo.Value = oParam.DLSysNo; } else { paramDLSysNo.Value = System.DBNull.Value; } if (oParam.ItemID != AppConst.StringNull) { paramItemID.Value = oParam.ItemID; } else { paramItemID.Value = System.DBNull.Value; } if (oParam.ItemType != AppConst.IntNull) { paramItemType.Value = oParam.ItemType; } else { paramItemType.Value = System.DBNull.Value; } if (oParam.PayType != AppConst.IntNull) { paramPayType.Value = oParam.PayType; } else { paramPayType.Value = System.DBNull.Value; } if (oParam.PayAmt != AppConst.DecimalNull) { paramPayAmt.Value = oParam.PayAmt; } else { paramPayAmt.Value = System.DBNull.Value; } if (oParam.Status != AppConst.IntNull) { paramStatus.Value = oParam.Status; } else { paramStatus.Value = System.DBNull.Value; } cmd.Parameters.Add(paramSysNo); cmd.Parameters.Add(paramDLSysNo); cmd.Parameters.Add(paramItemID); cmd.Parameters.Add(paramItemType); cmd.Parameters.Add(paramPayType); cmd.Parameters.Add(paramPayAmt); cmd.Parameters.Add(paramStatus); return(SqlHelper.ExecuteNonQuery(cmd, out oParam.SysNo)); }