public int Update(DSItemInfo oParam) { string sql = @"UPDATE DS_Item SET DSSysNo=@DSSysNo, ItemID=@ItemID, ItemType=@ItemType, PayType=@PayType, PayAmt=@PayAmt, Status=@Status, PosFee=@PosFee, DLSysNo=@DLSysNo, IsPos=@IsPos WHERE SysNo=@SysNo"; SqlCommand cmd = new SqlCommand(sql); SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int, 4); SqlParameter paramDSSysNo = new SqlParameter("@DSSysNo", 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); SqlParameter paramPosFee = new SqlParameter("@PosFee", SqlDbType.Decimal, 9); SqlParameter paramDLSysNo = new SqlParameter("@DLSysNo", SqlDbType.Int, 4); SqlParameter paramIsPos = new SqlParameter("@IsPos", SqlDbType.Int, 4); if (oParam.SysNo != AppConst.IntNull) paramSysNo.Value = oParam.SysNo; else paramSysNo.Value = System.DBNull.Value; if (oParam.DSSysNo != AppConst.IntNull) paramDSSysNo.Value = oParam.DSSysNo; else paramDSSysNo.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; if (oParam.PosFee != AppConst.DecimalNull) paramPosFee.Value = oParam.PosFee; else paramPosFee.Value = System.DBNull.Value; if (oParam.DLSysNo != AppConst.IntNull) paramDLSysNo.Value = oParam.DLSysNo; else paramDLSysNo.Value = System.DBNull.Value; if (oParam.IsPos != AppConst.IntNull) paramIsPos.Value = oParam.IsPos; else paramIsPos.Value = System.DBNull.Value; cmd.Parameters.Add(paramSysNo); cmd.Parameters.Add(paramDSSysNo); cmd.Parameters.Add(paramItemID); cmd.Parameters.Add(paramItemType); cmd.Parameters.Add(paramPayType); cmd.Parameters.Add(paramPayAmt); cmd.Parameters.Add(paramStatus); cmd.Parameters.Add(paramPosFee); cmd.Parameters.Add(paramDLSysNo); cmd.Parameters.Add(paramIsPos); return SqlHelper.ExecuteNonQuery(cmd); }
public int Insert(DSItemInfo oParam) { string sql = @"INSERT INTO DS_Item ( DSSysNo, ItemID, ItemType, PayType, PayAmt, Status, PosFee, DLSysNo, IsPos ) VALUES ( @DSSysNo, @ItemID, @ItemType, @PayType, @PayAmt, @Status, @PosFee, @DLSysNo, @IsPos );set @SysNo = SCOPE_IDENTITY();"; SqlCommand cmd = new SqlCommand(sql); SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int, 4); SqlParameter paramDSSysNo = new SqlParameter("@DSSysNo", 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); SqlParameter paramPosFee = new SqlParameter("@PosFee", SqlDbType.Decimal, 9); SqlParameter paramDLSysNo = new SqlParameter("@DLSysNo", SqlDbType.Int, 4); SqlParameter paramIsPos = new SqlParameter("@IsPos", SqlDbType.Int, 4); paramSysNo.Direction = ParameterDirection.Output; if (oParam.DSSysNo != AppConst.IntNull) paramDSSysNo.Value = oParam.DSSysNo; else paramDSSysNo.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; if (oParam.PosFee != AppConst.DecimalNull) paramPosFee.Value = oParam.PosFee; else paramPosFee.Value = System.DBNull.Value; if (oParam.DLSysNo != AppConst.IntNull) paramDLSysNo.Value = oParam.DLSysNo; else paramDLSysNo.Value = System.DBNull.Value; if (oParam.IsPos != AppConst.IntNull) paramIsPos.Value = oParam.IsPos; else paramIsPos.Value = System.DBNull.Value; cmd.Parameters.Add(paramSysNo); cmd.Parameters.Add(paramDSSysNo); cmd.Parameters.Add(paramItemID); cmd.Parameters.Add(paramItemType); cmd.Parameters.Add(paramPayType); cmd.Parameters.Add(paramPayAmt); cmd.Parameters.Add(paramStatus); cmd.Parameters.Add(paramPosFee); cmd.Parameters.Add(paramDLSysNo); cmd.Parameters.Add(paramIsPos); return SqlHelper.ExecuteNonQuery(cmd, out oParam.SysNo); }
public void CreateDS(string dlsysnolist, int usersysno, DSInfo oDSInfo) { try { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { decimal ARAmt = 0; decimal IncomeAmt = 0; int FreightUser = 0; oDSInfo.ItemHash.Clear(); string NullFreightItem = ""; string[] DLSysNoList = dlsysnolist.Split(','); int i = 0; for (i = 0; i < DLSysNoList.Length; i++) { int DLSysNo = Int32.Parse(DLSysNoList[i]); DLInfo oDLInfo = DLManager.GetInstance().Load(DLSysNo); if (oDLInfo == null) { throw new BizException(DLSysNo + "��Ӧ�����͵�������"); } else if (oDLInfo.Status != (int)AppEnum.DLStatus.StockConfirmed) { throw new BizException(DLSysNo + "���͵�����ȷ�Ϸ���״̬���������ɽ��㵥"); } else if (oDLInfo.Status == (int)AppEnum.DLStatus.DSConfirmed) { throw new BizException(DLSysNo + "�˵������ɽ��㵥�������ظ�����"); } FreightUser = oDLInfo.FreightUserSysNo; foreach (DLItemInfo oItem in oDLInfo.ItemHash.Values) { if (oItem.Status == (int)AppEnum.BiStatus.Valid) { if (oItem.ItemType == (int)AppEnum.DLItemType.SaleOrder) { int sosysno = Convert.ToInt32(oItem.ItemID.Substring(1)); SOInfo oSOInfo = SaleManager.GetInstance().LoadSOMaster(sosysno); if (oSOInfo.FreightUserSysNo == AppConst.IntNull) { NullFreightItem += oSOInfo.SOID + ","; } else if (NullFreightItem == "" && oSOInfo.FreightUserSysNo == oDLInfo.FreightUserSysNo && oSOInfo.DLSysNo == oDLInfo.SysNo) { if (oSOInfo.Status == (int)AppEnum.SOStatus.OutStock) { DSItemInfo oDSItem = new DSItemInfo(); oDSItem.ItemID = oItem.ItemID; oDSItem.ItemType = oItem.ItemType; oDSItem.PayType = oItem.PayType; oDSItem.DLSysNo = oItem.DLSysNo; if (oSOInfo.PayTypeSysNo == 1) //��������ȥ��ͷ { oDSItem.PayAmt = Util.TruncMoney(oSOInfo.GetTotalAmt()); IncomeAmt += oDSItem.PayAmt; } else { oDSItem.PayAmt = 0; IncomeAmt += oItem.PayAmt; } oDSInfo.ItemHash.Add(oDSItem, oDSItem); ARAmt += oDSItem.PayAmt; } else if (oSOInfo.Status == (int)AppEnum.SOStatus.PartlyReturn) { DSItemInfo oDSItem = new DSItemInfo(); oDSItem.ItemID = oItem.ItemID; oDSItem.ItemType = oItem.ItemType; oDSItem.PayType = oItem.PayType; oDSItem.DLSysNo = oItem.DLSysNo; decimal returnAmt = 0; SOInfo oSOInfo2 = SaleManager.GetInstance().LoadSO(oSOInfo.SysNo); foreach (SOItemInfo oSOItem in oSOInfo2.ItemHash.Values) { if (oSOItem.ReturnQty != AppConst.IntNull) { returnAmt += oSOItem.ReturnQty * oSOItem.Price; } } if (oSOInfo.PayTypeSysNo == 1) //��������ȥ��ͷ { oDSItem.PayAmt = Util.TruncMoney(oSOInfo.GetTotalAmt() - returnAmt); IncomeAmt += Util.TruncMoney(oSOInfo.GetTotalAmt() - returnAmt); } else { oDSItem.PayAmt = 0; IncomeAmt += oItem.PayAmt; } oDSInfo.ItemHash.Add(oDSItem, oDSItem); ARAmt += oDSItem.PayAmt; } } } else if (oItem.ItemType == (int)AppEnum.DLItemType.RMARequest) { int FreightUserSysNo = RMARequestManager.GetInstance().GetFreightUserSysNofromID(oItem.ItemID); int RequestDLSysNo = RMARequestManager.GetInstance().GetDLSysNofromID(oItem.ItemID); if (FreightUserSysNo == AppConst.IntNull) { NullFreightItem += oItem.ItemID + ","; } else if (NullFreightItem == "" && FreightUserSysNo == oDLInfo.FreightUserSysNo && RequestDLSysNo == oDLInfo.SysNo) { DSItemInfo oDSItem = new DSItemInfo(); oDSItem.ItemID = oItem.ItemID; oDSItem.ItemType = oItem.ItemType; oDSItem.PayType = oItem.PayType; oDSItem.PayAmt = oItem.PayAmt; oDSItem.DLSysNo = oItem.DLSysNo; oDSInfo.ItemHash.Add(oDSItem, oDSItem); ARAmt += oItem.PayAmt; IncomeAmt += oItem.PayAmt; } } else if (oItem.ItemType == (int)AppEnum.DLItemType.RMAOutbound) { int FreightUserSysNo = RMAOutBoundManager.GetInstance().GetFreightUserSysNoByID(oItem.ItemID); int OutboundDLSysNo = RMAOutBoundManager.GetInstance().GetDLSysNoSysNoByID(oItem.ItemID); if (FreightUserSysNo == AppConst.IntNull) { NullFreightItem += oItem.ItemID + ","; } else if (NullFreightItem == "" && FreightUserSysNo == oDLInfo.FreightUserSysNo && OutboundDLSysNo == oDLInfo.SysNo) { DSItemInfo oDSItem = new DSItemInfo(); oDSItem.ItemID = oItem.ItemID; oDSItem.ItemType = oItem.ItemType; oDSItem.PayType = oItem.PayType; oDSItem.DLSysNo = oItem.DLSysNo; oDSItem.PayAmt = 0; oDSInfo.ItemHash.Add(oDSItem, oDSItem); ARAmt += 0; IncomeAmt += 0; } } else if (oItem.ItemType == (int)AppEnum.DLItemType.RMARevert) { int FreightUserSysNo = RMARevertManager.GetInstance().GetFreightUserSysNofromID(oItem.ItemID); int RevertDLSysNo = RMARevertManager.GetInstance().GetDLSysNofromID(oItem.ItemID); if (FreightUserSysNo == AppConst.IntNull) { NullFreightItem += oItem.ItemID + ","; } else if (NullFreightItem == "" && FreightUserSysNo == oDLInfo.FreightUserSysNo && RevertDLSysNo == oDLInfo.SysNo) { DSItemInfo oDSItem = new DSItemInfo(); oDSItem.ItemID = oItem.ItemID; oDSItem.ItemType = oItem.ItemType; oDSItem.PayType = oItem.PayType; oDSItem.DLSysNo = oItem.DLSysNo; oDSItem.PayAmt = 0; oDSInfo.ItemHash.Add(oDSItem, oDSItem); ARAmt += 0; IncomeAmt += 0; } } else if (oItem.ItemType == (int)AppEnum.DLItemType.RMASendAccessory) { int FreightUserSysNo = RMASendAccessoryManager.GetInstance().GetFreightUserSysNoByID(oItem.ItemID); int SendAccessoryDLSysNo = RMASendAccessoryManager.GetInstance().GetDLSysNoByID(oItem.ItemID); if (FreightUserSysNo == AppConst.IntNull) { NullFreightItem += oItem.ItemID + ","; } else if (NullFreightItem == "" && FreightUserSysNo == oDLInfo.FreightUserSysNo && SendAccessoryDLSysNo == oDLInfo.SysNo) { DSItemInfo oDSItem = new DSItemInfo(); oDSItem.ItemID = oItem.ItemID; oDSItem.ItemType = oItem.ItemType; oDSItem.PayType = oItem.PayType; oDSItem.DLSysNo = oItem.DLSysNo; oDSItem.PayAmt = 0; oDSInfo.ItemHash.Add(oDSItem, oDSItem); ARAmt += 0; IncomeAmt += 0; } } else if (oItem.ItemType == (int)AppEnum.DLItemType.StShift) { ShiftInfo oInfo = ShiftManager.GetInstance().Load(Int32.Parse(oItem.ItemID.Substring(2))); int FreightUserSysNo = oInfo.FreightUserSysNo; int stShiftDLSysNo = oInfo.DLSysNo; if (FreightUserSysNo == AppConst.IntNull) { NullFreightItem += oItem.ItemID + ","; } else if (NullFreightItem == "" && FreightUserSysNo == oDLInfo.FreightUserSysNo && stShiftDLSysNo == oDLInfo.SysNo) { DSItemInfo oDSItem = new DSItemInfo(); oDSItem.ItemID = oItem.ItemID; oDSItem.ItemType = oItem.ItemType; oDSItem.PayType = oItem.PayType; oDSItem.DLSysNo = oItem.DLSysNo; oDSItem.PayAmt = 0; oDSInfo.ItemHash.Add(oDSItem, oDSItem); ARAmt += 0; IncomeAmt += 0; } } } } oDLInfo.Status = (int)AppEnum.DLStatus.DSConfirmed; DLManager.GetInstance().UpdateDLMaster(oDLInfo); } if (NullFreightItem != "") { throw new BizException(NullFreightItem + "û�������ˣ����������ã�"); } if (oDSInfo.ItemHash.Count <= 0) { throw new BizException("���͵���û�����ͳɹ��ĵ���"); } oDSInfo.CreateTime = DateTime.Now; oDSInfo.CreateUserSysNo = usersysno; oDSInfo.FreightUserSysNo = FreightUser; oDSInfo.ARAmt = ARAmt; oDSInfo.IncomeAmt = IncomeAmt; DSManager.GetInstance().CreateDS(oDSInfo); scope.Complete(); } } catch (Exception ex) { throw ex; } }
private void map(DSItemInfo oParam, DataRow tempdr) { oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]); oParam.DSSysNo = Util.TrimIntNull(tempdr["DSSysNo"]); 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"]); oParam.PosFee = Util.TrimDecimalNull(tempdr["PosFee"]); oParam.DLSysNo = Util.TrimIntNull(tempdr["DLSysNo"]); oParam.IsPos = Util.TrimIntNull(tempdr["IsPos"]); oParam.PosNo = Util.TrimNull(tempdr["PosNo"]); oParam.PosDate = Util.TrimDateNull(tempdr["PosDate"]); }
private void InsertDSItem(DSItemInfo oParam) { TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { new DSDac().Insert(oParam); scope.Complete(); } }
public DSItemInfo LoadDSItem(int sysno) { string sql = "select * from DS_Item where sysno =" + sysno; DataSet ds = SqlHelper.ExecuteDataSet(sql); DSItemInfo oItemInfo = new DSItemInfo(); if (Util.HasMoreRow(ds)) { map(oItemInfo, ds.Tables[0].Rows[0]); return oItemInfo; } else return null; }