private void btmSearchShifts_Click(object sender, EventArgs e)
        {
            try
            {
                this.dsItems.Clear();
            }
            catch (System.NullReferenceException)
            { }

            DateTime dtFromDate = new DateTime();
            DateTime dtToDate   = new DateTime();

            if (this.cekDate.Checked)
            {
                dtFromDate = new DateTime(this.dtpFromDate.Value.Year, this.dtpFromDate.Value.Month, this.dtpFromDate.Value.Day);
                dtToDate   = new DateTime(this.dtpToDate.Value.Year, this.dtpToDate.Value.Month, this.dtpToDate.Value.Day);
            }

            this.mfsSearch.shiShiftPty = ShiftInfo.ConvertTextToShift(this.cbShift.Text);
            this.mfsSearch.strGroupPty = this.cbGroup.Text;

            this.dsShifts = MaintenanceFurnaceShift.GetMFSs(this.cnConnection, mfsSearch, dtFromDate, dtToDate);

            this.dgvShifts.DataSource = this.dsShifts;
            this.dgvShifts.DataMember = "tabMaintenanceFurnaceShifts";

            for (int i = 0; i < this.dsShifts.Tables["tabMaintenanceFurnaceShifts"].Rows.Count; i++)
            {
                int intShift = int.Parse(this.dsShifts.Tables["tabMaintenanceFurnaceShifts"].Rows[i]["nvcShift"].ToString());
                this.dsShifts.Tables["tabMaintenanceFurnaceShifts"].Rows[i]["nvcShift"] = ((ShiftInfo.Shift)intShift).ToString();
            }
        }
Beispiel #2
0
    public static IEnumerable <ShiftWorkItem> EnumerateShifts(this ShiftConfig config, DateTime from, DateTime until)
    {
        DateTime  day        = from.Date.AddDays(-1);
        DateTime? shiftStart = null;
        ShiftInfo lastShift  = null;

        while (true)
        {
            foreach (var shift in config)
            {
                var shiftEnd = day.Add(shift.StartTime);
                if (shiftStart != null)
                {
                    if ((shiftStart.Value <= from && shiftEnd >= from) || (shiftStart.Value <= until && shiftEnd >= until) || (shiftStart.Value > from && shiftEnd <= until))
                    {
                        var workFrom  = shiftStart.Value < from ? from : shiftStart.Value;
                        var workUntil = shiftEnd > until ? until : shiftEnd;
                        yield return(new ShiftWorkItem(lastShift, shiftStart.Value, shiftEnd, workFrom, workUntil));
                    }
                }

                if (shiftEnd >= until)
                {
                    yield break;
                }

                shiftStart = shiftEnd;
                lastShift  = shift;
            }

            day = day.AddDays(1);
        }
    }
Beispiel #3
0
        public void UpdateMaster(ShiftInfo oParam)
        {
            //主项可以更新note
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                //必须是初始状态
                if (getCurrentStatus(oParam.SysNo) != (int)AppEnum.ShiftStatus.Origin)
                {
                    throw new BizException("status is not origin now,  update failed");
                }

                //设置 单号, 备注
                Hashtable ht = new Hashtable(3);
                ht.Add("SysNo", oParam.SysNo);
                ht.Add("Note", oParam.Note);
                if (1 != new ShiftDac().UpdateMaster(ht))
                {
                    throw new BizException("expected one-row update failed, update failed ");
                }

                scope.Complete();
            }
        }
Beispiel #4
0
        public async Task <IActionResult> Edit(int id, [Bind("ShiftId,ShiftName")] ShiftInfo shiftInfo)
        {
            if (id != shiftInfo.ShiftId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(shiftInfo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ShiftInfoExists(shiftInfo.ShiftId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(shiftInfo));
        }
Beispiel #5
0
        public void Create(ShiftInfo oParam)
        {
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                oParam.SysNo   = SequenceDac.GetInstance().Create("St_Shift_Sequence");
                oParam.ShiftID = getShiftID(oParam.SysNo);
                //建立主表记录
                int rowsAffected = new ShiftDac().InsertMaster(oParam);
                if (rowsAffected != 1)
                {
                    throw new BizException("insert shift master error");
                }
                foreach (ShiftItemInfo item in oParam.itemHash.Values)
                {
                    item.ShiftSysNo = oParam.SysNo;

                    rowsAffected = new ShiftDac().InsertItem(item);
                    if (rowsAffected != 1)
                    {
                        throw new BizException("insert shift item error");
                    }
                    InventoryManager.GetInstance().SetAvailableQty(oParam.StockSysNoA, item.ProductSysNo, item.ShiftQty);
                }

                scope.Complete();
            }
        }
Beispiel #6
0
        /// <summary>
        /// Initialize the householder vectors for the QR step.
        /// </summary>
        /// <param name="il">the index of the small sub-diagonal element</param>
        /// <param name="iu">the current eigenvalue index</param>
        /// <param name="shift">shift information holder</param>
        /// <param name="hVec">the initial houseHolder vector</param>
        /// <returns>the start index for the QR step</returns>
        private int initQRStep(int il, int iu, ShiftInfo shift, double[] hVec)
        {
            // Look for two consecutive small sub-diagonal elements
            int im = iu - 2;

            while (im >= il)
            {
                double z = matrixT[im][im];
                double r = shift.x - z;
                double s = shift.y - z;
                hVec[0] = (r * s - shift.w) / matrixT[im + 1][im] + matrixT[im][im + 1];
                hVec[1] = matrixT[im + 1][im + 1] - z - r - s;
                hVec[2] = matrixT[im + 2][im + 1];

                if (im == il)
                {
                    break;
                }

                double lhs = FastMath.abs(matrixT[im][im - 1]) * (FastMath.abs(hVec[1]) + FastMath.abs(hVec[2]));
                double rhs = FastMath.abs(hVec[0]) * (FastMath.abs(matrixT[im - 1][im - 1]) +
                                                      FastMath.abs(z) +
                                                      FastMath.abs(matrixT[im + 1][im + 1]));

                if (lhs < epsilon * rhs)
                {
                    break;
                }
                im--;
            }

            return(im);
        }
Beispiel #7
0
        public void CancelInStock(int masterSysNo, int userSysNo)
        {
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                ShiftInfo masterInfo = Load(masterSysNo);

                //必须是已出库
                if (masterInfo.Status != (int)AppEnum.ShiftStatus.InStock)
                {
                    throw new BizException("status is not instock now,  cancel instock failed");
                }

                //RMA发货单已发货,则不能取消入库
                Hashtable Registerht = new Hashtable();
                Registerht.Add("ShiftSysNo", masterInfo.SysNo);
                Registerht.Add("RevertStatus", (int)AppEnum.RMARevertStatus.Reverted);
                DataSet ds = GetRMARegisterByShiftSysNo(Registerht);
                if (Util.HasMoreRow(ds))
                {
                    throw new BizException("存在已出库的发货单,不能取消取出库 ");
                }
                else
                {
                    Hashtable Registerht2 = new Hashtable();
                    Registerht2.Add("ShiftSysNo", masterSysNo);
                    DataSet ds2 = GetRMARegisterByShiftSysNo(Registerht2);
                    if (Util.HasMoreRow(ds2))
                    {
                        foreach (DataRow dr in ds2.Tables[0].Rows)
                        {
                            string sql = @"update RMA_Register set ShiftStatus=" + (int)AppEnum.ShiftStatus.OutStock + "where sysno=" + Util.TrimIntNull(dr["registersysno"]);
                            SqlHelper.ExecuteNonQuery(sql);
                        }
                    }
                }

                //设置 单号、状态
                Hashtable ht = new Hashtable(4);
                ht.Add("SysNo", masterInfo.SysNo);
                ht.Add("Status", (int)AppEnum.ShiftStatus.OutStock);
                ht.Add("InTime", DateTime.Now);
                ht.Add("InUserSysNo", userSysNo);
                if (1 != new ShiftDac().UpdateMaster(ht))
                {
                    throw new BizException("expected one-row update failed, instock failed ");
                }

                foreach (ShiftItemInfo item in masterInfo.itemHash.Values)
                {
                    //库存设定
                    InventoryManager.GetInstance().SetShiftInStockQty(masterInfo.StockSysNoA, masterInfo.StockSysNoB, item.ProductSysNo, -1 * item.ShiftQty);
                }
                scope.Complete();
            }
        }
