Exemple #1
0
 public ValidationMsg UpdateConfRecordStatus(string lcId, string approvalAdvice, int userId)
 {
     try
     {
         if (lcId != "")
         {
             LCM_LCOpening ob = repository.LCOpeningRepository.GetByID(Convert.ToInt32(lcId));
             if (ob.RecordStatus == "NCF")
             {
                 ob.ApprovalAdvice = approvalAdvice.ToString().Trim();
                 ob.RecordStatus   = "CNF";
                 ob.LCStatus       = "RNG";
                 ob.ApprovedBy     = userId;
                 ob.ApproveDate    = DateTime.Now;
                 repository.LCOpeningRepository.Update(ob);
                 int flag = repository.Save();
                 if (flag == 1)
                 {
                     _vmMsg.Type = Enums.MessageType.Success;
                     _vmMsg.Msg  = "Confirmed Successfully.";
                 }
                 else
                 {
                     _vmMsg.Type = Enums.MessageType.Error;
                     _vmMsg.Msg  = "Confirmed Faild.";
                 }
             }
             else
             {
                 _vmMsg.Type = Enums.MessageType.Error;
                 _vmMsg.Msg  = "Data Save First.";
             }
         }
         else
         {
             _vmMsg.Type = Enums.MessageType.Error;
             _vmMsg.Msg  = "Data Save First.";
         }
     }
     catch (DbEntityValidationException e)
     {
         StringBuilder sb = new StringBuilder();
         foreach (var eve in e.EntityValidationErrors)
         {
             sb.AppendLine(string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                         eve.Entry.Entity.GetType().Name,
                                         eve.Entry.State));
             foreach (var ve in eve.ValidationErrors)
             {
                 sb.AppendLine(string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                             ve.PropertyName,
                                             ve.ErrorMessage));
             }
         }
         throw new DbEntityValidationException(sb.ToString(), e);
     }
     return(_vmMsg);
 }
