public static void SaveTransHis(VehicleDataContext dc, ItemInstance ItemIns, DateTime txtime, ItemStatus TransType, int cusPayType, decimal ActualCost, string Modifiefby, string OlderEngine,string from, string to)
        {
            var th = new SaleTransHistory();

            th.ActualCost = ActualCost;
            th.ReferenceOrderId = 0;
            th.FromBranch = from;
            th.ToBranch = to;
            th.ModifiedDate = DateTime.Now;
            th.ItemInstance = ItemIns;
            th.TransactionDate = txtime;
            th.TransactionType = (int)TransType;
            th.ModifiedBy = Modifiefby;
            th.OldEngineNo = (OlderEngine == null) ? null : OlderEngine;

            dc.SaleTransHistories.InsertOnSubmit(th);
        }
 public static Entity.SaleTransHistory SaveTransHist(VehicleDataContext db, ItemInstance IInst, DateTime tranDate, ItemStatus status, long ActualCost, string dCode, string bCode)
 {
     var transHis = new SaleTransHistory
                        {
                            ActualCost = ActualCost,
                            FromBranch = "",
                            ToBranch = string.Format("{0}-{1}", dCode, bCode),
                            ModifiedDate = DateTime.Now,
                            ItemInstance = IInst,
                            TransactionDate = tranDate,
                            TransactionType = (int) status,
                            ModifiedBy = UserHelper.Username
                        };
     db.SaleTransHistories.InsertOnSubmit(transHis);
     return transHis;
 }
        public static ShippingDetail SaveOrUpdateShippingDetail(VehicleDataContext db,long shipId, Entity.Item item, string engineNumber, int status, bool voucher, string ex, ItemInstance itemInstance, string itemType, string color, string branchCode, string orderNumber)
        {
            //IDao<Shippingdetail, long> dao;
            //IDao<ShippingHeader, long> shdao;
            //List<Shippingdetail> list;
            ShippingDetail SD = null;

            //dao = DaoFactory.GetDao<Shippingdetail, long>();
            //dao.SetCriteria(new ICriterion[] { Expression.And(Expression.Eq("Shippingheader.Id", shipId), Expression.Eq("Enginenumber", engineNumber.Trim())) });
            //list = dao.GetAll();
            SD =
                db.ShippingDetails.FirstOrDefault(
                    p => p.ShippingId == shipId && p.EngineNumber == engineNumber.Trim());

            if (SD == null)
            {

                SD = new ShippingDetail();
                SD.ShippingId = shipId;
                SD.EngineNumber = engineNumber;
                db.ShippingDetails.InsertOnSubmit(SD);
            }

            SD.ItemType = itemType;
            SD.Color = color;
            SD.Item = item;
            SD.BranchCode = branchCode;
            SD.OrderNumber = orderNumber;
            SD.Status = status;
            SD.VoucherStatus = voucher? 1:0;
            SD.ItemCode = item.ItemCode;
            SD.VMEPResponseDate = DateTime.MinValue;
            if (itemInstance != null) SD.ProductInstanceId = itemInstance.ItemInstanceId;
            //if (!string.IsNullOrEmpty(ex))
            SD.Exception = ex;

            return SD;
        }
        public static ItemInstance SaveOrUpdateItemInstance(VehicleDataContext db, string dealerCode, string branchCode, string engineNumber, string shipNumber, string invoice, string itemType, Entity.Item item, DateTime impDate, string color, int status, DateTime madeDate, string DatabaseCode)
        {
            var IIS = db.ItemInstances.FirstOrDefault(p => p.EngineNumber.Equals(engineNumber.Trim()));

            if (IIS == null)
            {
                IIS = new ItemInstance { CreatedDate = DateTime.Now };
                IIS.EngineNumber = engineNumber;
                db.ItemInstances.InsertOnSubmit(IIS);
            }

            // get shipping header to take some data
            //var SH = db.ShippingHeaders.FirstOrDefault(p => p.ShippingNumber == (shipNumber.Trim()));
            //if (SH == null)
            //{
            //    Exception e = new Exception("Shipping number does not exist: " + shipNumber);
            //    throw e;
            //}
            //else
            //{
                // save to database
                //IIS.Dealercode = SH.Dealercode;

                IIS.ItemType = itemType;
                IIS.ItemCode = item.ItemCode;
                IIS.ImportedDate = impDate;
                IIS.Color = color;
                IIS.Status = status;
                IIS.DealerCode = dealerCode;
                IIS.VMEPInvoice = invoice;
                IIS.DatabaseCode = DatabaseCode;
                if (madeDate > DateTime.MinValue) IIS.MadeDate = madeDate;
                IIS.BranchCode = branchCode;

                IIS.ReleasedDate = DateTime.Parse("9999/12/31");
               // }
            return IIS;
        }
        //public static List<int> GetItemStatusForSale()
        //{
        //    List<int> list = new List<int>();
        //    list.Add((int)ItemStatus.AdmitTemporarily);
        //    list.Add((int)ItemStatus.Imported);
        //    list.Add((int)ItemStatus.Moved);
        //    list.Add((int)ItemStatus.Redundant);
        //    return list;
        //}
        // select sold items and tiptop items for service
        private List<ItemInstance> SelectFromTipTop(int maximumRows, int startRowIndex, string engineNumberLike, string dealerCode, string databaseCode1, string databaseCode2)
        {
            int page = (maximumRows == 0) ? 0 : startRowIndex / maximumRows;
            string databaseCode = databaseCode1;

            // get data from tiptop
            DataSet ds = Motorbike.GetItemInfo(engineNumberLike, databaseCode, dealerCode, page, maximumRows);
            if ((ds == null) || (ds.Tables[0].Rows.Count == 0))
            {
                databaseCode = databaseCode2;
                ds = Motorbike.GetItemInfo(engineNumberLike, databaseCode, dealerCode, page, maximumRows);
            }

            // count items
            count = (int)Motorbike.GetItemInfoCount(engineNumberLike, databaseCode, dealerCode);
            HttpContext.Current.Items["listgvSelectEngineRowCount"] = count;

            // re pagging if startRow is wrong
            if (startRowIndex >= count && count > 0)
            {
                ds = Motorbike.GetItemInfo(engineNumberLike, databaseCode, dealerCode, 0, maximumRows);
            }

            // build return list
            List<ItemInstance> list = new List<ItemInstance>();
            ItemInstance item;
            var row = ds.Tables[0].Rows;
            int count_ds = row.Count - 1 ;
            while(count_ds >= 0)
            {
                var moreinfo = Motorbike.GetMoreItemInfo(row[count_ds]["EngineNo"].ToString(), row[count_ds]["DatabaseCode"].ToString());
                if (!string.IsNullOrEmpty(dealerCode))
                {
                    if (moreinfo.Tables[0].Rows[0]["DealerCode"] != dealerCode)
                    {
                        count_ds--;
                        continue;
                    }
                }
                item = new ItemInstance();
                if (moreinfo.Tables[0].Rows.Count > 0)
                {
                    item.DealerCode = moreinfo.Tables[0].Rows[0]["DealerCode"].ToString();
                    item.BranchCode = moreinfo.Tables[0].Rows[0]["DealerCode"].ToString();
                    item.MadeDate = (DateTime)moreinfo.Tables[0].Rows[0]["OutStockDate"]; ;
                    item.ImportedDate = (DateTime)moreinfo.Tables[0].Rows[0]["OutStockDate"];
                }

                item.Item = new Entity.Item();
                item.Item.ItemCode = row[count_ds]["ItemCode"].ToString();
                item.Item.DatabaseCode = databaseCode;
                item.Item.ColorCode = row[count_ds]["ColorCode"].ToString();
                item.Item.ColorName = row[count_ds]["ColorCode"].ToString();
                item.Item.ItemType = row[count_ds]["ItemCode"].ToString();

                item.ItemInstanceId = 0;
                item.DatabaseCode = row[count_ds]["DatabaseCode"].ToString();
                item.ItemType = item.Item.ItemType;
                item.Color = row[count_ds]["ColorCode"].ToString();

                item.EngineNumber = row[count_ds]["EngineNo"].ToString();
                item.ReleasedDate = DateTime.MinValue;

                list.Add(item);
                count_ds--;
            }
            return list;
        }
        public ItemInstanceEx(ItemInstance i)
        {
            this.BranchCode = i.BranchCode;
            this.Color = i.Color;
            this.Comments = i.Comments;
            this.CreatedDate = i.CreatedDate;
            this.DatabaseCode = i.DatabaseCode;
            this.DealerCode = i.DealerCode;
            this.EngineNumber = i.EngineNumber;
            this.ImportedDate = i.ImportedDate;
            //this.Item = i.Item;
            this.ItemCode = i.ItemCode;
            this.ItemInstanceId = i.ItemInstanceId;
            this.ItemType = i.ItemType;
            this.MadeDate = i.MadeDate;
            this.ReleasedDate = i.ReleasedDate;
            this.Status = i.Status;
            this.VMEPInvoice = i.VMEPInvoice;

            //var sd = i.ShippingDetails.Where(d => d.ShippingHeader.DealerCode == UserHelper.DealerCode).OrderByDescending(s => s.ShippingDetailId).FirstOrDefault();
            int voucherstatus = 1;
            var sd = CheckVoucherStatus(i.ItemInstanceId, i.DealerCode, i.BranchCode, i.EngineNumber, out voucherstatus);
            this.HasVoucher = sd ? false : 1 == voucherstatus;
            this.VoucherStatus = sd ? 0 : voucherstatus;
            //var sd = s.OrderByDescending(v => v.ShippingDetailId).FirstOrDefault();
            //this.HasVoucher = sd == null ? false : sd.VoucherStatus == 1;
            //this.VoucherStatus = sd == null ? 0 : sd.VoucherStatus;
        }
Beispiel #7
0
 public static void SetSelectEngineSession(string key, ItemInstance val)
 {
     HttpContext.Current.Session[string.Format(PopupHelper.SelectEngineSessionString, key)] = val;
 }
 private void detach_ItemInstances(ItemInstance entity)
 {
     this.SendPropertyChanging("ItemInstances");
     entity.Item = null;
 }