Beispiel #8
0
 public ShiftWorkItem(ShiftInfo shift, DateTime shiftFrom, DateTime shiftUntil, DateTime workFrom, DateTime workUntil)
 {
     Shift      = shift;
     ShiftFrom  = shiftFrom;
     ShiftUntil = shiftUntil;
     WorkFrom   = workFrom;
     WorkUntil  = workUntil;
 }
Beispiel #9
0
        // == == == == == Puzzle 1 == == == == ==
        public static int Puzzle1(string input)
        {
            var records = new List <Record>();

            // Parse input
            foreach (var rawRecord in Common.ParseStringArray(input))
            {
                var record = new Record(rawRecord);
                records.Add(record);
            }
            records.Sort((x, y) => x.Time.CompareTo(y.Time));
            // Create ShiftInfos
            var        guardStats = new Dictionary <int, GuardStats>();
            GuardStats gs;
            ShiftInfo  si = null;

            foreach (var record in records)
            {
                // Shift Start
                if (record.Type == Record.RecordType.ShiftStart)
                {
                    // Next guard
                    si = new ShiftInfo(record);
                    if (guardStats.TryGetValue(record.ID, out gs))
                    {
                        gs.AddShift(si);
                    }
                    else
                    {
                        gs    = new GuardStats();
                        gs.ID = si.ID;
                        gs.AddShift(si);
                        guardStats.Add(gs.ID, gs);
                    }
                }
                // FallAsleep / WakeUp
                else
                {
                    si.AddRecord(record);
                }
            }
            // Find sleepiest guard
            int maxAsleepMin = 0, maxAsleepID = 0;

            foreach (var guard in guardStats)
            {
                var minSleep = guard.Value.MinutesAsleep;
                if (minSleep > maxAsleepMin)
                {
                    maxAsleepMin = minSleep;
                    maxAsleepID  = guard.Value.ID;
                }
            }

            return(guardStats[maxAsleepID].FindSleepiestMinute(out int noNeed) * maxAsleepID);
        }
Beispiel #10
0
        public async Task <IActionResult> Create([Bind("ShiftId,ShiftName")] ShiftInfo shiftInfo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(shiftInfo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(shiftInfo));
        }
Beispiel #11
0
        /// <summary>
        /// Compute the shift for the current iteration.
        /// </summary>
        /// <param name="l">the index of the small sub-diagonal element</param>
        /// <param name="idx">the current eigenvalue index</param>
        /// <param name="iteration">the current iteration</param>
        /// <param name="shift">holder for shift information</param>
        private void computeShift(int l, int idx, int iteration, ShiftInfo shift)
        {
            // Form shift
            shift.x = matrixT[idx][idx];
            shift.y = shift.w = 0.0;
            if (l < idx)
            {
                shift.y = matrixT[idx - 1][idx - 1];
                shift.w = matrixT[idx][idx - 1] * matrixT[idx - 1][idx];
            }

            // Wilkinson's original ad hoc shift
            if (iteration == 10)
            {
                shift.exShift += shift.x;
                for (int i = 0; i <= idx; i++)
                {
                    matrixT[i][i] -= shift.x;
                }
                double s = FastMath.abs(matrixT[idx][idx - 1]) + FastMath.abs(matrixT[idx - 1][idx - 2]);
                shift.x = 0.75 * s;
                shift.y = 0.75 * s;
                shift.w = -0.4375 * s * s;
            }

            // MATLAB's new ad hoc shift
            if (iteration == 30)
            {
                double s = (shift.y - shift.x) / 2.0;
                s = s * s + shift.w;
                if (s > 0.0)
                {
                    s = FastMath.sqrt(s);
                    if (shift.y < shift.x)
                    {
                        s = -s;
                    }
                    s = shift.x - shift.w / ((shift.y - shift.x) / 2.0 + s);
                    for (int i = 0; i <= idx; i++)
                    {
                        matrixT[i][i] -= s;
                    }
                    shift.exShift += s;
                    shift.x        = shift.y = shift.w = 0.964;
                }
            }
        }