Exemple #2
0
        public ValidationMsg UpdateLCOpeningInfo(LcmLcOpening dataSet, int UserID)
        {
            try
            {
                LCM_LCOpening obLcOpening = repository.LCOpeningRepository.GetByID(Convert.ToInt32(dataSet.LCID));
                if (!obLcOpening.RecordStatus.Equals("CNF"))
                {
                    obLcOpening.LCNo          = dataSet.LCNo;
                    obLcOpening.LCDate        = DalCommon.SetDate(dataSet.LCDate.ToString());
                    obLcOpening.LCAmount      = dataSet.LCAmount;
                    obLcOpening.ExchangeRate  = dataSet.ExchangeRate;
                    obLcOpening.ExchangeValue = Convert.ToDecimal(dataSet.LCAmount * dataSet.ExchangeRate);
                    if (dataSet.LCAmountCurrency > 0)
                    {
                        obLcOpening.LCCurrencyID = (byte)dataSet.LCAmountCurrency;
                    }
                    if (dataSet.ExchangeCurrency > 0)
                    {
                        obLcOpening.ExchangeCurrency = (byte)dataSet.ExchangeCurrency;
                    }


                    obLcOpening.IssueDate        = Convert.ToDateTime(DalCommon.SetDate(dataSet.IssueDate));
                    obLcOpening.ExpiryDate       = DalCommon.SetDate(dataSet.ExpiryDate);
                    obLcOpening.ExpiryPlace      = dataSet.ExpiryPlace;
                    obLcOpening.NNDSendingTime   = dataSet.NNDSendingTime;
                    obLcOpening.ApprovalAdvice   = dataSet.ApprovalAdvice;
                    obLcOpening.LCANo            = dataSet.LCANo;
                    obLcOpening.IRCNo            = dataSet.IRCNo;
                    obLcOpening.VatRegNo         = dataSet.VatRegNo;
                    obLcOpening.TINNo            = dataSet.TINNo;
                    obLcOpening.BINNo            = dataSet.BINNo;
                    obLcOpening.ICNNo            = dataSet.ICNNo;
                    obLcOpening.ICNDate          = DalCommon.SetDate(dataSet.ICNDate);
                    obLcOpening.LastShipmentDate = DalCommon.SetDate(dataSet.LastShipmentDate);
                    if (dataSet.BranchID > 0)
                    {
                        obLcOpening.LCOpeningBank = dataSet.BranchID;
                    }
                    if (dataSet.AdvisingBank > 0)
                    {
                        obLcOpening.AdvisingBank = dataSet.AdvisingBank;
                    }

                    if (!string.IsNullOrEmpty(dataSet.Beneficiary))
                    {
                        obLcOpening.Beneficiary = Convert.ToInt32(dataSet.Beneficiary);
                    }

                    if (!string.IsNullOrEmpty(dataSet.PINo))
                    {
                        obLcOpening.PIID = dataSet.PIID;
                        obLcOpening.PINo = dataSet.PINo;
                    }

                    obLcOpening.ModifiedOn = DateTime.Now;
                    obLcOpening.ModifiedBy = UserID;
                    obLcOpening.IPAddress  = GetIPAddress.LocalIPAddress();
                    obLcOpening.LCMargin   = dataSet.LCMargin;
                    //   ##############        "": "", "": "", "": "", "": "", "": "",
                    if (!string.IsNullOrEmpty(dataSet.InsuranceID.ToString()))
                    {
                        obLcOpening.InsuranceID = Convert.ToInt32(dataSet.InsuranceID);
                    }
                    if (!string.IsNullOrEmpty(dataSet.PICurrency.ToString()))
                    {
                        obLcOpening.PICurrency = (byte)dataSet.PICurrency;
                    }
                    obLcOpening.PaymentTerm  = dataSet.PaymentTerm;
                    obLcOpening.PaymentMode  = dataSet.PaymentMode;
                    obLcOpening.DeferredDays = dataSet.DeferredDays;
                    if (!string.IsNullOrEmpty(dataSet.CountryOforigin.ToString()))
                    {
                        obLcOpening.CountryOforigin = Convert.ToInt32(dataSet.CountryOforigin);
                    }
                    if (!string.IsNullOrEmpty(dataSet.BeneficiaryBank.ToString()))
                    {
                        obLcOpening.BeneficiaryBank = Convert.ToInt32(dataSet.BeneficiaryBank);
                    }

                    obLcOpening.DeliveryTerm = dataSet.DeliveryTerm;
                    if (!string.IsNullOrEmpty(dataSet.PortofDischarge.ToString()))
                    {
                        obLcOpening.PortofDischarge = Convert.ToInt32(dataSet.PortofDischarge);
                    }

                    obLcOpening.DeliveryMode = dataSet.DeliveryMode;
                    if (!string.IsNullOrEmpty(dataSet.PortofLoading.ToString()))
                    {
                        obLcOpening.PortofLoading = Convert.ToInt32(dataSet.PortofLoading);
                    }

                    obLcOpening.Transshipment   = dataSet.Transshipment;
                    obLcOpening.PartialShipment = dataSet.PartialShipment;
                    obLcOpening.GoodDelivery    = dataSet.GoodDelivery;
                    obLcOpening.ShippingMark    = dataSet.ShippingMark;
                    if (!string.IsNullOrEmpty(dataSet.ExpectedShipmentTime))
                    {
                        obLcOpening.ExpectedShipmentTime = Convert.ToInt32(dataSet.ExpectedShipmentTime);
                    }

                    obLcOpening.Packing        = dataSet.Packing;
                    obLcOpening.PreShipmentIns = dataSet.PreShipmentIns;
                    if (!string.IsNullOrEmpty(dataSet.OfferValidityDays.ToString()))
                    {
                        obLcOpening.OfferValidityDays = Convert.ToInt32(dataSet.OfferValidityDays);
                    }

                    obLcOpening.PresentationDays = Convert.ToInt32(dataSet.PresentationDays);
                    obLcOpening.ConfirmStatus    = dataSet.ConfirmStatus;

                    repository.LCOpeningRepository.Update(obLcOpening);
                    int flag = repository.Save();
                    if (flag == 1)
                    {
                        _vmMsg.Type = Enums.MessageType.Success;
                        _vmMsg.Msg  = "Update Successfully.";
                    }
                    else
                    {
                        _vmMsg.Type = Enums.MessageType.Error;
                        _vmMsg.Msg  = "Saved Faild.";
                    }
                }
                else
                {
                    _vmMsg.Type = Enums.MessageType.Error;
                    _vmMsg.Msg  = "Data already confirmed. You can't update this.";
                }
            }
            catch (DbEntityValidationException e)
            {
                StringBuilder sb = new StringBuilder();
                foreach (var eve in e.EntityValidationErrors)
                {
                    sb.AppendLine(string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                eve.Entry.Entity.GetType().Name,
                                                eve.Entry.State));
                    foreach (var ve in eve.ValidationErrors)
                    {
                        sb.AppendLine(string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                                    ve.PropertyName,
                                                    ve.ErrorMessage));
                    }
                }
                throw new DbEntityValidationException(sb.ToString(), e);
            }
            return(_vmMsg);
        }