Example #1
0
        // method to get the Lot ID
        public string GetLotID()
        {
            string lotID = "";

            lotID = LotFloor + LotNumber.ToString();
            return(lotID);
        }
        public LotNumber GetSingle(string id, long companyId)
        {
            long      longId = Convert.ToInt64(id);
            LotNumber entity = this.Context.LotNumbers.FirstOrDefault(x => x.Id == longId && x.CompanyId == companyId);

            return(entity);
        }
        public IEnumerable <SerialNumber> GetAvailableSerials(LotNumber entity, long companyId, long sobId)
        {
            List <SerialNumber> serialExist = this.GetSerialsbyLotNo(entity.Id, companyId, sobId).ToList();

            if (serialExist != null && serialExist.Count > 0)
            {
                var availableSerials = (from a in serialExist
                                        group a by a.SerialNo into g
                                        where g.Count() % 2 != 0
                                        select new SerialNumber
                {
                    CompanyId = g.FirstOrDefault().CompanyId,
                    CreateBy = g.FirstOrDefault().CreateBy,
                    CreateDate = g.FirstOrDefault().CreateDate,
                    Id = g.FirstOrDefault().Id,
                    LotNo = g.FirstOrDefault().LotNo,
                    LotNoId = g.FirstOrDefault().LotNoId,
                    SerialNo = g.FirstOrDefault().SerialNo,
                    UpdateBy = g.FirstOrDefault().UpdateBy,
                    UpdateDate = g.FirstOrDefault().UpdateDate
                }).ToList();

                return(availableSerials);
            }
            return(new List <SerialNumber>());
        }
Example #4
0
        /// <summary>
        /// 判斷號碼是否有重覆
        /// </summary>
        /// <param name="data"></param>
        private void CheckRepeatFun(LotNumber data)
        {
            List <string> checkRepeat = new List <string> {
                data.號碼1, data.號碼2, data.號碼3, data.號碼4, data.號碼5
            };

            //List<string> RepeatData = new List<string>();
            //for (int i = 0; i < checkRepeat.Count; i++)
            //{
            //    for (int j = i + 1; j < checkRepeat.Count; j++)
            //    {
            //        if (checkRepeat[i] == checkRepeat[j])
            //        {
            //            RepeatData.Add(checkRepeat[i]);
            //        }
            //    }
            //}
            //var dd = from p in checkRepeat
            //         group p by p.ToString() into g
            //         where g.Count() > 1//出現1次以上的數字
            //         select g.Key;
            //TempData["message"] = checkRepeat.GroupBy(p=>p).Where(g=>g.Count()>1).Select(m=>m.Key);
            if (checkRepeat.GroupBy(p => p).Count() > 1)
            {
                TempData["message"] = "重覆號碼:" + checkRepeat.GroupBy(p => p).Where(g => g.Count() > 1).Select(m => m.Key);
            }
            else
            {
                TempData["message"] = "無重覆值";
            }
        }
Example #5
0
 public override int GetHashCode()
 {
     return(PersonId.GetHashCode() ^
            ConceptId.GetHashCode() ^
            TypeConceptId.GetHashCode() ^
            (SourceValue != null ? SourceValue.GetHashCode() : 0) ^
            (StopReason != null ? StopReason.GetHashCode() : 0) ^
            Refills.GetHashCode() ^
            VisitOccurrenceId.GetHashCode() ^
            Quantity.GetHashCode() ^
            DaysSupply.GetHashCode() ^
            RouteConceptId.GetHashCode() ^
            EffectiveDrugDose.GetHashCode() ^
            DoseUnitConceptId.GetHashCode() ^
            SourceConceptId.GetHashCode() ^
            (Sig != null ? Sig.GetHashCode() : 0) ^
            (LotNumber != null ? LotNumber.GetHashCode() : 0) ^
            (RouteSourceValue != null ? RouteSourceValue.GetHashCode() : 0) ^
            (DoseUnitSourceValue != null ? DoseUnitSourceValue.GetHashCode() : 0) ^
            ProviderId.GetHashCode() ^
            (StartDate.GetHashCode()) ^
            (EndDate.GetHashCode()) ^
            (VerbatimEndDate.GetHashCode()) ^
            (StartTime != null ? StartTime.GetHashCode() : 0) ^
            (EndTime != null ? EndTime.GetHashCode() : 0));
 }