Beispiel #12
0
        public void Abandon(int masterSysNo)
        {
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                ShiftInfo masterInfo = Load(masterSysNo);

                //必须是初始状态
                if (masterInfo.Status != (int)AppEnum.ShiftStatus.Origin)
                {
                    throw new BizException("status is not origin now ,  abandon failed");
                }

                //设置 单号、状态
                Hashtable ht = new Hashtable(4);
                ht.Add("SysNo", masterSysNo);
                ht.Add("Status", (int)AppEnum.ShiftStatus.Abandon);
                if (1 != new ShiftDac().UpdateMaster(ht))
                {
                    throw new BizException("expected one-row update failed, abandon failed ");
                }

                //取消对available数量的占用
                foreach (ShiftItemInfo item in masterInfo.itemHash.Values)
                {
                    InventoryManager.GetInstance().SetAvailableQty(masterInfo.StockSysNoA, item.ProductSysNo, -1 * item.ShiftQty);
                }

                //设置RMA单件的状态
                Hashtable Registerht = new Hashtable();
                Registerht.Add("ShiftSysNo", masterSysNo);
                DataSet ds = GetRMARegisterByShiftSysNo(Registerht);
                if (Util.HasMoreRow(ds))
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        string sql = @"update RMA_Register set ShiftStatus=" + (int)AppEnum.ShiftStatus.Abandon + "where sysno=" + Util.TrimIntNull(dr["registersysno"]);
                        SqlHelper.ExecuteNonQuery(sql);
                    }
                }
                scope.Complete();
            }
        }
    private void Restock(int shiftIdx)
    {
        int dept, amountToRestock;

        foreach (FoodItem food in Stock)
        {
            dept = food.Department;
            ShiftInfo shift = (ShiftInfo)Shifts[shiftIdx];

            // restock if there is an employee in this department
            if (shift.Employees[DepartmentNames[food.Department]] != 0)
            {
                amountToRestock = Mathf.Min(food.MaxFOH - food.StockFOH, food.StockBOH);
                food.StockFOH  += amountToRestock;
                food.StockBOH  -= amountToRestock;
            }
        }
    }
Beispiel #14
0
 /// <summary>
 /// 设置班次信息
 /// </summary>
 /// <param name="loggingSessionInfo">登录信息</param>
 /// <param name="shiftInfoList">班次集合</param>
 /// <param name="strError">错误信息输出</param>
 /// <returns></returns>
 public bool SetShiftInfoList(LoggingSessionInfo loggingSessionInfo, IList <ShiftInfo> shiftInfoList, out string strError)
 {
     cSqlMapper.Instance(loggingSessionInfo.CurrentLoggingManager).BeginTransaction();
     try
     {
         ShiftInfo shiftInfo = new ShiftInfo();
         shiftInfo.ShiftListInfo = shiftInfoList;
         cSqlMapper.Instance(loggingSessionInfo.CurrentLoggingManager).Update("Shift.InsertOrUpdate", shiftInfo);
         cSqlMapper.Instance(loggingSessionInfo.CurrentLoggingManager).CommitTransaction();
         strError = "";
         return(true);
     }
     catch (Exception ex) {
         cSqlMapper.Instance(loggingSessionInfo.CurrentLoggingManager).RollBackTransaction();
         strError = ex.ToString();
         throw (ex);
     }
 }
Beispiel #15
0
        public void CancelVerify(int masterSysNo, int userSysNo)
        {
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                ShiftInfo masterInfo = Load(masterSysNo);

                //必须是已审核状态
                if (masterInfo.Status != (int)AppEnum.ShiftStatus.Verified)
                {
                    throw new BizException("status is not verified now,  cancel verify failed");
                }

                //设置 单号、状态
                Hashtable ht = new Hashtable(4);
                ht.Add("SysNo", masterInfo.SysNo);
                ht.Add("Status", (int)AppEnum.ShiftStatus.Origin);
                ht.Add("AuditTime", DateTime.Now);
                ht.Add("AuditUserSysNo", userSysNo);
                if (1 != new ShiftDac().UpdateMaster(ht))
                {
                    throw new BizException("expected one-row update failed, cancel verify failed ");
                }

                //设置RMA单件的状态
                Hashtable Registerht = new Hashtable();
                Registerht.Add("ShiftSysNo", masterSysNo);
                DataSet ds = GetRMARegisterByShiftSysNo(Registerht);
                if (Util.HasMoreRow(ds))
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        string sql = @"update RMA_Register set ShiftStatus=" + (int)AppEnum.ShiftStatus.Origin + "where sysno=" + Util.TrimIntNull(dr["registersysno"]);
                        SqlHelper.ExecuteNonQuery(sql);
                    }
                }
                scope.Complete();
            }
        }
