public void Init() { lock (ratioLock) { int ratioTotal = 0; if (ratioHash != null) { ratioHash.Clear(); } if (allocatedMenHash != null) { allocatedMenHash.Clear(); } string sql = "select * from SO_User_AuditRatio"; DataSet ds = SqlHelper.ExecuteDataSet(sql); if (!Util.HasMoreRow(ds)) { return; } foreach (DataRow dr in ds.Tables[0].Rows) { ratioTotal += Util.TrimIntNull(dr["Ratio"]); if (!allocatedMenHash.ContainsKey(Util.TrimIntNull(dr["UserSysNo"]))) { UserInfo user = SysManager.GetInstance().LoadUser(Util.TrimIntNull(dr["UserSysNo"])); allocatedMenHash.Add(Util.TrimIntNull(dr["UserSysno"]), user); } } foreach (DataRow dr in ds.Tables[0].Rows) { SOUserAuditRatioInfo item = new SOUserAuditRatioInfo(); map(item, dr); if (ratioHash == null) { ratioHash = new Hashtable(5); } for (int i = 0; i < item.Ratio; i++) { bool found = false; do { System.Random oRandom = new System.Random(RandomString.GetNewSeed()); int tempkey = oRandom.Next(ratioTotal); if (!ratioHash.ContainsKey(tempkey)) { found = true; ratioHash.Add(tempkey, item.UserSysNo); } } while (!found); } } } }
public void InspectionInit() { lock (ratioLock) { int ratioTotal = 0; if (InspectionratioHash != null) { InspectionratioHash.Clear(); } if (allocatedInspectionMenHash != null) { allocatedInspectionMenHash.Clear(); } string sql = "select * from WH_User_WorkRatio where WorkType=" + (int)AppEnum.WhWorkType.ProductInspection + "and BillType=" + (int)AppEnum.WhWorkBillType.SO; DataSet ds = SqlHelper.ExecuteDataSet(sql); if (!Util.HasMoreRow(ds)) { return; } foreach (DataRow dr in ds.Tables[0].Rows) { ratioTotal += Util.TrimIntNull(dr["Ratio"]); if (!allocatedInspectionMenHash.ContainsKey(Util.TrimIntNull(dr["UserSysNo"]))) { UserInfo user = SysManager.GetInstance().LoadUser(Util.TrimIntNull(dr["UserSysNo"])); allocatedInspectionMenHash.Add(Util.TrimIntNull(dr["UserSysno"]), user); } } foreach (DataRow dr in ds.Tables[0].Rows) { WHUserWorkRatioInfo item = new WHUserWorkRatioInfo(); map(item, dr); if (InspectionratioHash == null) { InspectionratioHash = new Hashtable(5); } for (int i = 0; i < item.Ratio; i++) { bool found = false; do { System.Random oRandom = new System.Random(RandomString.GetNewSeed()); int tempkey = oRandom.Next(ratioTotal); if (!InspectionratioHash.ContainsKey(tempkey)) { found = true; InspectionratioHash.Add(tempkey, item.UserSysNo); } } while (!found); } } } }
/// <summary> /// 获取ro发票 /// </summary> /// <param name="roSysNo"></param> /// <returns></returns> public ROInvoiceInfo GetROInvoice(int roSysNo) { ROInvoiceInfo invoice = new ROInvoiceInfo(); ROInfo ro = this.LoadRO(roSysNo); RMAInfo rma = RMAManager.GetInstance().Load(ro.RMASysNo); SOInfo so = SaleManager.GetInstance().LoadSO(rma.SOSysNo); IcsonInfo son = new IcsonInfo(); invoice.AuditUserSysNo = ro.AuditUserSysNo; invoice.CompanyAddress = son.CompanyAddress; invoice.InvoiceNote = so.InvoiceNote; invoice.SOID = so.SOID; PayTypeInfo ptInfo = ASPManager.GetInstance().LoadPayType(so.PayTypeSysNo); invoice.PayTypeName = ptInfo.PayTypeName; invoice.ReceiveAddress = ro.ReceiveAddress; CustomerInfo customer = CustomerManager.GetInstance().Load(so.CustomerSysNo); invoice.CustomerName = customer.CustomerName; invoice.CustomerSysNo = customer.SysNo; invoice.ReceiveName = ro.ReceiveName; invoice.ReceivePhone = ro.ReceivePhone; invoice.ROID = ro.ROID; invoice.ROSysNo = ro.SysNo; ShipTypeInfo stInfo = ASPManager.GetInstance().LoadShipType(so.ShipTypeSysNo); invoice.ShipTypeName = stInfo.ShipTypeName; UserInfo employee = SysManager.GetInstance().LoadUser(so.OutUserSysNo); if (employee != null) { invoice.WarehouseUserCode = employee.UserID; } else { invoice.WarehouseUserCode = ""; } this.InitPageList(ro, invoice); invoice.TotalPage = invoice.ItemHash.Count; invoice.TotalWeight = ro.GetTotalWeight(); return(invoice); }
public void Import() { if (!AppConfig.IsImportable) { throw new BizException("Is Importable is false"); } string sql = " select top 1 sysno from finance_soincome"; DataSet ds = SqlHelper.ExecuteDataSet(sql); if (Util.HasMoreRow(ds)) { throw new BizException("the table finance_soincome is not empty"); } TransactionOptions options = new TransactionOptions(); options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; options.Timeout = TransactionManager.DefaultTimeout; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options)) { //1 将原来的收款单导入, //2 对于有应收而没有收款单的,因为原来的早一点的应收记录不准确的, // 所以这部分的来源用 so已经出库而没有收款单的,生成收款单 // ??? UserInfo oUser = SysManager.GetInstance().LoadUser("0061"); string sql2 = @"select 0 as sysno, ordertype, SOorUTSysNo as ordersysno, incomeamt as orderamt, incomeamt_local as incomeamt, incometype as incomestyle, createtime as incometime, con_user1.newsysno as incomeUserSysNo, con_user2.newsysno as confirmUserSysNo, null as confirmTime, note, status from ipp2003..so_income as so_income, ippConvert..sys_user as con_user1, ippConvert..sys_user as con_user2 where so_income.createusersysno *= con_user1.oldsysno and so_income.accountsysno *= con_user2.oldsysno order by so_income.ordersysno asc, so_income.status desc" ; DataSet ds2 = SqlHelper.ExecuteDataSet(sql2); int lastsosysno = AppConst.IntNull; bool gotvalid = false; //如果有多条valid(orign 和 confirm)只能导入一条 foreach (DataRow dr in ds2.Tables[0].Rows) { SOIncomeInfo item = new SOIncomeInfo(); map(item, dr); //当前的是一个新的sosysno if (lastsosysno != item.OrderSysNo) { lastsosysno = item.OrderSysNo; gotvalid = false; } /*old * IncomeType 0:正常 1:预收 2:退款 * ordertype 0: so, 1: ro * status 0: 已确认 -1:作废 -2:未确认 */ if (item.OrderType == 0) { item.OrderType = (int)AppEnum.SOIncomeOrderType.SO; } else if (item.OrderType == 1) { item.OrderType = (int)AppEnum.SOIncomeOrderType.RO; } else { throw new BizException("no such order type"); } if (item.IncomeStyle == 0) { item.IncomeStyle = (int)AppEnum.SOIncomeStyle.Normal; } else if (item.IncomeStyle == 1) { item.IncomeStyle = (int)AppEnum.SOIncomeStyle.Advanced; } else if (item.IncomeStyle == 2) { item.IncomeStyle = (int)AppEnum.SOIncomeStyle.RO; } else { throw new BizException("no such imcometype"); } if (item.Status == -1) { item.Status = (int)AppEnum.SOIncomeStatus.Abandon; } else if (item.Status == -2) { item.Status = (int)AppEnum.SOIncomeStatus.Origin; } else if (item.Status == 0) { item.Status = (int)AppEnum.SOIncomeStatus.Confirmed; } else { throw new BizException("no such status"); } if (item.IncomeUserSysNo == AppConst.IntNull) { item.IncomeUserSysNo = oUser.SysNo; } if (item.ConfirmUserSysNo != AppConst.IntNull) { item.ConfirmTime = DateTime.Now; } if (item.Status == (int)AppEnum.SOIncomeStatus.Abandon || !gotvalid) { new SOIncomeDac().Insert(item); if (item.Status == (int)AppEnum.SOIncomeStatus.Origin || item.Status == (int)AppEnum.SOIncomeStatus.Confirmed) { gotvalid = true; } } } /* * 这种情况下导入的数据有问题,sql1里面用的是cashamt, 这个仅仅是so的货款现金支付部分。 * 用下面的语句更新如下 2005.05.18 18:42 by marco * update finance_soincome * set * orderamt = round(cashamt+shipprice+premiumamt+payprice,2), * incomeamt = round(cashamt+shipprice+premiumamt+payprice,2) * * from * ipp2003..so_master so, * ippConvert..sys_user as con_user * where * so.warehouseUserSysNo =con_user.oldsysno * and so.status = 4 * and so.soid not in * ( select soOrUtid from ipp2003..so_income where ordertype = 0) * and outtime >= '2003-08-07' * and so.sysno = ordersysno and ordertype = 1 */ string sql1 = @"select 0 as sysno, 0 as orderType, so.sysno as orderSysNo, cashamt as orderamt, 0 as incomestyle, cashamt as incomeamt, outtime as incometime, con_user.newsysno as incomeusersysno, null as confirmtime, null as confirmusersysno, 'ipp3导入' as note, 0 as status from ipp2003..so_master so, ippConvert..sys_user as con_user where so.warehouseUserSysNo =con_user.oldsysno and so.status = 4 and so.soid not in ( select soOrUtid from ipp2003..so_income where ordertype = 0) and outtime >= '2003-08-07'" ; DataSet ds1 = SqlHelper.ExecuteDataSet(sql1); if (!Util.HasMoreRow(ds1)) { return; } foreach (DataRow dr in ds1.Tables[0].Rows) { SOIncomeInfo item = new SOIncomeInfo(); map(item, dr); item.OrderType = (int)AppEnum.SOIncomeOrderType.SO; item.IncomeStyle = (int)AppEnum.SOIncomeStyle.Normal; item.Status = (int)AppEnum.SOIncomeStatus.Origin; new SOIncomeDac().Insert(item); } scope.Complete(); } }