Example #6
0
        private static LotNumber GetLotEntityByMiscellaneousTransaction(MiscellaneousTransactionDetailModel model, int count)
        {
            if (model == null)
            {
                return(null);
            }

            LotNumber entity = new LotNumber();

            if (count == 0)
            {
                entity.CreateBy   = AuthenticationHelper.UserId;
                entity.CreateDate = DateTime.Now;
            }
            else
            {
                entity.CreateBy   = model.CreateBy;
                entity.CreateDate = model.CreateDate;
            }

            entity.CompanyId  = AuthenticationHelper.CompanyId.Value;
            entity.Id         = model.Id;
            entity.ItemId     = model.ItemId;
            entity.LotNo      = model.LotNo;
            entity.SOBId      = SessionHelper.SOBId;
            entity.SourceId   = model.Id;
            entity.SourceType = "Miscellaneous Transaction";
            entity.UpdateBy   = AuthenticationHelper.UserId;
            entity.UpdateDate = DateTime.Now;
            return(entity);
        }
Example #7
0
        public ActionResult AddNumber()
        {
            LotNumber model = new LotNumber();

            model.開獎日期 = DateTime.Now.ToString("yyyyMMdd");
            SetMaxNo();
            return(View(model));
        }
 /// <summary>
 /// 去掉前面0
 /// </summary>
 /// <param name="data"></param>
 private void TrimStartZone(LotNumber data)
 {
     data.號碼1 = data.號碼1.TrimStart('0');
     data.號碼2 = data.號碼2.TrimStart('0');
     data.號碼3 = data.號碼3.TrimStart('0');
     data.號碼4 = data.號碼4.TrimStart('0');
     data.號碼5 = data.號碼5.TrimStart('0');
 }
        public string Update(LotNumber entity)
        {
            LotNumber originalEntity = this.Context.LotNumbers.Find(entity.Id);

            this.Context.Entry(originalEntity).CurrentValues.SetValues(entity);
            this.Context.Entry(originalEntity).State = EntityState.Modified;
            this.Commit();
            return(entity.Id.ToString());
        }
Example #10
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 6, Configuration.FieldSeparator),
                       Id,
                       DeviceNumber?.ToDelimitedString(),
                       DeviceName,
                       LotNumber?.ToDelimitedString(),
                       ItemIdentifier?.ToDelimitedString(),
                       BarCode
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
Example #11
0
        public int CompareTo(Lot lot)
        {
            var thisParts  = LotNumber.Split('-');
            var otherParts = lot.LotNumber.Split('-');

            if (thisParts.Count() < 2 || otherParts.Count() < 2)
            {
                return(LotNumber.CompareTo(lot.LotNumber));
            }

            var thisNumber  = Int32.Parse(thisParts[1]);
            var otherNumber = Int32.Parse(otherParts[1]);

            return(thisNumber.CompareTo(otherNumber));
        }
Example #12
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 8, Configuration.FieldSeparator),
                       Id,
                       LotNumber?.ToDelimitedString(),
                       DeviceNumber?.ToDelimitedString(),
                       DeviceName,
                       DeviceDataState,
                       LoadStatus,
                       ControlCode.HasValue ? ControlCode.Value.ToString(Consts.NumericFormat, culture) : null,
                       OperatorName
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
Example #13
0
        public bool UpdateCopyNumber(LotNumber data)
        {
            var sql   = @"
            DECLARE @TSQL NVARCHAR(4000)
SET @TSQL =	'update [dbo].[TwLot59_StoredCount]
set ' + @num1 + '=0,' + @num2 + '=0,' + @num3 +'=0,' + @num4 + '=0,' + @num5 + '=0
where 日期=' + @date
EXEC SP_EXECUTESQL @TSQL";
            var param = new Dictionary <string, object>();

            param.Add("num1", "[" + data.號碼1 + "]");
            param.Add("num2", "[" + data.號碼2 + "]");
            param.Add("num3", "[" + data.號碼3 + "]");
            param.Add("num4", "[" + data.號碼4 + "]");
            param.Add("num5", "[" + data.號碼5 + "]");
            param.Add("date", data.開獎日期);

            return(_dbDapper.NonQuerySQL(sql, param) > 0);
        }