Beispiel #16
0
        public void DeleteItem(ShiftInfo masterInfo, int itemProductSysNo)
        {
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                //必须是初始
                if (getCurrentStatus(masterInfo.SysNo) != (int)AppEnum.ShiftStatus.Origin)
                {
                    throw new BizException("status is not origin now,  delete item failed");
                }

                //获取数量差值
                ShiftItemInfo oldItemInfo = masterInfo.itemHash[itemProductSysNo] as ShiftItemInfo;
                int           deltQty     = -1 * oldItemInfo.ShiftQty;

                //更新item
                if (1 != new ShiftDac().DeleteItem(oldItemInfo.SysNo))
                {
                    throw new BizException("expected one-row update failed, delete item qty failed");
                }

                //更新库存
                InventoryManager.GetInstance().SetAvailableQty(masterInfo.StockSysNoA, itemProductSysNo, deltQty);

                //更新 masterInfo
                masterInfo.itemHash.Remove(itemProductSysNo);

                //更新RMA移库信息信息
                Hashtable ht = new Hashtable();
                ht.Add("ShiftSysNo", masterInfo.SysNo);
                ht.Add("RevertProductSysNo", itemProductSysNo);
                DataSet ds = GetRMARegisterByShiftSysNo(ht);
                if (Util.HasMoreRow(ds))
                {
                    RMARegisterManager.GetInstance().DeleteRegisterShift(ds);
                }
                scope.Complete();
            }
        }
        private void LoadingRegister_Load(object sender, EventArgs e)
        {
            SetComponentsByPermisions();

            this.siShift             = new ShiftInfo(this.cnConnection, this.setSetings.stProductionFurnaceShifttypePty, this.setSetings.dtProductionFurnaceDateOrginPty);
            this.intScaleWeight      = 0;
            this.tmrLoadingDuration  = new Timer();
            this.tmrbutRegisterDelay = new Timer();

            //SetSerialPort();

            this.LodLast = Loading.GetLastLoadingFromDB(this.cnConnection);

            //MessageBox.Show(Loading.CurrentLoaingFromToXML(this.strCurrentLoadingFilePath, "IsLoading", "", false).ToString());
            //MessageBox.Show(Loading.NextLoaingFromToXML(this.strNextLoadingFilePath, "IsLoading", "", false).ToString());
            //Postion 1: Current and Next Loading arent in Loading.
            if (!(Boolean)Loading.CurrentLoaingFromToXML(this.strCurrentLoadingFilePath, "IsLoading", "", false) &&
                !(Boolean)Loading.NextLoaingFromToXML(this.strNextLoadingFilePath, "IsLoading", "", false))
            {
                this.LodCurrent = new Loading();
                this.LodNext    = new Loading();
                this.LodCurrent.intLoadingCountPty = this.LodLast.NextLoadingCount(this.siShift.GetDate(DateTime.Now));
                Loading.CurrentLoaingFromToXML(this.strCurrentLoadingFilePath, "Intialization", "", true);
                Loading.NextLoaingFromToXML(this.strNextLoadingFilePath, "Intialization", "", true);
            }
            //Postion 2: Current is in Loading and Next Loading isnt.
            if ((Boolean)Loading.CurrentLoaingFromToXML(this.strCurrentLoadingFilePath, "IsLoading", "", false) &&
                !(Boolean)Loading.NextLoaingFromToXML(this.strNextLoadingFilePath, "IsLoading", "", false))
            {
                this.LodCurrent = (Loading)Loading.CurrentLoaingFromToXML(this.strCurrentLoadingFilePath, "Loading", "", false);
                this.LodNext    = new Loading();
            }
            //Postion 3: Current isnt in Loading and Next Loading is.
            if (!(Boolean)Loading.CurrentLoaingFromToXML(this.strCurrentLoadingFilePath, "IsLoading", "", false) &&
                (Boolean)Loading.NextLoaingFromToXML(this.strNextLoadingFilePath, "IsLoading", "", false))
            {
                this.LodCurrent = new Loading();
                this.LodNext    = (Loading)Loading.NextLoaingFromToXML(this.strNextLoadingFilePath, "Loading", "", false);
            }

            SetFormComponents();
        }
 public override void InitControl(bool showSplash)
 {
     if (showSplash)
     {
         FormProgress.ShowProgress("Loading data...", () =>
         {
             ShiftInfo.LoadContentData();
             BeginInvoke(new MethodInvoker(() =>
             {
                 Application.DoEvents();
                 InitControlInner();
             }));
         }, false);
     }
     else
     {
         ShiftInfo.LoadContentData();
         InitControlInner();
     }
 }
Beispiel #19
0
        /// <summary>
        /// 班次报表统计查询
        /// </summary>
        /// <param name="loggingSessionInfo">登录model</param>
        /// <param name="unit_ids">组织集合(不同的门店标识,请用逗号分隔:"id1,id2")[必须]</param>
        /// <param name="user_names">销售人员集合(同门店一样,用逗号分隔,请注意,这里是用户名集合,不是用户标识集合)</param>
        /// <param name="order_date_begin">单据日期开始[必须]</param>
        /// <param name="order_date_end">单据日期结束[必须]</param>
        /// <param name="maxRowCount">每页数量[必须]</param>
        /// <param name="startRowIndex">开始行号[必须]</param>
        /// <returns></returns>
        public ShiftInfo SearchShiftReport(LoggingSessionInfo loggingSessionInfo
                                           , string unit_ids
                                           , string user_names
                                           , string order_date_begin
                                           , string order_date_end
                                           , int maxRowCount
                                           , int startRowIndex
                                           )
        {
            try
            {
                ShiftInfo shiftInfo = new ShiftInfo();
                Hashtable _ht       = new Hashtable();
                _ht.Add("UnitIds", unit_ids);
                _ht.Add("UserNames", user_names);
                _ht.Add("order_date_begin", order_date_begin);
                _ht.Add("order_date_end", order_date_end);
                _ht.Add("StartRow", startRowIndex);
                _ht.Add("EndRow", startRowIndex + maxRowCount);

                IList <ShiftInfo> shiftReportList = new List <ShiftInfo>();
                shiftReportList = cSqlMapper.Instance().QueryForList <ShiftInfo>("Shift.SearchReport", _ht);

                ShiftInfo shiftInfo1 = (ShiftInfo)cSqlMapper.Instance().QueryForObject("Shift.SearchReportTotal", _ht);
                shiftInfo.sales_total_qty          = shiftInfo1.sales_total_qty;    //总销售笔数
                shiftInfo.sales_total_amount       = shiftInfo1.sales_total_amount; //总销售金额
                shiftInfo.sales_total_total_amount = shiftInfo1.sales_total_total_amount;
                shiftInfo.total_deposit_amount     = shiftInfo1.total_deposit_amount;
                shiftInfo.total_return_amount      = shiftInfo1.total_return_amount;
                shiftInfo.total_sale_amount        = shiftInfo1.total_sale_amount;
                shiftInfo.icount = shiftInfo1.icount; //总记录数

                shiftInfo.ShiftListInfo = shiftReportList;
                return(shiftInfo);
            }
            catch (Exception ex) {
                throw (ex);
            }
        }
Beispiel #20
0
        public void UpdateItemQty(ShiftInfo masterInfo, ShiftItemInfo itemInfo)
        {
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                //必须是初始
                if (getCurrentStatus(masterInfo.SysNo) != (int)AppEnum.ShiftStatus.Origin)
                {
                    throw new BizException("status is not origin now,  update item qty failed");
                }

                //获取数量差值
                ShiftItemInfo oldItemInfo = masterInfo.itemHash[itemInfo.ProductSysNo] as ShiftItemInfo;
                int           deltQty     = itemInfo.ShiftQty - oldItemInfo.ShiftQty;

                //更新表单明细 ( 如果增加表单明细项的属性,需要在这里处理一下)
                itemInfo.SysNo      = oldItemInfo.SysNo;
                itemInfo.ShiftSysNo = oldItemInfo.ShiftSysNo;

                if (1 != new ShiftDac().UpdateItemQty(itemInfo.SysNo, deltQty))
                {
                    throw new BizException("expected one-row update failed, update item qty failed");
                }


                //更新库存
                InventoryManager.GetInstance().SetAvailableQty(masterInfo.StockSysNoA, itemInfo.ProductSysNo, deltQty);

                //更新 itemInfo 到 masterInfo 注:数据库更新成功以后才更新类
                masterInfo.itemHash.Remove(itemInfo.ProductSysNo);
                masterInfo.itemHash.Add(itemInfo.ProductSysNo, itemInfo);

                scope.Complete();
            }
        }
