Esempio n. 1
0
        /* tntung
         * 30/07/2007
         */
        public TransHis SaveTranHis(Iteminstance ItemIns, DateTime txtime, ItemStatus TransType, int cusPayType, decimal ActualCost, string Modifiefby, string OlderEngine,string from, string to)
        {
            TransHis tshx = new TransHis();

            tshx.Actualcost = ActualCost;
            tshx.Referenceorderid = 0;
            tshx.Frombranch = from;
            tshx.Tobranch = to;
            tshx.Modifieddate = DateTime.Now;
            tshx.Iteminstance = ItemIns;
            tshx.Transactiondate = txtime;
            tshx.Transactiontype = (int)TransType;
            tshx.Modifiedby = Modifiefby;
            tshx.Oldengineno = (OlderEngine == null) ? null : OlderEngine;
            return tshx;
        }
Esempio n. 2
0
    private bool SaveReturnFinish(string engineNumber, string branchCode)
    {
        using (TransactionBlock trans = new TransactionBlock())
        {
            IDao<Iteminstance, long> iisDao = DaoFactory.GetDao<Iteminstance, long>();
            IDao<Returnitem, long> riDao = DaoFactory.GetDao<Returnitem, long>();
            IDao<TransHis, long> trhDao = DaoFactory.GetDao<TransHis, long>();
            IList lst;
            try
            {
                // iteminstance record
                iisDao.SetCriteria(new ICriterion[] { Expression.Eq("Enginenumber", engineNumber.ToUpper()) });
                lst = iisDao.GetAll();
                if (lst.Count <= 0) return false;
                Iteminstance iis = (Iteminstance)lst[0];

                // check for item instock?
                if (!ItemHepler.IsInstock(iis.Status))
                {
                    AddError(ReturnItemErrorCode.ItemHasOutOfStock);
                    return false;
                }

                //
                iis.Status = (int)ItemStatus.Return;
                //iis.Releaseddate = DateTime.Now;

                // returnItem record
                riDao.SetCriteria(new ICriterion[] { Expression.Eq("Iteminstance.Id", iis.Id), Expression.Eq("Status", (int)ReturnItemStatus.Allowed), Expression.Eq("Dealercode", UserHelper.DealerCode), Expression.Eq("Branchcode", UserHelper.BranchCode) });
                lst = riDao.GetAll();
                if (lst.Count <= 0) return false;
                Returnitem ri = (Returnitem)lst[0];
                ri.Status = (int)ReturnItemStatus.Returned;
                ri.Confirmdate = DateTime.Now;
                if (ri.Vmepcomment == null) ri.Vmepcomment = "";
                if (ri.Returnnumber == null) ri.Returnnumber = "";

                if (InventoryHelper.IsInventoryLock(ri.Releasedate, UserHelper.DealerCode, UserHelper.BranchCode))
                {
                    //AddError(string.Format(ReturnItemErrorCode.InventoryLocked,lockdate.Month + "/" + lockdate.Year));
                    AddError(ReturnItemErrorCode.InventoryLocked);
                    return false;
                }

                iis.Releaseddate = ri.Releasedate;

                // tranHistory record
                TransHis trh = new TransHis();
                trh.Actualcost = 0;
                trh.Frombranch = branchCode;
                trh.Modifieddate = DateTime.Now;
                trh.Iteminstance = iis;
                trh.Transactiondate = ri.Releasedate;
                trh.Transactiontype = (int)ItemStatus.Return;
                trh.Modifiedby = UserHelper.Username;

                // daily tracking
                InventoryHelper.SaveInventoryDay(iis.Item.Id, ri.Releasedate, -1, (int)ItemStatus.Return, UserHelper.DealerCode, branchCode);

                // save data
                iisDao.SaveOrUpdate(iis);
                riDao.SaveOrUpdate(ri);
                trhDao.Save(trh);

                trans.IsValid = true;
                return true;
            }
            catch { trans.IsValid = false; return false; }
        }
    }
Esempio n. 3
0
 public static TransHis SaveTransHist(Iteminstance IInst, DateTime tranDate, ItemStatus status, long ActualCost, string dCode, string bCode)
 {
     IDao<TransHis, long> dao = DaoFactory.GetDao<TransHis, long>();
     TransHis transHis = new TransHis();
     transHis.Actualcost = ActualCost;
     transHis.Frombranch = "";
     transHis.Tobranch = string.Format("{0}-{1}", dCode, bCode);
     transHis.Modifieddate = DateTime.Now;
     transHis.Iteminstance = IInst;
     transHis.Transactiondate = tranDate;
     transHis.Transactiontype = (int)status;
     transHis.Modifiedby = UserHelper.Username;
     try
     {
         return dao.Save(transHis);
     }
     catch { return null; }
 }