Example #14
0
        public bool AddNumberServices(LotNumber data)
        {
            bool          success  = false;
            List <string> inputNum = new List <string> {
                data.號碼1, data.號碼2, data.號碼3, data.號碼4, data.號碼5
            };

            using (var scope = new TransactionScope())
            {
                success = _sqlRepository.InputLotNumber(data) &&
                          _sqlRepository.InsertCopyNumber(data.開獎日期) &&
                          _sqlRepository.UpdateCopyNumber(data);
                if (success)
                {
                    scope.Complete();
                }
            }
            return(success);
        }
Example #15
0
        public ActionResult AddNumber(LotNumber data)
        {
            SetMaxNo();
            //CheckRepeatFun(data);

            if (ModelState.IsValid)
            {
                if (_homeService.AddNumberServices(data))
                {
                    TempData["message"] = "寫入成功";
                }
                else
                {
                    TempData["message"] = "寫入失敗";
                }
                return(RedirectToAction("AddNumber"));
            }
            return(View());
        }
Example #16
0
        private static string updateLots(Shipment model)
        {
            if (model.Id > 0)
            {
                if (model.LotNoId != null && model.LotNoId > 0)
                {
                    LotNumber savedLot = LotNumberHelper.GetLotNumber(model.LotNoId.Value);
                    if (savedLot != null && savedLot.SourceId == model.Id)
                    {
                        //Lot is already saved..
                        return("");
                    }
                    else
                    {
                        savedLot = LotNumberHelper.GetLotBySourceId(model.Id);
                        if (savedLot != null)
                        {
                            LotNumberHelper.Delete(savedLot.Id.ToString());
                        }

                        savedLot.SourceId   = savedLot.Id;
                        savedLot.SourceType = "Shipment";
                        return(LotNumberHelper.SaveLot(savedLot));
                    }
                }
            }
            else
            {
                if (model.LotNoId != null && model.LotNoId > 0)
                {
                    LotNumber newLot = LotNumberHelper.GetLotNumber(model.LotNoId.Value);
                    newLot.SourceId   = 0; //Temporary..
                    newLot.SourceType = "Shipment";
                    return(LotNumberHelper.SaveLot(newLot));
                }
            }

            return("");
        }
Example #17
0
        private string deleteLot(ReceivingDetailModel model)
        {
            LotNumber        lot       = lotService.GetSingle(model.LotNoId.Value.ToString(), AuthenticationHelper.CompanyId.Value);
            List <LotNumber> savedLots = lotService.GetAllbyLotNo(AuthenticationHelper.CompanyId.Value, SessionHelper.SOBId, lot.LotNo, lot.ItemId).ToList();

            if (model.LotNoId != null)
            {
                List <SerialNumber> savedSerials = lotService.GetSerialsbyLotNo(model.LotNoId.Value, AuthenticationHelper.CompanyId.Value, SessionHelper.SOBId);
                if (savedSerials != null && savedSerials.Count() > 0)
                {
                    if (!string.IsNullOrEmpty(model.SerialNo))
                    {
                        List <string> currentSerials = model.SerialNo.Trim().Split(new char[] { ',' }).ToList();
                        if (savedSerials.Any(rec => rec.SerialNo != currentSerials.FirstOrDefault(x => x == rec.SerialNo)))
                        {
                            lot.Qty = lot.Qty - model.ThisPurchaseQty;
                            lotService.Update(lot);
                            return("");
                        }
                        else
                        {
                            lotService.Delete(model.LotNoId.Value.ToString(), AuthenticationHelper.CompanyId.Value);
                        }
                    }
                    else
                    {
                        lot.Qty = lot.Qty - model.ThisPurchaseQty;
                        lotService.Update(lot);
                        return("");
                    }
                }
                else
                {
                    lotService.Delete(model.LotNoId.Value.ToString(), AuthenticationHelper.CompanyId.Value);
                }
            }

            return("");
        }