Beispiel #21
0
 private void map(ShiftInfo oParam, DataRow tempdr)
 {
     oParam.SysNo             = Util.TrimIntNull(tempdr["SysNo"]);
     oParam.ShiftID           = Util.TrimNull(tempdr["ShiftID"]);
     oParam.StockSysNoA       = Util.TrimIntNull(tempdr["StockSysNoA"]);
     oParam.StockSysNoB       = Util.TrimIntNull(tempdr["StockSysNoB"]);
     oParam.CreateTime        = Util.TrimDateNull(tempdr["CreateTime"]);
     oParam.CreateUserSysNo   = Util.TrimIntNull(tempdr["CreateUserSysNo"]);
     oParam.AuditTime         = Util.TrimDateNull(tempdr["AuditTime"]);
     oParam.AuditUserSysNo    = Util.TrimIntNull(tempdr["AuditUserSysNo"]);
     oParam.OutTime           = Util.TrimDateNull(tempdr["OutTime"]);
     oParam.OutUserSysNo      = Util.TrimIntNull(tempdr["OutUserSysNo"]);
     oParam.InTime            = Util.TrimDateNull(tempdr["InTime"]);
     oParam.InUserSysNo       = Util.TrimIntNull(tempdr["InUserSysNo"]);
     oParam.CheckQtyUserSysNo = Util.TrimIntNull(tempdr["CheckQtyUserSysNo"]);
     oParam.CheckQtyTime      = Util.TrimDateNull(tempdr["CheckQtyTime"]);
     oParam.Status            = Util.TrimIntNull(tempdr["Status"]);
     oParam.Note               = Util.TrimNull(tempdr["Note"]);
     oParam.DLSysNo            = Util.TrimIntNull(tempdr["DLSysNo"]);
     oParam.SetDeliveryManTime = Util.TrimDateNull(tempdr["SetDeliveryManTime"]);
     oParam.FreightUserSysNo   = Util.TrimIntNull(tempdr["FreightUserSysNo"]);
     oParam.IsLarge            = Util.TrimIntNull(tempdr["IsLarge"]);
 }
Beispiel #22
0
        public ShiftInfo Load(int shiftSysNo)
        {
            ShiftInfo masterInfo;

            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                string  masterSql = "select * from st_shift where sysno = " + shiftSysNo;
                DataSet masterDs  = SqlHelper.ExecuteDataSet(masterSql);
                if (!Util.HasMoreRow(masterDs))
                {
                    throw new BizException("there is no this shift sysno");
                }

                masterInfo = new ShiftInfo();
                map(masterInfo, masterDs.Tables[0].Rows[0]);

                string  itemSql = "select * from st_shift_item where shiftsysno=" + shiftSysNo;
                DataSet itemDs  = SqlHelper.ExecuteDataSet(itemSql);
                if (Util.HasMoreRow(itemDs))
                {
                    foreach (DataRow dr in itemDs.Tables[0].Rows)
                    {
                        ShiftItemInfo item = new ShiftItemInfo();
                        map(item, dr);
                        masterInfo.itemHash.Add(item.ProductSysNo, item);
                    }
                }
                scope.Complete();
            }

            return(masterInfo);
        }
Beispiel #23
0
        public void InsertItem(ShiftInfo masterInfo, ShiftItemInfo itemInfo)
        {
            if (masterInfo.itemHash.ContainsKey(itemInfo.ProductSysNo))
            {
                throw new BizException("item duplicated!");
            }

            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                //必须是初始
                if (getCurrentStatus(masterInfo.SysNo) != (int)AppEnum.ShiftStatus.Origin)
                {
                    throw new BizException("status is not origin now,  add item failed");
                }

                //获取数量差值

                //更新item
                if (1 != new ShiftDac().InsertItem(itemInfo))
                {
                    throw new BizException("expected one-row update failed, add item failed");
                }

                //更新库存
                InventoryManager.GetInstance().SetAvailableQty(masterInfo.StockSysNoA, itemInfo.ProductSysNo, itemInfo.ShiftQty);

                //更新 itemInfo 到 masterInfo
                masterInfo.itemHash.Add(itemInfo.ProductSysNo, itemInfo);

                scope.Complete();
            }
        }
Beispiel #24
0
 public void AddShift(ShiftInfo si)
 {
     shifts.Add(si);
 }