Esempio n. 4
0
        public static AdjustmentErrorCode UpdateVerhicle(string enginNumber, DateTime moveDate, string from, string to, string dealerCode, string dbCode, bool voucher, AdjustmentTask task)
        {
            using (TransactionBlock trs = new TransactionBlock())
            {
                Shippingdetail shd;
                AdjustmentErrorCode error = GetItemInfos(enginNumber, dealerCode, dbCode, out shd);
                if (error != AdjustmentErrorCode.OK) return error;

                // change item status
                IDao<Iteminstance, long> dao = DaoFactory.GetDao<Iteminstance, long>();
                IDao<Shippingdetail, long> sdao = DaoFactory.GetDao<Shippingdetail, long>();
                Iteminstance item = dao.GetById(shd.PRODUCTINSTANCE.Id, false); //true -> false
                if (item == null) return AdjustmentErrorCode.InvalidEngineNumber;
                switch (task)
                {
                    case AdjustmentTask.Move:
                        //item.Status = (int)ItemStatus.Moved;
                        item.Branchcode = to;
                        break;
                    case AdjustmentTask.CheckLacked: item.Status = (int)ItemStatus.Lacked; item.Releaseddate = moveDate; break;
                    case AdjustmentTask.CheckRedundant: item.Status = (int)ItemStatus.Redundant; break;
                    case AdjustmentTask.AddVoucher: shd.Voucherstatus = voucher; break;
                }
                try
                {
                    switch (task)
                    {
                        case AdjustmentTask.Move:
                        case AdjustmentTask.CheckLacked:
                        case AdjustmentTask.CheckRedundant: dao.SaveOrUpdate(item); break;
                        case AdjustmentTask.AddVoucher: sdao.SaveOrUpdate(shd); break;
                    }
                }
                catch { trs.IsValid = false; return AdjustmentErrorCode.SaveDataFailed; }

                // write transHistory
                IDao<TransHis, long> trhdao = DaoFactory.GetDao<TransHis, long>();
                TransHis trans = new TransHis();
                TransHis transTo = new TransHis();
                trans.Actualcost = 0;
                if (from != null) trans.Frombranch = UserHelper.BuildFullBranch(dealerCode, from);
                if (to != null) trans.Tobranch = UserHelper.BuildFullBranch(dealerCode, to);
                trans.Transactiondate = moveDate;
                switch (task)
                {
                    case AdjustmentTask.Move:
                        trans.Transactiontype = (int)ItemStatus.Moved;
                        transTo.Actualcost = trans.Actualcost;
                        transTo.Frombranch = trans.Tobranch;
                        transTo.Tobranch = trans.Frombranch;
                        transTo.Transactiondate = trans.Transactiondate;
                        transTo.Transactiontype = (int)ItemStatus.ReceivedFromMoving;
                        transTo.Modifieddate = DateTime.Now;
                        transTo.Iteminstance = item;
                        transTo.Modifiedby = UserHelper.Username;
                        break;
                    case AdjustmentTask.CheckLacked: trans.Transactiontype = (int)ItemStatus.Lacked; break;
                    case AdjustmentTask.CheckRedundant: trans.Transactiontype = (int)ItemStatus.Redundant; break;
                    case AdjustmentTask.AddVoucher: trans.Transactiontype = (int)ItemStatus.VoucherCompensated; break;
                }
                trans.Modifieddate = DateTime.Now;
                trans.Iteminstance = item;
                trans.Modifiedby = UserHelper.Username;
                try
                {
                    trhdao.SaveOrUpdate(trans);
                    if (task == AdjustmentTask.Move)
                        trhdao.SaveOrUpdate(transTo);
                }
                catch { trs.IsValid = false; return AdjustmentErrorCode.SaveDataFailed; }

                // save xxx info
                Inventoryday invDay;
                try
                {
                    switch (task)
                    {
                        case AdjustmentTask.Move:
                            invDay = InventoryHelper.SaveInventoryDay(item.Item.Id, moveDate, -1, (int)ItemStatus.Moved, dealerCode, from);
                            if (invDay == null) { trs.IsValid = false; return AdjustmentErrorCode.SaveDataFailed; }
                            invDay = InventoryHelper.SaveInventoryDay(item.Item.Id, moveDate, 1, (int)ItemStatus.Moved, dealerCode, to);
                            if (invDay == null) { trs.IsValid = false; return AdjustmentErrorCode.SaveDataFailed; }
                            break;
                        case AdjustmentTask.CheckLacked:
                            invDay = InventoryHelper.SaveInventoryDay(item.Item.Id, moveDate, -1, (int)ItemStatus.Lacked, dealerCode, item.Branchcode);
                            if (invDay == null) { trs.IsValid = false; return AdjustmentErrorCode.SaveDataFailed; }
                            break;
                        case AdjustmentTask.CheckRedundant:
                            //invDay = InventoryHelper.SaveInventoryDay(item.Item.Id, moveDate, 1, (int)ItemStatus.Redundant, dealerCode, item.Branchcode);
                            //if (invDay == null) { trs.IsValid = false; return AdjustmentErrorCode.SaveDataFailed; }
                            break;
                    }
                }
                catch { trs.IsValid = false; return AdjustmentErrorCode.SaveDataFailed; }

                // after all
                trs.IsValid = true;
            }
            return AdjustmentErrorCode.OK;
        }