Example #18
0
            public XElement ToQBXML(string name, BaseRef OverrideItemAccountRef = null)
            {
                XElement xElement = new XElement(name);

                xElement.Add(TxnLineID.ToQBXML(nameof(TxnLineID)));
                xElement.Add(ItemRef.ToQBXML(nameof(ItemRef)));
                xElement.Add(InventorySiteRef.ToQBXML(nameof(InventorySiteRef)));
                xElement.Add(InventorySiteLocationRef.ToQBXML(nameof(InventorySiteLocationRef)));
                xElement.Add(SerialNumber.ToQBXML(nameof(SerialNumber)));
                xElement.Add(LotNumber.ToQBXML(nameof(LotNumber)));
                xElement.Add(Desc.ToQBXML(nameof(Desc)));
                xElement.Add(UnitOfMeasure.ToQBXML(nameof(UnitOfMeasure)));
                xElement.Add(OverrideUOMSetRef.ToQBXML(nameof(OverrideUOMSetRef)));
                xElement.Add(Cost.ToQBXML(nameof(Cost)));
                xElement.Add(Amount.ToQBXML(nameof(Amount)));
                xElement.Add(CustomerRef.ToQBXML(nameof(CustomerRef)));
                xElement.Add(ClassRef.ToQBXML(nameof(ClassRef)));
                xElement.Add(BillableStatus.ToQBXML(nameof(BillableStatus)));
                xElement.Add(OverrideItemAccountRef.ToQBXML(nameof(OverrideItemAccountRef)));
                xElement.Add(SalesRepRef.ToQBXML(nameof(SalesRepRef)));
                return(xElement);
            }
Example #19
0
        public bool InputLotNumber(LotNumber data)
        {
            var sql = @"
INSERT INTO [dbo].[TwLot59]
           ([期數]
           ,[開獎日期]
           ,[號碼1]
           ,[號碼2]
           ,[號碼3]
           ,[號碼4]
           ,[號碼5])
     VALUES
           (@期數
           ,@開獎日期
           ,@號碼1
           ,@號碼2
           ,@號碼3
           ,@號碼4
           ,@號碼5)
";

            return(_dbDapper.NonQuerySQL(sql, data) > 0);
        }
Example #20
0
            public virtual XElement GenerateModRq(BaseRef OverrideItemAccountRef = null)
            {
                XElement xElement = new XElement(nameof(ItemLine) + "Mod");

                xElement.Add(TxnLineID.ToQBXML(nameof(TxnLineID)));
                xElement.Add(ItemRef.ToQBXML(nameof(ItemRef)));
                xElement.Add(InventorySiteRef.ToQBXML(nameof(InventorySiteRef)));
                xElement.Add(InventorySiteLocationRef.ToQBXML(nameof(InventorySiteLocationRef)));
                xElement.Add(SerialNumber.ToQBXML(nameof(SerialNumber)));
                xElement.Add(LotNumber.ToQBXML(nameof(LotNumber)));
                xElement.Add(Desc.ToQBXML(nameof(Desc)));
                xElement.Add(Quantity.ToQBXML(nameof(Quantity)));
                xElement.Add(UnitOfMeasure.ToQBXML(nameof(UnitOfMeasure)));
                xElement.Add(OverrideUOMSetRef.ToQBXML(nameof(OverrideUOMSetRef)));
                xElement.Add(Cost.ToQBXML(nameof(Cost)));
                xElement.Add(Amount.ToQBXML(nameof(Amount)));
                xElement.Add(CustomerRef.ToQBXML(nameof(CustomerRef)));
                xElement.Add(ClassRef.ToQBXML(nameof(ClassRef)));
                xElement.Add(BillableStatus.ToQBXML(nameof(BillableStatus)));
                xElement.Add(OverrideItemAccountRef.ToQBXML(nameof(OverrideItemAccountRef)));
                xElement.Add(SalesRepRef.ToQBXML(nameof(SalesRepRef)));
                return(xElement);
            }
Example #21
0
 public ActionResult DatepicerTest2(LotNumber data)
 {
     return(View());
 }
Example #22
0
 public IEnumerable <SerialNumber> GetAvailableSerials(LotNumber entity, long companyId, long sobId)
 {
     return(this.repository.GetAvailableSerials(entity, companyId, sobId));
 }
        public LotNumber GetLotBySourceId(long sourceId, long companyId, long sobId)
        {
            LotNumber entity = this.Context.LotNumbers.FirstOrDefault(x => x.CompanyId == companyId && x.SOBId == sobId && x.SourceId == sourceId);

            return(entity);
        }