Beispiel #25
0
        public int InsertMaster(ShiftInfo oParam)
        {
            string sql = @"INSERT INTO St_Shift
                            (
                            SysNo, ShiftID, StockSysNoA, StockSysNoB, 
                            CreateTime, CreateUserSysNo, AuditTime, AuditUserSysNo, 
                            OutTime, OutUserSysNo, InTime, InUserSysNo, 
                            Status, Note
                            )
                            VALUES (
                            @SysNo, @ShiftID, @StockSysNoA, @StockSysNoB, 
                            @CreateTime, @CreateUserSysNo, @AuditTime, @AuditUserSysNo, 
                            @OutTime, @OutUserSysNo, @InTime, @InUserSysNo, 
                            @Status, @Note
                            )";

            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo           = new SqlParameter("@SysNo", SqlDbType.Int, 4);
            SqlParameter paramShiftID         = new SqlParameter("@ShiftID", SqlDbType.NVarChar, 20);
            SqlParameter paramStockSysNoA     = new SqlParameter("@StockSysNoA", SqlDbType.Int, 4);
            SqlParameter paramStockSysNoB     = new SqlParameter("@StockSysNoB", SqlDbType.Int, 4);
            SqlParameter paramCreateTime      = new SqlParameter("@CreateTime", SqlDbType.DateTime);
            SqlParameter paramCreateUserSysNo = new SqlParameter("@CreateUserSysNo", SqlDbType.Int, 4);
            SqlParameter paramAuditTime       = new SqlParameter("@AuditTime", SqlDbType.DateTime);
            SqlParameter paramAuditUserSysNo  = new SqlParameter("@AuditUserSysNo", SqlDbType.Int, 4);
            SqlParameter paramOutTime         = new SqlParameter("@OutTime", SqlDbType.DateTime);
            SqlParameter paramOutUserSysNo    = new SqlParameter("@OutUserSysNo", SqlDbType.Int, 4);
            SqlParameter paramInTime          = new SqlParameter("@InTime", SqlDbType.DateTime);
            SqlParameter paramInUserSysNo     = new SqlParameter("@InUserSysNo", SqlDbType.Int, 4);
            SqlParameter paramStatus          = new SqlParameter("@Status", SqlDbType.Int, 4);
            SqlParameter paramNote            = new SqlParameter("@Note", SqlDbType.NVarChar, 200);

            if (oParam.SysNo != AppConst.IntNull)
            {
                paramSysNo.Value = oParam.SysNo;
            }
            else
            {
                paramSysNo.Value = System.DBNull.Value;
            }
            if (oParam.ShiftID != AppConst.StringNull)
            {
                paramShiftID.Value = oParam.ShiftID;
            }
            else
            {
                paramShiftID.Value = System.DBNull.Value;
            }
            if (oParam.StockSysNoA != AppConst.IntNull)
            {
                paramStockSysNoA.Value = oParam.StockSysNoA;
            }
            else
            {
                paramStockSysNoA.Value = System.DBNull.Value;
            }
            if (oParam.StockSysNoB != AppConst.IntNull)
            {
                paramStockSysNoB.Value = oParam.StockSysNoB;
            }
            else
            {
                paramStockSysNoB.Value = System.DBNull.Value;
            }
            if (oParam.CreateTime != AppConst.DateTimeNull)
            {
                paramCreateTime.Value = oParam.CreateTime;
            }
            else
            {
                paramCreateTime.Value = System.DBNull.Value;
            }
            if (oParam.CreateUserSysNo != AppConst.IntNull)
            {
                paramCreateUserSysNo.Value = oParam.CreateUserSysNo;
            }
            else
            {
                paramCreateUserSysNo.Value = System.DBNull.Value;
            }
            if (oParam.AuditTime != AppConst.DateTimeNull)
            {
                paramAuditTime.Value = oParam.AuditTime;
            }
            else
            {
                paramAuditTime.Value = System.DBNull.Value;
            }
            if (oParam.AuditUserSysNo != AppConst.IntNull)
            {
                paramAuditUserSysNo.Value = oParam.AuditUserSysNo;
            }
            else
            {
                paramAuditUserSysNo.Value = System.DBNull.Value;
            }
            if (oParam.OutTime != AppConst.DateTimeNull)
            {
                paramOutTime.Value = oParam.OutTime;
            }
            else
            {
                paramOutTime.Value = System.DBNull.Value;
            }
            if (oParam.OutUserSysNo != AppConst.IntNull)
            {
                paramOutUserSysNo.Value = oParam.OutUserSysNo;
            }
            else
            {
                paramOutUserSysNo.Value = System.DBNull.Value;
            }
            if (oParam.InTime != AppConst.DateTimeNull)
            {
                paramInTime.Value = oParam.InTime;
            }
            else
            {
                paramInTime.Value = System.DBNull.Value;
            }
            if (oParam.InUserSysNo != AppConst.IntNull)
            {
                paramInUserSysNo.Value = oParam.InUserSysNo;
            }
            else
            {
                paramInUserSysNo.Value = System.DBNull.Value;
            }
            if (oParam.Status != AppConst.IntNull)
            {
                paramStatus.Value = oParam.Status;
            }
            else
            {
                paramStatus.Value = System.DBNull.Value;
            }
            if (oParam.Note != AppConst.StringNull)
            {
                paramNote.Value = oParam.Note;
            }
            else
            {
                paramNote.Value = System.DBNull.Value;
            }

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramShiftID);
            cmd.Parameters.Add(paramStockSysNoA);
            cmd.Parameters.Add(paramStockSysNoB);
            cmd.Parameters.Add(paramCreateTime);
            cmd.Parameters.Add(paramCreateUserSysNo);
            cmd.Parameters.Add(paramAuditTime);
            cmd.Parameters.Add(paramAuditUserSysNo);
            cmd.Parameters.Add(paramOutTime);
            cmd.Parameters.Add(paramOutUserSysNo);
            cmd.Parameters.Add(paramInTime);
            cmd.Parameters.Add(paramInUserSysNo);
            cmd.Parameters.Add(paramStatus);
            cmd.Parameters.Add(paramNote);

            return(SqlHelper.ExecuteNonQuery(cmd));
        }
 public override void Release()
 {
     ShiftInfo.ReleaseContentData();
 }
Beispiel #27
0
        /// <summary>
        /// Perform a double QR step involving rows l:idx and columns m:n
        /// </summary>
        /// <param name="il">the index of the small sub-diagonal element</param>
        /// <param name="im">the start index for the QR step</param>
        /// <param name="iu">the current eigenvalue index</param>
        /// <param name="shift">shift information holder</param>
        /// <param name="hVec">the initial houseHolder vector</param>
        private void performDoubleQRStep(int il, int im, int iu, ShiftInfo shift, double[] hVec)
        {
            int    n = matrixT.Length;
            double p = hVec[0];
            double q = hVec[1];
            double r = hVec[2];

            for (int k = im; k <= iu - 1; k++)
            {
                Boolean notlast = k != (iu - 1);
                if (k != im)
                {
                    p       = matrixT[k][k - 1];
                    q       = matrixT[k + 1][k - 1];
                    r       = notlast ? matrixT[k + 2][k - 1] : 0.0;
                    shift.x = FastMath.abs(p) + FastMath.abs(q) + FastMath.abs(r);
                    if (Precision.equals(shift.x, 0.0, epsilon))
                    {
                        continue;
                    }
                    p /= shift.x;
                    q /= shift.x;
                    r /= shift.x;
                }
                double s = FastMath.sqrt(p * p + q * q + r * r);
                if (p < 0.0)
                {
                    s = -s;
                }
                if (s != 0.0)
                {
                    if (k != im)
                    {
                        matrixT[k][k - 1] = -s * shift.x;
                    }
                    else if (il != im)
                    {
                        matrixT[k][k - 1] = -matrixT[k][k - 1];
                    }
                    p      += s;
                    shift.x = p / s;
                    shift.y = q / s;
                    double z = r / s;
                    q /= p;
                    r /= p;

                    // Row modification
                    for (int j = k; j < n; j++)
                    {
                        p = matrixT[k][j] + q * matrixT[k + 1][j];
                        if (notlast)
                        {
                            p += r * matrixT[k + 2][j];
                            matrixT[k + 2][j] -= p * z;
                        }
                        matrixT[k][j]     -= p * shift.x;
                        matrixT[k + 1][j] -= p * shift.y;
                    }

                    // Column modification
                    for (int i = 0; i <= FastMath.min(iu, k + 3); i++)
                    {
                        p = shift.x * matrixT[i][k] + shift.y * matrixT[i][k + 1];
                        if (notlast)
                        {
                            p += z * matrixT[i][k + 2];
                            matrixT[i][k + 2] -= p * r;
                        }
                        matrixT[i][k]     -= p;
                        matrixT[i][k + 1] -= p * q;
                    }

                    // Accumulate transformations
                    int high = matrixT.Length - 1;
                    for (int i = 0; i <= high; i++)
                    {
                        p = shift.x * matrixP[i][k] + shift.y * matrixP[i][k + 1];
                        if (notlast)
                        {
                            p += z * matrixP[i][k + 2];
                            matrixP[i][k + 2] -= p * r;
                        }
                        matrixP[i][k]     -= p;
                        matrixP[i][k + 1] -= p * q;
                    }
                } // (s != 0)
            }     // k loop

            // clean up pollution due to round-off errors
            for (int i = im + 2; i <= iu; i++)
            {
                matrixT[i][i - 2] = 0.0;
                if (i > im + 2)
                {
                    matrixT[i][i - 3] = 0.0;
                }
            }
        }
Beispiel #28
0
        // == == == == == Puzzle 2 == == == == ==
        public static int Puzzle2(string input)
        {
            // CopyPaste from Puzzle 1
            var records = new List <Record>();

            // Parse input
            foreach (var rawRecord in Common.ParseStringArray(input))
            {
                var record = new Record(rawRecord);
                records.Add(record);
            }
            records.Sort((x, y) => x.Time.CompareTo(y.Time));
            // Create ShiftInfos
            var        guardStats = new Dictionary <int, GuardStats>();
            GuardStats gs;
            ShiftInfo  si = null;

            foreach (var record in records)
            {
                // Shift Start
                if (record.Type == Record.RecordType.ShiftStart)
                {
                    // Next guard
                    si = new ShiftInfo(record);
                    if (guardStats.TryGetValue(record.ID, out gs))
                    {
                        gs.AddShift(si);
                    }
                    else
                    {
                        gs    = new GuardStats();
                        gs.ID = si.ID;
                        gs.AddShift(si);
                        guardStats.Add(gs.ID, gs);
                    }
                }
                // FallAsleep / WakeUp
                else
                {
                    si.AddRecord(record);
                }
            }

            // Puzzle 2 modifications
            int asleepTimesMax = 0, asleepMinuteMax = 0, asleepIDMax = 0;   // Max values
            int asleepTimes, asleepMinute;

            foreach (var guard in guardStats)
            {
                // Need to get this value to populate array on Shift objects
                // Should be rewritten to calculate all stats on GuardStats class, then access as variables
                var noNeed = guard.Value.MinutesAsleep;

                asleepMinute = guard.Value.FindSleepiestMinute(out asleepTimes);
                if (asleepTimes > asleepTimesMax)
                {
                    asleepTimesMax  = asleepTimes;
                    asleepMinuteMax = asleepMinute;
                    asleepIDMax     = guard.Value.ID;
                }
            }
            return(asleepMinuteMax * asleepIDMax);
        }
Beispiel #29
0
        /// <summary>
        /// Transform original matrix to Schur form.
        /// </summary>
        /// <exception cref="MaxCountExceededException"> if the transformation does not converge
        /// </exception>
        private void transform()
        {
            int n = matrixT.Length;

            // compute matrix norm
            double norm = getNorm();

            // shift information
            ShiftInfo shift = new ShiftInfo();

            // Outer loop over eigenvalue index
            int iteration = 0;
            int iu        = n - 1;

            while (iu >= 0)
            {
                // Look for single small sub-diagonal element
                int il = findSmallSubDiagonalElement(iu, norm);

                // Check for convergence
                if (il == iu)
                {
                    // One root found
                    matrixT[iu][iu] += shift.exShift;
                    iu--;
                    iteration = 0;
                }
                else if (il == iu - 1)
                {
                    // Two roots found
                    double p = (matrixT[iu - 1][iu - 1] - matrixT[iu][iu]) / 2.0;
                    double q = p * p + matrixT[iu][iu - 1] * matrixT[iu - 1][iu];
                    matrixT[iu][iu]         += shift.exShift;
                    matrixT[iu - 1][iu - 1] += shift.exShift;

                    if (q >= 0)
                    {
                        double z = FastMath.sqrt(FastMath.abs(q));
                        if (p >= 0)
                        {
                            z = p + z;
                        }
                        else
                        {
                            z = p - z;
                        }
                        double x = matrixT[iu][iu - 1];
                        double s = FastMath.abs(x) + FastMath.abs(z);
                        p = x / s;
                        q = z / s;
                        double r = FastMath.sqrt(p * p + q * q);
                        p /= r;
                        q /= r;

                        // Row modification
                        for (int j = iu - 1; j < n; j++)
                        {
                            z = matrixT[iu - 1][j];
                            matrixT[iu - 1][j] = q * z + p * matrixT[iu][j];
                            matrixT[iu][j]     = q * matrixT[iu][j] - p * z;
                        }

                        // Column modification
                        for (int i = 0; i <= iu; i++)
                        {
                            z = matrixT[i][iu - 1];
                            matrixT[i][iu - 1] = q * z + p * matrixT[i][iu];
                            matrixT[i][iu]     = q * matrixT[i][iu] - p * z;
                        }

                        // Accumulate transformations
                        for (int i = 0; i <= n - 1; i++)
                        {
                            z = matrixP[i][iu - 1];
                            matrixP[i][iu - 1] = q * z + p * matrixP[i][iu];
                            matrixP[i][iu]     = q * matrixP[i][iu] - p * z;
                        }
                    }
                    iu       -= 2;
                    iteration = 0;
                }
                else
                {
                    // No convergence yet
                    computeShift(il, iu, iteration, shift);

                    // stop transformation after too many iterations
                    if (++iteration > MAX_ITERATIONS)
                    {
                        throw new MaxCountExceededException <Int32>(new LocalizedFormats("CONVERGENCE_FAILED"), MAX_ITERATIONS);
                    }

                    // the initial houseHolder vector for the QR step
                    double[] hVec = new double[3];

                    int im = initQRStep(il, iu, shift, hVec);
                    performDoubleQRStep(il, im, iu, shift, hVec);
                }
            }
        }