Example #24
0
        private string save(ReceivingModel model)
        {
            Receiving entity = getEntityByModel(model);

            if (model.Id > 0)
            {
                List <ReceivingDetailModel> receivingDetail = service.GetAllReceivingDetail(model.Id).Select(rec => new ReceivingDetailModel(rec, true)).ToList();
                if (receivingDetail != null && receivingDetail.Count() > 0)
                {
                    foreach (var item in receivingDetail)
                    {
                        if (!model.ReceivingDetail.Any(rec => rec.PODetailId == item.PODetailId))
                        {
                            string serialResult = deleteSerials(item);
                            if (string.IsNullOrEmpty(serialResult))
                            {
                                service.DeleteReceivingDetail(item.Id);
                                deleteLot(item);
                            }
                            else
                            {
                                return(serialResult);
                            }
                        }
                    }
                }
            }

            List <ReceivingDetailModel> tobeUpdatedDetail = model.ReceivingDetail.Where(rec => rec.LocatorId > 0 && rec.WarehouseId > 0).ToList();

            string result = string.Empty;

            if (entity.IsValid())
            {
                bool goodToSave = false;
                foreach (var item in tobeUpdatedDetail)
                {
                    ReceivingDetailModel updatedModel = item;
                    string lotResult = updateLot(updatedModel);
                    int    outVal;
                    bool   isNumeric = int.TryParse(lotResult, out outVal);
                    if (isNumeric || string.IsNullOrEmpty(lotResult))
                    {
                        item.LotNoId = isNumeric ? (long?)Convert.ToInt64(lotResult) : null;
                        string serialResult = updateSerials(updatedModel);
                        if (string.IsNullOrEmpty(serialResult))
                        {
                            goodToSave = true;
                        }
                        else
                        {
                            if (item.LotNoId != null)
                            {
                                LotNumber lot = lotService.GetSingle(item.LotNoId.Value.ToString(), AuthenticationHelper.CompanyId.Value);
                                lot.Qty = lot.Qty - item.ThisPurchaseQty;
                                lotService.Update(lot);
                            }
                            return(serialResult);
                        }
                    }
                    else
                    {
                        return(lotResult);
                    }
                }
                if (goodToSave)
                {
                    if (model.Id > 0)
                    {
                        result = service.Update(entity);
                    }
                    else
                    {
                        result = service.Insert(entity);
                    }

                    if (!string.IsNullOrEmpty(result))
                    {
                        var savedLines = getReceivingDetail(result);
                        if (savedLines.Count() > tobeUpdatedDetail.Count())
                        {
                            var tobeDeleted = savedLines.Take(savedLines.Count() - tobeUpdatedDetail.Count());
                            foreach (var item in tobeDeleted)
                            {
                                string serialResult = deleteSerials(item);
                                if (string.IsNullOrEmpty(serialResult))
                                {
                                    string lotResult = deleteLot(item);
                                    if (string.IsNullOrEmpty(lotResult))
                                    {
                                        service.DeleteReceivingDetail(item.Id);
                                    }
                                    else
                                    {
                                        return("Record can not be deleted");
                                    }
                                }
                                else
                                {
                                    return("Record can not be deleted");
                                }
                            }
                            savedLines = getReceivingDetail(result);
                        }

                        foreach (var detail in tobeUpdatedDetail)
                        {
                            ReceivingDetail detailEntity = getEntityByModel(detail);
                            if (detailEntity.IsValid())
                            {
                                detailEntity.ReceiptId = Convert.ToInt64(result);
                                if (savedLines.Count() > 0)
                                {
                                    detailEntity.Id = savedLines.FirstOrDefault().Id;
                                    savedLines.Remove(savedLines.FirstOrDefault(rec => rec.Id == detailEntity.Id));

                                    string receivingDetailId = service.Update(detailEntity);

                                    if (detailEntity.LotNoId != null)
                                    {
                                        LotNumber lottobeUpdated = lotService.GetSingle(detailEntity.LotNoId.ToString(), AuthenticationHelper.CompanyId.Value);
                                        lottobeUpdated.SourceId = Convert.ToInt64(receivingDetailId);
                                        lotService.Update(lottobeUpdated);
                                    }
                                }
                                else
                                {
                                    string receivingDetailId = service.Insert(detailEntity);

                                    if (detailEntity.LotNoId != null)
                                    {
                                        LotNumber lottobeUpdated = lotService.GetSingle(detailEntity.LotNoId.ToString(), AuthenticationHelper.CompanyId.Value);
                                        lottobeUpdated.SourceId = Convert.ToInt64(receivingDetailId);
                                        lotService.Update(lottobeUpdated);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return("");
        }
 public string Insert(LotNumber entity)
 {
     this.Context.LotNumbers.Add(entity);
     this.Commit();
     return(entity.Id.ToString());
 }
Example #26
0
        /// <summary>
        /// Returns true if CommonPAFAddress instances are equal
        /// </summary>
        /// <param name="other">Instance of CommonPAFAddress to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(CommonPAFAddress other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Dpid == other.Dpid ||
                     Dpid != null &&
                     Dpid.Equals(other.Dpid)
                     ) &&
                 (
                     ThoroughfareNumber1 == other.ThoroughfareNumber1 ||
                     ThoroughfareNumber1 != null &&
                     ThoroughfareNumber1.Equals(other.ThoroughfareNumber1)
                 ) &&
                 (
                     ThoroughfareNumber1Suffix == other.ThoroughfareNumber1Suffix ||
                     ThoroughfareNumber1Suffix != null &&
                     ThoroughfareNumber1Suffix.Equals(other.ThoroughfareNumber1Suffix)
                 ) &&
                 (
                     ThoroughfareNumber2 == other.ThoroughfareNumber2 ||
                     ThoroughfareNumber2 != null &&
                     ThoroughfareNumber2.Equals(other.ThoroughfareNumber2)
                 ) &&
                 (
                     ThoroughfareNumber2Suffix == other.ThoroughfareNumber2Suffix ||
                     ThoroughfareNumber2Suffix != null &&
                     ThoroughfareNumber2Suffix.Equals(other.ThoroughfareNumber2Suffix)
                 ) &&
                 (
                     FlatUnitNumber == other.FlatUnitNumber ||
                     FlatUnitNumber != null &&
                     FlatUnitNumber.Equals(other.FlatUnitNumber)
                 ) &&
                 (
                     FloorLevelNumber == other.FloorLevelNumber ||
                     FloorLevelNumber != null &&
                     FloorLevelNumber.Equals(other.FloorLevelNumber)
                 ) &&
                 (
                     LotNumber == other.LotNumber ||
                     LotNumber != null &&
                     LotNumber.Equals(other.LotNumber)
                 ) &&
                 (
                     BuildingName1 == other.BuildingName1 ||
                     BuildingName1 != null &&
                     BuildingName1.Equals(other.BuildingName1)
                 ) &&
                 (
                     BuildingName2 == other.BuildingName2 ||
                     BuildingName2 != null &&
                     BuildingName2.Equals(other.BuildingName2)
                 ) &&
                 (
                     StreetName == other.StreetName ||
                     StreetName != null &&
                     StreetName.Equals(other.StreetName)
                 ) &&
                 (
                     StreetType == other.StreetType ||
                     StreetType != null &&
                     StreetType.Equals(other.StreetType)
                 ) &&
                 (
                     StreetSuffix == other.StreetSuffix ||
                     StreetSuffix != null &&
                     StreetSuffix.Equals(other.StreetSuffix)
                 ) &&
                 (
                     PostalDeliveryType == other.PostalDeliveryType ||
                     PostalDeliveryType != null &&
                     PostalDeliveryType.Equals(other.PostalDeliveryType)
                 ) &&
                 (
                     PostalDeliveryNumber == other.PostalDeliveryNumber ||
                     PostalDeliveryNumber != null &&
                     PostalDeliveryNumber.Equals(other.PostalDeliveryNumber)
                 ) &&
                 (
                     PostalDeliveryNumberPrefix == other.PostalDeliveryNumberPrefix ||
                     PostalDeliveryNumberPrefix != null &&
                     PostalDeliveryNumberPrefix.Equals(other.PostalDeliveryNumberPrefix)
                 ) &&
                 (
                     PostalDeliveryNumberSuffix == other.PostalDeliveryNumberSuffix ||
                     PostalDeliveryNumberSuffix != null &&
                     PostalDeliveryNumberSuffix.Equals(other.PostalDeliveryNumberSuffix)
                 ) &&
                 (
                     LocalityName == other.LocalityName ||
                     LocalityName != null &&
                     LocalityName.Equals(other.LocalityName)
                 ) &&
                 (
                     Postcode == other.Postcode ||
                     Postcode != null &&
                     Postcode.Equals(other.Postcode)
                 ) &&
                 (
                     State == other.State ||
                     State != null &&
                     State.Equals(other.State)
                 ));
        }
Example #27
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Dpid != null)
         {
             hashCode = hashCode * 59 + Dpid.GetHashCode();
         }
         if (ThoroughfareNumber1 != null)
         {
             hashCode = hashCode * 59 + ThoroughfareNumber1.GetHashCode();
         }
         if (ThoroughfareNumber1Suffix != null)
         {
             hashCode = hashCode * 59 + ThoroughfareNumber1Suffix.GetHashCode();
         }
         if (ThoroughfareNumber2 != null)
         {
             hashCode = hashCode * 59 + ThoroughfareNumber2.GetHashCode();
         }
         if (ThoroughfareNumber2Suffix != null)
         {
             hashCode = hashCode * 59 + ThoroughfareNumber2Suffix.GetHashCode();
         }
         if (FlatUnitNumber != null)
         {
             hashCode = hashCode * 59 + FlatUnitNumber.GetHashCode();
         }
         if (FloorLevelNumber != null)
         {
             hashCode = hashCode * 59 + FloorLevelNumber.GetHashCode();
         }
         if (LotNumber != null)
         {
             hashCode = hashCode * 59 + LotNumber.GetHashCode();
         }
         if (BuildingName1 != null)
         {
             hashCode = hashCode * 59 + BuildingName1.GetHashCode();
         }
         if (BuildingName2 != null)
         {
             hashCode = hashCode * 59 + BuildingName2.GetHashCode();
         }
         if (StreetName != null)
         {
             hashCode = hashCode * 59 + StreetName.GetHashCode();
         }
         if (StreetType != null)
         {
             hashCode = hashCode * 59 + StreetType.GetHashCode();
         }
         if (StreetSuffix != null)
         {
             hashCode = hashCode * 59 + StreetSuffix.GetHashCode();
         }
         if (PostalDeliveryType != null)
         {
             hashCode = hashCode * 59 + PostalDeliveryType.GetHashCode();
         }
         if (PostalDeliveryNumber != null)
         {
             hashCode = hashCode * 59 + PostalDeliveryNumber.GetHashCode();
         }
         if (PostalDeliveryNumberPrefix != null)
         {
             hashCode = hashCode * 59 + PostalDeliveryNumberPrefix.GetHashCode();
         }
         if (PostalDeliveryNumberSuffix != null)
         {
             hashCode = hashCode * 59 + PostalDeliveryNumberSuffix.GetHashCode();
         }
         if (LocalityName != null)
         {
             hashCode = hashCode * 59 + LocalityName.GetHashCode();
         }
         if (Postcode != null)
         {
             hashCode = hashCode * 59 + Postcode.GetHashCode();
         }
         if (State != null)
         {
             hashCode = hashCode * 59 + State.GetHashCode();
         }
         return(hashCode);
     }
 }
Example #28
0
 public string Insert(LotNumber entity)
 {
     return(this.repository.Insert(entity));
 }
Example #29
0
 public string Update(LotNumber entity)
 {
     return(this.repository.Update(entity));
 }
Example #30
0
        private string updateSerials(ReceivingDetailModel model)
        {
            if (!string.IsNullOrEmpty(model.SerialNo))
            {
                List <string> newSerials = model.SerialNo.Trim().Split(new char[] { ',' }).ToList();
                if (newSerials.Count() != model.ThisPurchaseQty)
                {
                    return("Serials must be according to the Quantity");
                }
            }
            if (model.Id > 0)
            {
                ReceivingDetail savedDetail = service.GetSingleReceivingDetail(model.Id);
                if (!string.IsNullOrEmpty(model.SerialNo))
                {
                    List <string> unsavedSerials = model.SerialNo.Trim().Split(new char[] { ',' }).ToList();
                    if (!string.IsNullOrEmpty(savedDetail.SerialNo))
                    {
                        List <string> savedSerials = savedDetail.SerialNo.Split(new char[] { ',' }).ToList();
                        bool          isAvailable  = true;
                        foreach (var serial in savedSerials)
                        {
                            isAvailable = lotService.CheckSerialNumAvailability(AuthenticationHelper.CompanyId.Value, savedDetail.LotNoId.Value, serial);
                            if (!isAvailable)
                            {
                                return("Serial is in use!");
                            }
                        }

                        if (isAvailable)
                        {
                            if (savedSerials.Count() > unsavedSerials.Count())
                            {
                                List <string> tobeDeleted = savedSerials.Take(savedSerials.Count() - unsavedSerials.Count()).ToList();
                                if (tobeDeleted != null && tobeDeleted.Count() > 0)
                                {
                                    foreach (var item in tobeDeleted)
                                    {
                                        SerialNumber serialNum = lotService.GetSerialNo(item, savedDetail.LotNoId.Value, AuthenticationHelper.CompanyId.Value, SessionHelper.SOBId);
                                        if (serialNum != null)
                                        {
                                            lotService.DeleteSerialNum(serialNum.Id.ToString(), AuthenticationHelper.CompanyId.Value);
                                        }
                                    }
                                }
                            }
                            foreach (var serial in unsavedSerials)
                            {
                                SerialNumber entity = lotService.GetSerialNo(serial, savedDetail.LotNoId.Value, AuthenticationHelper.CompanyId.Value, SessionHelper.SOBId);
                                if (entity != null)
                                {
                                    entity.LotNo    = model.LotNo;
                                    entity.SerialNo = serial;
                                    lotService.UpdateSerialNum(entity);
                                }
                                else
                                {
                                    lotService.InsertSerialNum(new SerialNumber
                                    {
                                        CompanyId  = AuthenticationHelper.CompanyId.Value,
                                        CreateBy   = AuthenticationHelper.UserId,
                                        CreateDate = DateTime.Now,
                                        LotNo      = model.LotNo,
                                        LotNoId    = savedDetail.LotNoId.Value,
                                        SerialNo   = serial,
                                        UpdateBy   = null,
                                        UpdateDate = null
                                    });
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (var serial in unsavedSerials)
                        {
                            lotService.InsertSerialNum(new SerialNumber
                            {
                                CompanyId  = AuthenticationHelper.CompanyId.Value,
                                CreateBy   = AuthenticationHelper.UserId,
                                CreateDate = DateTime.Now,
                                LotNo      = model.LotNo,
                                LotNoId    = savedDetail.Id,
                                SerialNo   = serial,
                                UpdateBy   = null,
                                UpdateDate = null
                            });
                        }
                    }
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(model.SerialNo))
                {
                    if (!string.IsNullOrEmpty(model.LotNo))
                    {
                        LotNumber lot = lotService.GetLotbyItem(AuthenticationHelper.CompanyId.Value, SessionHelper.SOBId, model.ItemId, model.LotNo);
                        if (lot != null)
                        {
                            List <string> serials      = model.SerialNo.Trim().Split(new char[] { ',' }).ToList();
                            bool          notAvailable = true;
                            foreach (var serial in serials)
                            {
                                notAvailable = lotService.CheckSerialNumAvailability(AuthenticationHelper.CompanyId.Value, lot.Id, serial);
                                if (notAvailable)
                                {
                                    return("Serial # " + serial + " is already defined");
                                }
                            }
                            if (!notAvailable)
                            {
                                foreach (var serial in serials)
                                {
                                    lotService.InsertSerialNum(new SerialNumber
                                    {
                                        CompanyId  = AuthenticationHelper.CompanyId.Value,
                                        CreateBy   = AuthenticationHelper.UserId,
                                        CreateDate = DateTime.Now,
                                        LotNo      = lot.LotNo,
                                        LotNoId    = lot.Id,
                                        SerialNo   = serial,
                                        UpdateBy   = null,
                                        UpdateDate = null
                                    });
                                }
                            }
                        }
                        else
                        {
                            return("Lot not found!");
                        }
                    }
                    else
                    {
                        return("Serials can not be defined without lot!");
                    }
                }
            }

            return("");
        }