Beispiel #30
0
        public void Import()
        {
            /* 涉及的问题
             * 1 还货记录的处理
             * 2 库存的处理
             * 3 状态的处理
             * 4 还有单据id的对应,这个要特别注意
             */
            if (!AppConfig.IsImportable)
            {
                throw new BizException("Is Importable is false");
            }

            string  sql = " select top 1 sysno from st_shift";
            DataSet ds  = SqlHelper.ExecuteDataSet(sql);

            if (Util.HasMoreRow(ds))
            {
                throw new BizException("the table shift 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))
            {
                string  sql_old = @"select 
								old.sysno, old.shiftid, stocka_con.newsysno as stocksysnoa, stockb_con.newsysno as stocksysnob,
								create_con.newsysno as createusersysno,
								audit_con.newsysno as auditusersysno,
								out_con.newsysno as outusersysno,
								in_con.newsysno as inusersysno,
								createtime, audittime,outstocktime as outtime,instocktime as intime,
								auditstatus, productstatus, note, '1' as status
							from 
								ipp2003..st_shift as old, 
								ippconvert..sys_user as create_con,
								ippconvert..sys_user as audit_con,
								ippconvert..sys_user as out_con,
								ippconvert..sys_user as in_con,
								ippconvert..stock as stocka_con,
								ippconvert..Stock as stockb_con
							where 
								old.createusersysno *= create_con.oldsysno and
								old.auditusersysno *= audit_con.oldsysno and
								old.outstockusersysno *= out_con.oldsysno and
								old.instockusersysno *= in_con.oldsysno and
								old.stocksysnoa = stocka_con.oldsysno and
								old.stocksysnob = stockb_con.oldsysno
								order by old.sysno"                                ;
                DataSet ds_old  = SqlHelper.ExecuteDataSet(sql_old);
                if (!Util.HasMoreRow(ds_old))
                {
                    return;
                }
                foreach (DataRow dr in ds_old.Tables[0].Rows)
                {
                    /* newStatus	aduit	product
                     * abandon		-1		n/a
                     * origin		0		n/a
                     * verified		1		n/a
                     *
                     * StillInA		n/a		0
                     * OnTheRoad	n/a		1
                     * AlreadyInB	n/a		2
                     */
                    int newStatus     = (int)AppEnum.ShiftStatus.Origin;
                    int auditStatus   = Util.TrimIntNull(dr["auditStatus"]);
                    int productStatus = Util.TrimIntNull(dr["productStatus"]);
                    if (auditStatus == -1)
                    {
                        newStatus = (int)AppEnum.ShiftStatus.Abandon;
                    }
                    if (auditStatus == 0)
                    {
                        newStatus = (int)AppEnum.ShiftStatus.Origin;
                    }
                    if (auditStatus == 0)
                    {
                        newStatus = (int)AppEnum.ShiftStatus.Verified;
                    }
                    if (productStatus == 1)
                    {
                        newStatus = (int)AppEnum.ShiftStatus.OutStock;
                    }
                    if (productStatus == 2)
                    {
                        newStatus = (int)AppEnum.ShiftStatus.InStock;
                    }


                    ShiftInfo oInfo = new ShiftInfo();
                    map(oInfo, dr);
                    oInfo.Status = newStatus;

                    if (new ShiftDac().InsertMaster(oInfo) != 1)
                    {
                        throw new BizException("master expected one row error");
                    }

                    //insert item
                    string sql_item = @"select '0' as sysno,
										ShiftSysNo, con_product.newsysno as productsysno, shiftqty
									from 
										ipp2003..St_Shift_Item si, ippconvert..productbasic as con_product
									where si.productsysno = con_product.oldsysno and ShiftSysNo="                                     + oInfo.SysNo;

                    DataSet ds_item = SqlHelper.ExecuteDataSet(sql_item);
                    if (!Util.HasMoreRow(ds_item))
                    {
                        continue;
                    }
                    foreach (DataRow drItem in ds_item.Tables[0].Rows)
                    {
                        ShiftItemInfo oItem = new ShiftItemInfo();
                        map(oItem, drItem);

                        int resultitem = new ShiftDac().InsertItem(oItem);
                        if (resultitem < 1)
                        {
                            throw new BizException("insert item row < 1");
                        }

                        //调整库存
                        if (oInfo.Status == (int)AppEnum.ShiftStatus.Origin || oInfo.Status == (int)AppEnum.ShiftStatus.Verified)
                        {
                            InventoryManager.GetInstance().SetAvailableQty(oInfo.StockSysNoA, oItem.ProductSysNo, oItem.ShiftQty);
                        }
                    }
                }

                string  sqlMaxSysNo = "select top 1 sysno from ipp2003..st_shift order by sysno desc";
                DataSet dsMax       = SqlHelper.ExecuteDataSet(sqlMaxSysNo);
                if (!Util.HasMoreRow(dsMax))
                {
                    throw new BizException("got max sysno error");
                }
                int maxSysNo = Util.TrimIntNull(dsMax.Tables[0].Rows[0]["sysno"]);
                // 将自动生成的sysno填到目前的最大单据号
                int newSysNo;
                do
                {
                    newSysNo = SequenceDac.GetInstance().Create("St_Shift_Sequence");
                } while (newSysNo < maxSysNo);


                scope.Complete();
            }
        }