public long AddNewRequisitionDate(string _ScheduleID, string _RequiredDate)
        {
            try
            {
                using (_context)
                {
                    PRD_YearMonthFinishReqDate obj = new PRD_YearMonthFinishReqDate();

                    obj.ScheduleID   = Convert.ToInt64(_ScheduleID);
                    obj.RequiredDate = DalCommon.SetDate(_RequiredDate);
                    //Random r = new Random();
                    //obj.RequisitionNo = r.Next().ToString();
                    obj.RequisitionNo = DalCommon.GetPreDefineNextCodeByUrl("WBRequisitionForCrusting/WBRequisitionForCrusting");
                    obj.RecordStatus  = "NCF";


                    _context.PRD_YearMonthFinishReqDate.Add(obj);
                    _context.SaveChanges();

                    return(obj.RequisitionDateID);
                }
            }
            catch
            {
                return(0);
            }
        }
Beispiel #2
0
        private LCM_PackingList ModelConversionPackingList(PackingListVM model, int userId, string url)
        {
            var entity = model.Plid == 0 ? new LCM_PackingList() : (from b in _context.LCM_PackingList.AsEnumerable()
                                                                    where b.PLID == model.Plid
                                                                    select b).FirstOrDefault();

            entity.PLID            = model.Plid;
            entity.PLNo            = model.Plid == 0 ? DalCommon.GetPreDefineNextCodeByUrl(url) : model.PlNo;
            entity.PLDate          = DalCommon.SetDate(model.PlDate);
            entity.LCID            = model.Lcid;
            entity.LCNo            = model.LcNo;
            entity.CIID            = model.Ciid;
            entity.CINo            = model.CiNo;
            entity.PLNetWeight     = model.NetWeight;
            entity.NetWeightUnit   = model.NetWeightUnit;
            entity.PLGrossWeight   = model.GrossWeight;
            entity.GrossWeightUnit = model.GrossWeightUnit;
            entity.PLNote          = model.PlNote;
            entity.RecordStatus    = model.Plid == 0 ? "NCF" : model.RecordStatus;
            entity.SetOn           = model.Plid == 0 ? DateTime.Now : _unit.PackingListRepository.GetByID(model.Plid).SetOn;
            entity.SetBy           = model.Plid == 0 ? userId : _unit.PackingListRepository.GetByID(model.Plid).SetBy;
            entity.ModifiedBy      = model.Plid == 0 ? (int?)null : userId;
            entity.ModifiedOn      = model.Plid == 0 ? (DateTime?)null : DateTime.Now;

            return(entity);
        }
Beispiel #3
0
        public ValidationMsg Save(EXPBankDebitVoucher model, int userid, string pageUrl)
        {
            _vmMsg = new ValidationMsg();
            try
            {
                #region Save

                using (var tx = new TransactionScope())
                {
                    using (_context)
                    {
                        model.BDVNo = DalCommon.GetPreDefineNextCodeByUrl(pageUrl);//DalCommon.GetPreDefineValue("1", "00045");
                        if (model.BDVNo != null)
                        {
                            EXP_BankDebitVoucher tblEXPCI = SetToModelObject(model, userid);
                            _context.EXP_BankDebitVoucher.Add(tblEXPCI);
                            _context.SaveChanges();

                            tx.Complete();
                            BDVID       = tblEXPCI.BDVID;
                            BDVNo       = model.BDVNo;
                            _vmMsg.Type = Enums.MessageType.Success;
                            _vmMsg.Msg  = "Saved Successfully.";
                        }
                        else
                        {
                            _vmMsg.Type = Enums.MessageType.Error;
                            _vmMsg.Msg  = "BDVNo Predefine Value not Found.";
                        }
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                _vmMsg.Type = Enums.MessageType.Error;
                _vmMsg.Msg  = "Failed to save.";
                if (ex.InnerException.InnerException.Message.Contains("UNIQUE KEY"))
                {
                    _vmMsg.Type = Enums.MessageType.Error;
                    _vmMsg.Msg  = "Schedule Year,Month Combination Data Already Exit.";
                }
            }
            return(_vmMsg);
        }
        private PRQ_ChemLocalPurcBill BillConversion(PrqChemLocalPurcBill model, int userId, string url)
        {
            var entity = model.BillId == 0
                ? new PRQ_ChemLocalPurcBill()
                : (from b in _context.PRQ_ChemLocalPurcBill.AsEnumerable()
                   where b.BillID == model.BillId
                   select b).FirstOrDefault();

            entity.BillID            = model.BillId;
            entity.BillNo            = model.BillId == 0 ? DalCommon.GetPreDefineNextCodeByUrl(url) : model.BillNo;
            entity.BillDate          = DalCommon.SetDate(model.BillDate);
            entity.PurchaseYear      = model.PurchaseYear;
            entity.SupplierID        = model.SupplierId;
            entity.SupplierAddressID = model.SupplierAddressId;
            entity.SupplierBillNo    = model.SupplierBillNo;
            entity.SupBillDate       = DalCommon.SetDate(model.SupBillDate);
            entity.BillCategory      = "Real";
            entity.BillType          = "Supplier";
            entity.Currency          = model.Currency;
            entity.ExchangRate       = model.ExchangRate;
            entity.ExchangCurrency   = model.ExchangCurrency;
            entity.ExchangValue      = model.ExchangValue;
            entity.BillAmt           = model.BillAmt;
            entity.VatAmt            = model.VatAmt;
            entity.DiscountPercent   = model.DiscountPercent;
            entity.DiscountAmt       = model.DiscountAmt;
            entity.PayableAmt        = model.PayableAmt;
            entity.RecordStatus      = model.BillId == 0 ? "NCF" : model.RecordStatus;
            entity.SetBy             = model.BillId == 0
                ? userId
                : _unit.ChemicalLocalPurchaseBillRepository.GetByID(model.BillId).SetBy;
            entity.SetOn = model.BillId == 0
                ? DateTime.Now
                : _unit.ChemicalLocalPurchaseBillRepository.GetByID(model.BillId).SetOn;
            entity.ModifiedBy = model.BillId == 0 ? (int?)null : userId;
            entity.ModifiedOn = model.BillId == 0 ? (DateTime?)null : DateTime.Now;

            return(entity);
        }
        private SLS_BuyerOrder ConvertOrder(SlsBuyerOrder model, int userId, string url)
        {
            var entity = model.BuyerOrderID == 0 ? new SLS_BuyerOrder() : (from b in _context.SLS_BuyerOrder.AsEnumerable()
                                                                           where b.BuyerOrderID == model.BuyerOrderID
                                                                           select b).FirstOrDefault();

            entity.BuyerOrderID         = model.BuyerOrderID;
            entity.BuyerOrderNo         = model.BuyerOrderNo ?? DalCommon.GetPreDefineNextCodeByUrl(url);
            entity.OrderNo              = model.OrderNo;
            entity.BuyerOrderDate       = model.BuyerOrderDate == null ? DateTime.Now : DalCommon.SetDate(model.BuyerOrderDate);
            entity.OrderFrom            = model.OrderFrom;
            entity.BuyerOrderCategory   = model.BuyerOrderCategory;
            entity.BuyerID              = model.BuyerID;
            entity.BuyerAddressID       = model.BuyerAddressID;
            entity.BuyerLocalAgentID    = model.BuyerLocalAgentID;
            entity.BuyerForeignAgentID  = model.BuyerForeignAgentID;
            entity.BuyerRef             = model.BuyerRef;
            entity.ExpectedShipmentDate = model.ExpectedShipmentDate == null ? DateTime.Now : DalCommon.SetDate(model.ExpectedShipmentDate);
            entity.RevisionNo           = model.RevisionNo;
            entity.RevisionDate         = DalCommon.SetDate(model.RevisionDate);
            entity.OrderCurrency        = model.OrderCurrency;
            entity.BuyerOrderStatus     = model.BuyerOrderStatus == null ? "OD" : DalCommon.ReverseOrderStatus(model.BuyerOrderStatus);
            entity.RecordStatus         = model.BuyerOrderID == 0
                ? "NCF"
                : _unit.SlsBuyerOrederRepository.GetByID(model.BuyerOrderID).RecordStatus;
            entity.SetOn = model.BuyerOrderID == 0
                ? DateTime.Now
                : _unit.SlsBuyerOrederRepository.GetByID(model.BuyerOrderID).SetOn;
            entity.SetBy = model.BuyerOrderID == 0
                ? userId
                : _unit.SlsBuyerOrederRepository.GetByID(model.BuyerOrderID).SetBy;
            entity.ModifiedBy    = model.BuyerOrderID == 0 ? (int?)null : userId;
            entity.ModifiedOn    = model.BuyerOrderID == 0 ? (DateTime?)null : DateTime.Now;
            entity.OrderCurrency = model.OrderCurrency;
            entity.TotalFootQty  = model.TotalFootQty;
            entity.TotalMeterQty = model.TotalMeterQty;
            entity.PriceLevel    = model.PriceLevel;
            return(entity);
        }
Beispiel #6
0
        public ValidationMsg Save(EXPAgentCommission model, int userid, string pageUrl)
        {
            _vmMsg = new ValidationMsg();
            try
            {
                #region Save

                using (var tx = new TransactionScope())
                {
                    using (_context)
                    {
                        model.AgentComNo = DalCommon.GetPreDefineNextCodeByUrl(pageUrl);//DalCommon.GetPreDefineValue("1", "00045");
                        if (model.AgentComNo != null)
                        {
                            #region AgentCommission

                            EXP_AgentCommission tblEXPAgentCommission = SetToModelObject(model, userid);
                            _context.EXP_AgentCommission.Add(tblEXPAgentCommission);
                            _context.SaveChanges();

                            #endregion

                            #region CIPIItemColor

                            if (model.EXPAgentCommissionBuyerCIList != null)
                            {
                                foreach (EXPAgentCommissionBuyerCI objEXPAgentCommissionBuyerCI in model.EXPAgentCommissionBuyerCIList)
                                {
                                    objEXPAgentCommissionBuyerCI.AgentComID    = tblEXPAgentCommission.AgentComID;
                                    objEXPAgentCommissionBuyerCI.LocalCurrency = model.LocalCurrency;

                                    EXP_AgentCommissionBuyerCI tblEXPAgentCommissionBuyerCI = SetToModelObject(objEXPAgentCommissionBuyerCI, userid);
                                    _context.EXP_AgentCommissionBuyerCI.Add(tblEXPAgentCommissionBuyerCI);
                                }
                            }
                            #endregion

                            _context.SaveChanges();
                            tx.Complete();
                            AgentComID  = tblEXPAgentCommission.AgentComID;
                            AgentComNo  = model.AgentComNo;
                            _vmMsg.Type = Enums.MessageType.Success;
                            _vmMsg.Msg  = "Saved Successfully.";
                        }
                        else
                        {
                            _vmMsg.Type = Enums.MessageType.Error;
                            _vmMsg.Msg  = "AgentComNo Predefine Value not Found.";
                        }
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                _vmMsg.Type = Enums.MessageType.Error;
                _vmMsg.Msg  = "Failed to save.";
                if (ex.InnerException.InnerException.Message.Contains("UK_EXP_AgentCommission_AgentComNo"))
                {
                    _vmMsg.Type = Enums.MessageType.Error;
                    _vmMsg.Msg  = "Agent Com. No Already Exist.";
                }
                if (ex.InnerException.InnerException.Message.Contains("UK_EXP_AgentCommissionBuyerCI_BuyerAgentID_CIID"))
                {
                    _vmMsg.Type = Enums.MessageType.Error;
                    _vmMsg.Msg  = "Same Agent Already Exist.";
                }
            }
            return(_vmMsg);
        }
Beispiel #7
0
        public ValidationMsg SaveLCM_LCRetirement(EXP_LCRetirement dataSet, int _userId, string url)
        {
            try
            {
                EXP_LCRetirement obLCRetirement = new EXP_LCRetirement();
                obLCRetirement.LCRetirementID   = dataSet.LCRetirementID;
                obLCRetirement.LCRetirementNo   = DalCommon.GetPreDefineNextCodeByUrl(url);
                obLCRetirement.LCRetirementDate = dataSet.LCRetirementDate;
                obLCRetirement.LCNo             = dataSet.LCNo;
                obLCRetirement.LCID             = dataSet.LCID;
                //obLCRetirement.BillValue = (decimal)dataSet.BillValue;
                //EXP_CIPI ExchangeValueInvoice = repository.EXPCommercialInvoicePIRepository.Get(filter: dat => dat.LCID == dataSet.LCID).FirstOrDefault();
                //EXP_CIPI ExchangeRateInvoice = repository.EXPCommercialInvoicePIRepository.Get(filter: dat => dat.LCID == dataSet.LCID).FirstOrDefault();
                obLCRetirement.BillValue = dataSet.BillValue;//(ExchangeValueInvoice.ExchangeValue / ExchangeRateInvoice.ExchangeRate) == null ? 0 : (decimal)(ExchangeValueInvoice.ExchangeValue / ExchangeRateInvoice.ExchangeRate);

                //obLcLimInfo.OtherCharges = dataSet.OtherCharges == null ? 0 : (decimal)dataSet.OtherCharges;

                obLCRetirement.InterestPersent = dataSet.InterestPersent == null ? 0 : (decimal)dataSet.InterestPersent;
                obLCRetirement.InterestAmount  = dataSet.InterestAmount == null ? 0 : (decimal)dataSet.InterestAmount;

                obLCRetirement.BankCommissionAmt = dataSet.BankCommissionAmt == null ? 0 : (decimal)dataSet.BankCommissionAmt;
                obLCRetirement.OtherCharge       = dataSet.OtherCharge == null ? 0 : (decimal)dataSet.OtherCharge;
                obLCRetirement.SwiftCharge       = dataSet.SwiftCharge == null ? 0 : (decimal)dataSet.SwiftCharge;
                obLCRetirement.TotalAmount       = dataSet.TotalAmount == null ? 0 : (decimal)dataSet.TotalAmount;

                obLCRetirement.LCRCurrency = (byte)dataSet.LCRCurrency;
                obLCRetirement.Remarks     = dataSet.Remarks == null ? "" : dataSet.Remarks;

                obLCRetirement.ExchangeCurrency = (byte)(dataSet.ExchangeCurrency);
                //obLCRetirement.ExchangeRate = (decimal)dataSet.ExchangeRate == null ? 0 : (decimal)dataSet.ExchangeRate;
                if (obLCRetirement.ExchangeRate == null)
                {
                    dataSet.ExchangeRate = 0;
                }
                else
                {
                    obLCRetirement.ExchangeRate = (decimal)dataSet.ExchangeRate;
                }
                obLCRetirement.ExchangeValue = (decimal)dataSet.ExchangeValue == null ? 0 : (decimal)dataSet.ExchangeValue;
                obLCRetirement.RecordStatus  = "NCF";

                obLCRetirement.SetOn     = DateTime.Now;
                obLCRetirement.SetBy     = _userId;
                obLCRetirement.IPAddress = GetIPAddress.LocalIPAddress();

                obEntity.EXP_LCRetirement.Add(obLCRetirement);
                int flag = obEntity.SaveChanges();
                if (flag == 1)
                {
                    _vmMsg.ReturnId   = repository.LcmRetirementRpository.Get().Last().LCRetirementID;
                    _vmMsg.ReturnCode = dataSet.LCRetirementNo;//repository.LcmRetirementRpository.GetByID(_vmMsg.ReturnId).LCRetirementNo;
                    _vmMsg.Type       = Enums.MessageType.Success;
                    _vmMsg.Msg        = "Saved Successfully.";
                }
                else
                {
                    _vmMsg.Type = Enums.MessageType.Error;
                    _vmMsg.Msg  = "Saved Faild.";
                }
            }
            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);
        }
Beispiel #8
0
        public int Save(PRDChemProdReq model, int userId, string pageUrl)
        {
            int CurrentRequisitionID = 0;

            try
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    using (_context)
                    {
                        var GetRequisitionNo = DalCommon.GetPreDefineNextCodeByUrl(pageUrl);

                        if (GetRequisitionNo != null)
                        {
                            #region New_Requisition_Insert

                            PRD_ChemProdReq objRequisition = new PRD_ChemProdReq();

                            objRequisition.RequisitionNo       = GetRequisitionNo;
                            objRequisition.RequisitionCategory = model.RequisitionCategory;
                            objRequisition.RequisitionType     = model.RequisitionType;
                            objRequisition.RequisitionFrom     = model.RequisitionFrom;
                            objRequisition.RequisitionTo       = model.RequisitionTo;
                            objRequisition.RequiredByTime      = model.RequiredByTime;
                            objRequisition.ReqRaisedBy         = userId;
                            objRequisition.ReqRaisedOn         = DalCommon.SetDate((model.ReqRaisedOn).ToString());
                            if (model.RecipeFor == 0)
                            {
                                objRequisition.RecipeFor = null;
                            }
                            else
                            {
                                objRequisition.RecipeFor = model.RecipeFor;
                            }
                            if (model.RecipeID == 0)
                            {
                                objRequisition.RecipeID = null;
                            }
                            else
                            {
                                objRequisition.RecipeID = model.RecipeID;
                            }
                            objRequisition.ArticleNo = model.ArticleNo;

                            objRequisition.Thickness = model.Thickness;
                            if (model.ThicknessUnit != null)
                            {
                                objRequisition.ThicknessUnit = model.ThicknessUnit;
                            }
                            objRequisition.LeatherSize = model.LeatherSize;
                            if (model.SizeUnit != null)
                            {
                                objRequisition.SizeUnit = model.SizeUnit;
                            }
                            objRequisition.Selection     = model.Selection;
                            objRequisition.ProductionQty = model.ProductionQty;

                            objRequisition.RequisitionState  = "RNG";
                            objRequisition.RequisitionStatus = "PND";
                            objRequisition.RecordStatus      = "NCF";
                            objRequisition.SetBy             = userId;
                            objRequisition.SetOn             = DateTime.Now;



                            //if (model.BuyerAddressID == 0)
                            //    objPI.BeneficiaryAddressID = null;
                            //else
                            //    objPI.BeneficiaryAddressID = model.BuyerAddressID;

                            _context.PRD_ChemProdReq.Add(objRequisition);
                            _context.SaveChanges();
                            CurrentRequisitionID = objRequisition.RequisitionID;
                            #endregion

                            #region Item Insert
                            if (model.RequisitionItemList != null)
                            {
                                foreach (var item in model.RequisitionItemList)
                                {
                                    PRD_ChemProdReqItem objItem = new PRD_ChemProdReqItem();
                                    objItem.RequisitionID = CurrentRequisitionID;
                                    objItem.ItemID        = Convert.ToInt32(item.ItemID);

                                    if (item.SupplierID == 0)
                                    {
                                        objItem.SupplierID = null;
                                    }
                                    else
                                    {
                                        objItem.SupplierID = item.SupplierID;
                                    }
                                    //objItem.SupplierID = item.SupplierID;

                                    objItem.RequiredQty = item.RequiredQty;


                                    if (item.RequiredUnitName == null)
                                    {
                                        objItem.RequiredUnit = null;
                                    }
                                    else
                                    {
                                        objItem.RequiredUnit = DalCommon.GetUnitCode(item.RequiredUnitName);
                                    }


                                    objItem.RequsitionQty   = Convert.ToDecimal(item.RequsitionQty);
                                    objItem.RequisitionUnit = DalCommon.GetUnitCode(item.RequisitionUnitName);

                                    if (item.PackSizeName == null)
                                    {
                                        objItem.PackSize = null;
                                    }
                                    else
                                    {
                                        objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName);
                                    }

                                    //objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName);

                                    if (item.SizeUnitName == null)
                                    {
                                        objItem.SizeUnit = null;
                                    }
                                    else
                                    {
                                        objItem.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName);
                                    }
                                    //objItem.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName);


                                    objItem.PackQty     = item.PackQty;
                                    objItem.ApproveQty  = item.ApproveQty;
                                    objItem.ApproveUnit = DalCommon.GetUnitCode(item.ApproveUnitName);
                                    //objItem.ManufacturerID = item.ManufacturerID;
                                    objItem.ItemSource = DalCommon.ReturnItemSource(item.ItemSource);
                                    objItem.SetOn      = DateTime.Now;
                                    objItem.SetBy      = userId;

                                    _context.PRD_ChemProdReqItem.Add(objItem);
                                    _context.SaveChanges();
                                }
                            }
                            #endregion
                        }
                    }
                    transaction.Complete();
                }
                return(CurrentRequisitionID);
            }
            catch (Exception e)
            {
                return(0);
            }
        }
Beispiel #9
0
        public long SavePurchaseInformation(PurchaseReceive model, int userId)
        {
            long CurrentPurchaseID = 0;

            try
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    #region New_Purchase_Insert
                    using (_context)
                    {
                        Prq_Purchase objPurchase = new Prq_Purchase();
                        //Random r = new Random();

                        //objPurchase.PurchaseNo = r.Next().ToString();
                        objPurchase.PurchaseNo        = DalCommon.GetPreDefineNextCodeByUrl("Purchase/Purchase");
                        objPurchase.SupplierID        = Convert.ToInt16(model.SupplierID);
                        objPurchase.SupplierAddressID = Convert.ToInt16(model.SupplierAddressID);
                        objPurchase.PurchaseCategory  = model.PurchaseCategory;
                        objPurchase.PurchaseType      = model.PurchaseType;
                        objPurchase.PurchaseYear      = model.PurchaseYear;
                        objPurchase.PurchaseDate      = DalCommon.SetDate(model.PurchaseDate);
                        objPurchase.PurchaseNote      = model.PurchaseNote;
                        objPurchase.RecordStatus      = "NCF";
                        objPurchase.SetOn             = DateTime.Now;
                        objPurchase.SetBy             = userId;

                        _context.Prq_Purchase.Add(objPurchase);
                        _context.SaveChanges();

                        CurrentPurchaseID = objPurchase.PurchaseID;

                        if (model.ChallanList != null)
                        {
                            Prq_PurchaseChallan objChallan = new Prq_PurchaseChallan();

                            objChallan.ChallanNo       = model.ChallanList.FirstOrDefault().ChallanNo;
                            objChallan.PurchaseID      = CurrentPurchaseID;
                            objChallan.SourceID        = model.ChallanList.FirstOrDefault().SourceID;
                            objChallan.LocationID      = model.ChallanList.FirstOrDefault().LocationID;
                            objChallan.ReceiveStore    = DalCommon.GetStoreCode(model.ChallanList.FirstOrDefault().ReceiveStore);
                            objChallan.ChallanCategory = model.ChallanList.FirstOrDefault().ChallanCategory;
                            objChallan.ChallanNote     = model.ChallanList.FirstOrDefault().ChallanNote;



                            objChallan.ChallanDate = Convert.ToDateTime(model.ChallanList.FirstOrDefault().ChallanDate);


                            objChallan.RecordStatus = "NCF";
                            objChallan.SetOn        = DateTime.Now;
                            objChallan.SetBy        = userId;

                            _context.Prq_PurchaseChallan.Add(objChallan);
                            _context.SaveChanges();

                            var CurrentChallanNo = objChallan.ChallanID;

                            if (model.ChallanItemList != null)
                            {
                                foreach (var ChallanItem in model.ChallanItemList)
                                {
                                    Prq_PurchaseChallanItem objPurchaseChallanItem = new Prq_PurchaseChallanItem();

                                    objPurchaseChallanItem.ChallanID    = CurrentChallanNo;
                                    objPurchaseChallanItem.ItemCategory = "Leather";
                                    objPurchaseChallanItem.ItemTypeID   = DalCommon.GetItemTypeCode(ChallanItem.ItemTypeID);
                                    objPurchaseChallanItem.ItemSizeID   = DalCommon.GetSizeCode(ChallanItem.ItemSizeID);
                                    objPurchaseChallanItem.Description  = ChallanItem.Description;
                                    objPurchaseChallanItem.UnitID       = DalCommon.GetUnitCode(ChallanItem.UnitID);
                                    objPurchaseChallanItem.ChallanQty   = ChallanItem.ChallanQty;
                                    objPurchaseChallanItem.ReceiveQty   = ChallanItem.ReceiveQty;
                                    objPurchaseChallanItem.Remark       = ChallanItem.Remark;
                                    objPurchaseChallanItem.RecordStatus = "NCF";
                                    objPurchaseChallanItem.SetBy        = userId;
                                    objPurchaseChallanItem.SetOn        = DateTime.Now;

                                    _context.Prq_PurchaseChallanItem.Add(objPurchaseChallanItem);
                                    _context.SaveChanges();
                                }
                            }
                        }
                    }
                    #endregion

                    transaction.Complete();
                }
                return(CurrentPurchaseID);
            }
            catch (Exception e)
            {
                return(CurrentPurchaseID);
            }
        }
Beispiel #10
0
        public ValidationMsg SaveProductionRecipe(PrdRecipe recipeModel, int userId, string pageUrl)
        {
            try
            {
                using (var tx = new TransactionScope())
                {
                    var currentRecipeId = 0;
                    var currentCode     = DalCommon.GetPreDefineNextCodeByUrl(pageUrl);
                    using (_context)
                    {
                        var recipe = new PRD_Recipe
                        {
                            RecipeName       = recipeModel.RecipeName,
                            RecipeFor        = recipeModel.RecipeFor,
                            RecipeNo         = currentCode,
                            ArticleID        = recipeModel.ArticleID,
                            ArticleNo        = recipeModel.ArticleNo ?? "",
                            ArticleChallanNo = recipeModel.ArticleChallanNo ?? "",
                            ArticleName      = recipeModel.ArticleName ?? "",
                            ArticleColor     = recipeModel.ArticleColor,
                            CalculationBase  = recipeModel.CalculationBase,
                            BaseQuantity     = recipeModel.BaseQuantity,
                            BaseUnit         = recipeModel.BaseUnit,
                            RecordStatus     = "NCF",
                            SetOn            = DateTime.Now,
                            SetBy            = userId,
                            IPAddress        = GetIPAddress.LocalIPAddress()
                        };
                        _context.PRD_Recipe.Add(recipe);
                        _context.SaveChanges();

                        currentRecipeId = recipe.RecipeID;

                        if (recipeModel.RecipeItems != null)
                        {
                            foreach (var recipeItem in recipeModel.RecipeItems.Select(item => new PRD_RecipeItem
                            {
                                RecipeID = currentRecipeId,
                                ItemID = item.ItemID,
                                RequiredQty = item.RequiredQty,
                                UnitID = item.UnitID,
                                SetOn = DateTime.Now,
                                SetBy = userId,
                                IPAddress = GetIPAddress.LocalIPAddress()
                            }))
                            {
                                _context.PRD_RecipeItem.Add(recipeItem);
                                _context.SaveChanges();
                            }
                        }
                    }
                    tx.Complete();

                    _vmMsg.Type       = Enums.MessageType.Success;
                    _vmMsg.Msg        = "Saved Successfully.";
                    _vmMsg.ReturnId   = currentRecipeId;
                    _vmMsg.ReturnCode = currentCode;
                }
            }
            catch (Exception)
            {
                _vmMsg.Type = Enums.MessageType.Error;
                _vmMsg.Msg  = "Failed to save.";
            }
            return(_vmMsg);
        }
Beispiel #11
0
        public long Save(ExpBankVoucher model, int userId, string pageUrl)
        {
            long CurrentBVID = 0;


            using (TransactionScope transaction = new TransactionScope())
            {
                try
                {
                    using (_context)
                    {
                        var AutoBVNo = DalCommon.GetPreDefineNextCodeByUrl(pageUrl);

                        //Random r = new Random();
                        //var AutoBVNo = r.Next();

                        if (AutoBVNo != null)
                        {
                            #region New_Voucher_Insert

                            EXP_BankVoucher objVoucher = new EXP_BankVoucher();


                            objVoucher.BVNo    = AutoBVNo.ToString();
                            objVoucher.RefBVNo = model.RefBVNo;
                            objVoucher.BVDate  = DalCommon.SetDate(model.BVDate);
                            objVoucher.BVType  = model.BVType;

                            objVoucher.BankID   = model.BankID;
                            objVoucher.BranchID = model.BranchID;
                            objVoucher.ACName   = model.ACName;
                            objVoucher.ACNo     = model.ACNo;
                            objVoucher.Remarks  = model.Remarks;

                            objVoucher.RecordStatus = "NCF";
                            objVoucher.SetBy        = userId;
                            objVoucher.SetOn        = DateTime.Now;

                            _context.EXP_BankVoucher.Add(objVoucher);
                            _context.SaveChanges();
                            CurrentBVID = objVoucher.BVID;
                            #endregion
                        }

                        #region Item Insert
                        if (model.EXPBankVoucherDtl != null)
                        {
                            foreach (var item in model.EXPBankVoucherDtl)
                            {
                                EXP_BankVoucherDtl objItem = new EXP_BankVoucherDtl();

                                objItem.BVID    = CurrentBVID;
                                objItem.TransSL = item.TransSL;

                                objItem.Narration = item.Narration;
                                objItem.TransHead = item.TransHead;
                                objItem.BVCRAmt   = item.BVCRAmt;
                                objItem.BVDRAmt   = item.BVDRAmt;

                                if (item.CurrencyName != null)
                                {
                                    objItem.Currency = DalCommon.GetCurrencyID(item.CurrencyName);
                                }

                                if (item.ExchangeCurrencyName != null)
                                {
                                    objItem.ExchangeCurrency = DalCommon.GetCurrencyID(item.ExchangeCurrencyName);
                                }

                                objItem.ExchangeRate   = item.ExchangeRate;
                                objItem.ExchangeAmount = item.ExchangeAmount;
                                objItem.CIID           = item.CIID;



                                objItem.SetOn = DateTime.Now;
                                objItem.SetBy = userId;

                                _context.EXP_BankVoucherDtl.Add(objItem);
                                //_context.SaveChanges();
                            }
                        }
                        #endregion

                        _context.SaveChanges();
                    }
                    transaction.Complete();
                }
                catch (Exception e)
                {
                    CurrentBVID = 0;
                    return(CurrentBVID);
                }
            }
            return(CurrentBVID);
        }
Beispiel #12
0
        public long Save(INVStoreTrans model, int userId, string pageUrl)
        {
            long CurrentTransactionID = 0;

            try
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    using (_context)
                    {
                        var GetTransactionNo = DalCommon.GetPreDefineNextCodeByUrl(pageUrl);

                        if (GetTransactionNo != null)
                        {
                            #region New_Transaction_Insert

                            INV_StoreTrans objIssue = new INV_StoreTrans();

                            objIssue.TransactionNo       = GetTransactionNo;
                            objIssue.TransactionDate     = DalCommon.SetDate(model.TransactionDate);
                            objIssue.TransactionCategory = "ISU";
                            objIssue.TransactionType     = "STI";
                            objIssue.TransactionFrom     = model.IssueFrom;
                            objIssue.TransactionTo       = model.IssueTo;

                            objIssue.TransactionStatus = "TRI";


                            objIssue.RecordStatus = "NCF";
                            objIssue.SetBy        = userId;
                            objIssue.SetOn        = DateTime.Now;

                            _context.INV_StoreTrans.Add(objIssue);
                            _context.SaveChanges();
                            CurrentTransactionID = objIssue.TransactionID;
                            #endregion

                            #region Item Insert
                            if (model.TransactionItemList != null)
                            {
                                foreach (var item in model.TransactionItemList)
                                {
                                    INV_StoreTransItem objItem = new INV_StoreTransItem();

                                    objItem.TransactionID = CurrentTransactionID;

                                    objItem.ItemID     = item.ItemID;
                                    objItem.SupplierID = item.SupplierID;

                                    objItem.TransactionQty = item.IssueQty;

                                    objItem.TransactionUnit = DalCommon.GetUnitCode(item.IssueUnitName);


                                    objItem.PackSize = DalCommon.GetSizeCode(item.IssuePackSizeName);
                                    objItem.SizeUnit = DalCommon.GetUnitCode(item.IssueSizeUnitName);


                                    objItem.PackQty = item.IssuePackQty;
                                    //objItem.ItemSource = DalCommon.ReturnItemSource(item.ItemSource);
                                    objItem.SetOn = DateTime.Now;
                                    objItem.SetBy = userId;

                                    _context.INV_StoreTransItem.Add(objItem);
                                    //_context.SaveChanges();
                                }
                            }
                            #endregion
                        }
                        _context.SaveChanges();
                    }
                    transaction.Complete();
                }
                return(CurrentTransactionID);
            }
            catch (Exception e)
            {
                return(0);
            }
        }
Beispiel #13
0
        private INV_CrustLeatherIssue ConvertIssue(InvCrustLeatherIssue model, int userId, string url)
        {
            var entity = model.CrustLeatherIssueID == 0 ? new INV_CrustLeatherIssue() : (from b in _context.INV_CrustLeatherIssue.AsEnumerable()
                                                                                         where b.CrustLeatherIssueID == model.CrustLeatherIssueID
                                                                                         select b).FirstOrDefault();

            entity.CrustLeatherIssueID   = model.CrustLeatherIssueID;
            entity.CrustLeatherIssueNo   = model.CrustLeatherIssueNo ?? DalCommon.GetPreDefineNextCodeByUrl(url);
            entity.CrustLeatherIssueDate = model.CrustLeatherIssueDate == null ? DateTime.Now : DalCommon.SetDate(model.CrustLeatherIssueDate);
            entity.IssueCategory         = model.IssueCategory;
            entity.IssueFor     = model.IssueFor;
            entity.IssueFrom    = model.IssueFrom;
            entity.IssueTo      = model.IssueTo;
            entity.RecordStatus = model.RecordStatus ?? "NCF";
            entity.SetOn        = model.CrustLeatherIssueID == 0
                ? DateTime.Now
                : _unit.CrustLeatherIssue.GetByID(model.CrustLeatherIssueID).SetOn;
            entity.SetBy = model.CrustLeatherIssueID == 0
                ? userId
                : _unit.CrustLeatherIssue.GetByID(model.CrustLeatherIssueID).SetBy;
            entity.ModifiedOn = model.CrustLeatherIssueID == 0 ? (DateTime?)null : DateTime.Now;
            entity.ModifiedBy = model.CrustLeatherIssueID == 0 ? (int?)null : userId;
            #region New Code

            //var put = entity.INV_CrustLeatherReceiveItem;
            //if (model.Items.Count > 0)
            //{
            //    foreach (var item in model.Items)
            //    {
            //        put.CrustLeatherIssueItemID = item.CrustLeatherIssueItemID;
            //        put.CrustLeatherIssueID = entity.CrustLeatherIssueID;
            //        put.RequisitionDateID = item.RequisitionDateID ?? null;
            //        //entity.RequisitionNo = null;
            //        put.CrustQCLabel = item.CrustQCLabel ?? null;
            //        put.BuyerID = item.BuyerID;
            //        put.BuyerOrderID = item.BuyerOrderID;
            //        put.ArticleID = item.ArticleID;
            //        put.ArticleNo = item.ArticleNo;
            //        put.ArticleChallanID = item.ArticleChallanID;
            //        put.ArticleChallanNo = item.ArticleChallanNo;
            //        put.ItemTypeID = item.ItemTypeID;
            //        put.LeatherTypeID = item.LeatherTypeID;
            //        put.LeatherStatusID = item.LeatherStatusID;
            //        put.SetOn = item.CrustLeatherIssueItemID == 0
            //            ? DateTime.Now
            //            : _unit.CrustLeatherIssueItem.GetByID(item.CrustLeatherIssueItemID).SetOn;
            //        entity.SetBy = item.CrustLeatherIssueItemID == 0
            //            ? userId
            //            : _unit.CrustLeatherIssueItem.GetByID(item.CrustLeatherIssueItemID).SetBy;
            //        entity.ModifiedOn = item.CrustLeatherIssueItemID == 0 ? (DateTime?)null : DateTime.Now;
            //        entity.ModifiedBy = item.CrustLeatherIssueItemID == 0 ? (int?)null : userId;

            //        var col = new INV_CrustLeatherIssueColor();
            //        if (item.Colors.Count > 0)
            //        {
            //            foreach (var color in item.Colors)
            //            {
            //                entity.CrustLeatherIssueColorID = model.CrustLeatherIssueColorID;
            //                entity.CrustLeatherIssueItemID = itemId;
            //                entity.CrustLeatherIssueID = issueId;
            //                entity.ArticleColorNo = entity.ArticleColorNo;
            //                entity.ColorID = model.ColorID;
            //                entity.GradeID = model.GradeID;
            //                entity.GradeRange = model.GradeRange;
            //                entity.CrustQCLabel = model.CrustQCLabel;
            //                entity.IssuePcs = model.IssuePcs ?? 0;
            //                entity.IssueSide = model.IssueSide ?? 0;
            //                entity.IssueArea = model.IssueArea ?? 0;
            //                entity.SideArea = model.SideArea;
            //                entity.AreaUnit = model.AreaUnit;
            //                entity.SetOn = model.CrustLeatherIssueColorID == 0
            //                    ? DateTime.Now
            //                    : _unit.CrustLeatherIssueColor.GetByID(model.CrustLeatherIssueColorID).SetOn;
            //                entity.SetBy = model.CrustLeatherIssueColorID == 0
            //                    ? userId
            //                    : _unit.CrustLeatherIssueColor.GetByID(model.CrustLeatherIssueColorID).SetBy;
            //                entity.ModifiedBy = model.CrustLeatherIssueColorID == 0 ? (int?)null : userId;
            //                entity.ModifiedOn = model.CrustLeatherIssueColorID == 0 ? (DateTime?)null : DateTime.Now;
            //                return entity;
            //            }
            //        }
            //    }

            //}
            #endregion
            return(entity);
        }
        public ValidationMsg Save(InvFinishLeatherReceive model, int userid, string pageUrl)
        {
            _vmMsg = new ValidationMsg();
            try
            {
                using (var tx = new TransactionScope())
                {
                    using (_context)
                    {
                        model.FNReceiveNo = DalCommon.GetPreDefineNextCodeByUrl(pageUrl);//DalCommon.GetPreDefineValue("1", "00045");
                        if (model.FNReceiveNo != null)
                        {
                            #region Save Finish Leather Receive Data

                            INV_FinishLeatherReceive tblFinishLeatherReceive = SetToModelObject(model, userid);
                            _context.INV_FinishLeatherReceive.Add(tblFinishLeatherReceive);
                            _context.SaveChanges();
                            #endregion

                            #region Save Finish Leather Receive Item Data
                            if (model.InvFinishLeatherReceiveItemList != null)
                            {
                                foreach (InvFinishLeatherReceiveItem objFinishLeatherReceiveItem in model.InvFinishLeatherReceiveItemList)
                                {
                                    objFinishLeatherReceiveItem.FNReceiveID = tblFinishLeatherReceive.FNReceiveID;
                                    INV_FinishLeatherReceiveItem tblFinishLeatherReceiveItem = SetToIssueItemModelObject(objFinishLeatherReceiveItem, userid);
                                    _context.INV_FinishLeatherReceiveItem.Add(tblFinishLeatherReceiveItem);
                                    _context.SaveChanges();

                                    #region Save Finish Leather Receive Color Data

                                    if (model.InvFinishLeatherReceiveColorList != null)
                                    {
                                        if (objFinishLeatherReceiveItem.FNReceiveItemID != null)
                                        {
                                            foreach (InvFinishLeatherReceiveColor objFinishLeatherReceiveColor in model.InvFinishLeatherReceiveColorList)
                                            {
                                                objFinishLeatherReceiveColor.FNReceiveID     = tblFinishLeatherReceiveItem.FNReceiveID;
                                                objFinishLeatherReceiveColor.FNReceiveItemID = tblFinishLeatherReceiveItem.FNReceiveItemID;


                                                INV_FinishLeatherReceiveColor tblFinishLeatherReceiveColor = SetToReceiveColorModelObject(objFinishLeatherReceiveColor, userid);
                                                _context.INV_FinishLeatherReceiveColor.Add(tblFinishLeatherReceiveColor);
                                                _context.SaveChanges();
                                            }
                                        }
                                    }
                                    #endregion
                                }
                            }
                            #endregion

                            _context.SaveChanges();

                            tx.Complete();
                            //FNReceiveID = tblFinishLeatherReceive.FNReceiveID;
                            //FNReceiveNo = tblFinishLeatherReceive.FNReceiveNo;

                            _vmMsg.Type = Enums.MessageType.Success;
                            _vmMsg.Msg  = "Saved Successfully.";
                        }
                        else
                        {
                            _vmMsg.Type = Enums.MessageType.Error;
                            _vmMsg.Msg  = "Crust Leather No Predefine Value not Found.";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException.InnerException.Message.Contains("UNIQUE KEY"))
                {
                    _vmMsg.Type = Enums.MessageType.Error;
                    _vmMsg.Msg  = "Crust Leather No Data Already Exit.";
                }
                _vmMsg.Type = Enums.MessageType.Error;
                _vmMsg.Msg  = "Failed to save.";
            }
            return(_vmMsg);
        }
Beispiel #15
0
        public ValidationMsg SaveLCM_CnFBill(CnFBill dataSet, int _userId, string pageUrl)
        {
            try
            {
                LCM_CnfBill obLcCnFBill = new LCM_CnfBill();

                obLcCnFBill.LCID = dataSet.LCID;
                obLcCnFBill.LCNo = dataSet.LCNo == null ? "" : dataSet.LCNo;//DalCommon.GetPreDefineNextCodeByUrl(pageUrl);

                obLcCnFBill.CIID = dataSet.CIID;
                obLcCnFBill.CINo = dataSet.CINo == null ? "" : dataSet.CINo;


                obLcCnFBill.CnfBillID = dataSet.CnfBillID;
                //obLcCnFBill.CnfBillNo = dataSet.CnfBillNo==null?"":dataSet.CnfBillNo;
                obLcCnFBill.CnfBillNo    = DalCommon.GetPreDefineNextCodeByUrl(pageUrl);
                obLcCnFBill.RefCnfBillNo = dataSet.RefCnfBillNo == null ? "" : dataSet.RefCnfBillNo;
                obLcCnFBill.CnfBillDate  = dataSet.CnfBillDate == null ? (DateTime?)null : DalCommon.SetDate(dataSet.CnfBillDate);
                obLcCnFBill.CnfBillNote  = dataSet.CnfBillNote == null ? "" : (string)dataSet.CnfBillNote;

                obLcCnFBill.DutyAccountCharge     = dataSet.DutyAccountCharge == null ? 0 : (decimal)dataSet.DutyAccountCharge;
                obLcCnFBill.CnfAgentID            = dataSet.CnfAgentID == null ? 0 : obEntity.Sys_Buyer.Where(m => m.BuyerID == dataSet.CnfAgentID).FirstOrDefault().BuyerID; //dataSet.CnfAgentID;
                obLcCnFBill.PortCharge            = dataSet.PortCharge == null ? 0 : (decimal)dataSet.PortCharge;
                obLcCnFBill.NOCCharge             = dataSet.NOCCharge == null ? 0 : (decimal)dataSet.NOCCharge;
                obLcCnFBill.BerthOperatorCharge   = dataSet.BerthOperatorCharge == null ? 0 : (decimal)dataSet.BerthOperatorCharge;
                obLcCnFBill.AmendmentCharge       = dataSet.AmendmentCharge == null ? 0 : (decimal)dataSet.AmendmentCharge;
                obLcCnFBill.AgencyCommission      = dataSet.AgencyCommission == null ? 0 : (decimal)dataSet.AgencyCommission;
                obLcCnFBill.ChemicalTestCharge    = dataSet.ChemicalTestCharge == null ? 0 : (decimal)dataSet.ChemicalTestCharge;
                obLcCnFBill.ExamineCharge         = dataSet.ExamineCharge == null ? 0 : (decimal)dataSet.ExamineCharge;
                obLcCnFBill.SpecialDeliveryCharge = dataSet.SpecialDeliveryCharge == null ? 0 : (decimal)dataSet.SpecialDeliveryCharge;
                obLcCnFBill.ShippingCharge        = dataSet.ShippingCharge == null ? 0 : (decimal)dataSet.ShippingCharge;
                obLcCnFBill.StampCharge           = dataSet.StampCharge == null ? 0 : (decimal)dataSet.StampCharge;
                obLcCnFBill.BLVerifyCharge        = dataSet.BLVerifyCharge == null ? 0 : (decimal)dataSet.BLVerifyCharge; //OtherCharge
                obLcCnFBill.OtherCharge           = dataSet.OtherCharge == null ? 0 : (decimal)dataSet.OtherCharge;       //
                obLcCnFBill.TotalAmount           = dataSet.TotalAmount == null ? 0 : (decimal)dataSet.TotalAmount;       //(decimal)dataSet.TotalAmount;
                obLcCnFBill.BillOfEntryNo         = dataSet.BillOfEntryNo == null ? "" : dataSet.BillOfEntryNo;;
                obLcCnFBill.BillOfEntryDate       = dataSet.BillOfEntryDate == null ? (DateTime?)null : DalCommon.SetDate(dataSet.BillOfEntryDate);
                obLcCnFBill.AssesmentValue        = dataSet.AssesmentValue == null ? 0 : (decimal)dataSet.AssesmentValue;//Convert.ToDecimal(dataSet.AssesmentValue)==null? 0 :dataSet.AssesmentValue;
                obLcCnFBill.CnfBillCurrency       = dataSet.CnfBillCurrency == null ? 0 : dataSet.CnfBillCurrency;
                obLcCnFBill.BillOfEntryNo         = (string)dataSet.BillOfEntryNo == null ? "" : dataSet.BillOfEntryNo;
                obLcCnFBill.ExchangeCurrency      = (byte)(dataSet.ExchangeCurrency) == null ? 0 : dataSet.ExchangeCurrency;
                obLcCnFBill.ExchangeRate          = dataSet.ExchangeRate == null ? 0 : (decimal)dataSet.ExchangeRate;
                obLcCnFBill.ExchangeValue         = dataSet.ExchangeValue == null ? 0 : (decimal)dataSet.ExchangeValue;
                obLcCnFBill.RecordStatus          = "NCF";
                obLcCnFBill.Remarks = dataSet.Remarks == null ? "" : dataSet.Remarks;


                obLcCnFBill.SetOn = DateTime.Now;

                obLcCnFBill.SetBy      = 1;
                obLcCnFBill.ModifiedOn = DateTime.Now;
                obLcCnFBill.ModifiedBy = _userId;
                obLcCnFBill.IPAddress  = GetIPAddress.LocalIPAddress();
                obEntity.LCM_CnfBill.Add(obLcCnFBill);
                int flag = obEntity.SaveChanges();
                if (flag == 1)
                {
                    //_vmMsg.ReturnId =  repository.LcmCnFBillRpository.Get().Last().CnfBillID;//dataSet.CnfBillID;
                    _vmMsg.ReturnCode = obLcCnFBill.CnfBillNo;
                    _vmMsg.Type       = Enums.MessageType.Success;
                    _vmMsg.Msg        = "Saved Successfully.";
                }
                else
                {
                    _vmMsg.Type = Enums.MessageType.Error;
                    _vmMsg.Msg  = "Saved Faild.";
                }
            }
            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);
        }
Beispiel #16
0
        public long Save(INVStoreTrans model, int userId, string pageUrl)
        {
            long CurrentTransactionID = 0;
            long CurrentRequestID     = 0;

            using (TransactionScope transaction = new TransactionScope())
            {
                try
                {
                    using (_context)
                    {
                        string GetTransactionNo;
                        if (model.PageName == "Adjustment")
                        {
                            GetTransactionNo = DalCommon.GetPreDefineNextCodeByUrl("ChemicalStockAdjustment/ChemicalStockAdjustment");
                        }
                        else if (model.PageName == "InventoryAdjustment")
                        {
                            //Need Attention
                            GetTransactionNo = DalCommon.GetPreDefineNextCodeByUrl("ChemicalStockAdjustment/ChemicalStockAdjustment");
                        }
                        else
                        {
                            GetTransactionNo = DalCommon.GetPreDefineNextCodeByUrl(pageUrl);
                        }


                        if (GetTransactionNo != null)
                        {
                            #region New_Transaction_Insert

                            INV_StoreTrans objIssue = new INV_StoreTrans();

                            objIssue.TransactionNo   = GetTransactionNo;
                            objIssue.TransactionDate = DalCommon.SetDate(model.TransactionDate);
                            if (model.AdjustmentType == "Addition")
                            {
                                objIssue.TransactionCategory = "RCV";
                            }
                            else
                            {
                                objIssue.TransactionCategory = "ISU";
                            }


                            objIssue.TransactionFrom = model.TransactionFrom;


                            if (model.PageName == "Adjustment")
                            {
                                objIssue.TransactionType = "ADI";
                            }
                            else if (model.PageName == "InventoryAdjustment" & model.AdjustmentType == "Addition")
                            {
                                objIssue.TransactionType = "ADR";
                            }
                            else if (model.PageName == "InventoryAdjustment" & model.AdjustmentType == "Subtraction")
                            {
                                objIssue.TransactionType = "ADI";
                            }
                            else
                            {
                                objIssue.TransactionType = "ITP";
                                objIssue.TransactionTo   = model.TransactionTo;
                            }


                            objIssue.RecordStatus      = "NCF";
                            objIssue.TransactionState  = "RNG";
                            objIssue.TransactionStatus = "TRI";
                            objIssue.SetBy             = userId;
                            objIssue.SetOn             = DateTime.Now;

                            _context.INV_StoreTrans.Add(objIssue);
                            _context.SaveChanges();
                            CurrentTransactionID = objIssue.TransactionID;

                            #endregion

                            #region New Transaction Request Insert
                            if (model.PageName != "InventoryAdjustment")
                            {
                                var objRequest = new INV_StoreTransRequest();

                                objRequest.TransRequestNo = DalCommon.GetPreDefineNextCodeByUrl(pageUrl);
                                objRequest.TransactionID  = CurrentTransactionID;

                                if (model.PageName == "Adjustment")
                                {
                                    objRequest.ReqFromDate = DalCommon.SetDate(model.ReqFromDate);
                                    objRequest.ReqToDate   = DalCommon.SetDate(model.ReqToDate);
                                }
                                else
                                {
                                    objRequest.RequisitionID = Convert.ToInt32(model.RefTransactionID);
                                    objRequest.RequestNo     = model.RefTransactionNo;
                                }
                                objRequest.Remark = model.Remark;
                                objRequest.SetBy  = userId;
                                objRequest.SetOn  = DateTime.Now;

                                _context.INV_StoreTransRequest.Add(objRequest);
                                _context.SaveChanges();
                                CurrentRequestID = objRequest.TransRequestID;
                            }

                            #endregion

                            #region Item Insert
                            if (model.InvStoreTransItemList != null)
                            {
                                foreach (var item in model.InvStoreTransItemList)
                                {
                                    INV_StoreTransItem objItem = new INV_StoreTransItem();

                                    objItem.TransactionID = CurrentTransactionID;

                                    if (model.PageName != "InventoryAdjustment")
                                    {
                                        objItem.TransRequestID = CurrentRequestID;
                                    }

                                    objItem.ItemID = item.ItemID;
                                    if (item.SupplierID == 0)
                                    {
                                        objItem.SupplierID = null;
                                    }
                                    else
                                    {
                                        objItem.SupplierID = item.SupplierID;
                                    }
                                    objItem.TransactionQty = item.TransactionQty;

                                    objItem.TransactionUnit = DalCommon.GetUnitCode(item.TransactionUnitName);


                                    if (item.PackSizeName != null)
                                    {
                                        objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName);
                                    }

                                    if (item.SizeUnitName != null)
                                    {
                                        objItem.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName);
                                    }
                                    objItem.PackQty = item.PackQty;

                                    objItem.SetOn = DateTime.Now;
                                    objItem.SetBy = userId;

                                    _context.INV_StoreTransItem.Add(objItem);
                                    //_context.SaveChanges();
                                }
                            }
                            #endregion
                        }
                        _context.SaveChanges();
                    }
                    transaction.Complete();
                }
                catch (Exception e)
                {
                    CurrentTransactionID = 0;
                    return(CurrentTransactionID);
                }
            }
            return(CurrentTransactionID);
        }
        private EXP_FreightBill CovertModel(ExpFreightBill model, int userId, string url)
        {
            var entity = model.FreightBillID == 0
                ? new EXP_FreightBill()
                : (from b in _context.EXP_FreightBill.AsEnumerable()
                   where b.FreightBillID == model.FreightBillID
                   select b).FirstOrDefault();

            entity.FreightBillID   = model.FreightBillID;
            entity.FreightBillNo   = model.FreightBillNo ?? DalCommon.GetPreDefineNextCodeByUrl(url);
            entity.FreightBillRef  = model.FreightBillRef;
            entity.FreightBillDate = model.FreightBillDate == null ? (DateTime?)null : DalCommon.SetDate(model.FreightBillDate);
            entity.LCID            = model.LCID;
            entity.CIID            = model.CIID;
            entity.PIID            = model.PIID;
            entity.BLID            = model.BLID;
            entity.FreightAgentID  = model.FreightAgentID;
            //entity.NotifyTo = model.NotifyTo;
            entity.MSNo                = model.MSNo;
            entity.MSDate              = model.MSDate == null ? (DateTime?)null : DalCommon.SetDate(model.MSDate);
            entity.ShipmentOf          = model.ShipmentOf;
            entity.ShipmentFrom        = model.ShipmentFrom;
            entity.ShipmentTo          = model.ShipmentTo;
            entity.WBNo                = model.WBNo;
            entity.WBDate              = model.WBDate == null ? (DateTime?)null : DalCommon.SetDate(model.WBDate);
            entity.FreightWeight       = model.FreightWeight;
            entity.FreightRate         = model.FreightRate;
            entity.FreightValue        = model.FreightValue;
            entity.FreightBillCurrency = model.FreightBillCurrency;
            entity.ExchangeCurrency    = model.ExchangeCurrency;
            entity.ExchangeRate        = model.ExchangeRate;
            entity.ExchangeValue       = model.ExchangeValue;
            //entity.THCharge = model.THCharge;
            entity.AirWayBill         = model.AirWayBill;
            entity.FCSMYCCharge       = model.FCSMYCCharge;
            entity.SSCMCCCharge       = model.SSCMCCCharge;
            entity.OtherCharge        = model.OtherCharge;
            entity.LocalCarringCharge = model.LocalCarringCharge;
            entity.CustomCharge       = model.CustomCharge;
            entity.VATAsReceipt       = model.VATAsReceipt;
            entity.LoadUnloadCharge   = model.LoadUnloadCharge;
            //entity.GSPEXpence = model.GSPEXpence;
            entity.AgencyCommision       = model.AgencyCommision;
            entity.SpecialDeliveryCharge = model.SpecialDeliveryCharge;
            entity.TotalAmt = model.TotalAmt;
            //entity.AdvanceAmt = model.AdvanceAmt;
            //entity.NetFreightAmt = model.NetFreightAmt;
            entity.TrminalCharge   = model.TrminalCharge;
            entity.ExamineCharge   = model.ExamineCharge;
            entity.AmendmentCharge = model.AmendmentCharge;
            entity.RecordStatus    = model.RecordStatus ?? "NCF";
            entity.SetOn           = model.FreightBillID == 0
                ? DateTime.Now
                : _unit.FreightBillRepository.GetByID(model.FreightBillID).SetOn;
            entity.SetBy = model.FreightBillID == 0
                ? userId
                : _unit.FreightBillRepository.GetByID(model.FreightBillID).SetBy;
            entity.ModifiedBy = model.FreightBillID == 0 ? (int?)null : userId;
            entity.ModifiedOn = model.FreightBillID == 0 ? (DateTime?)null : DateTime.Now;

            return(entity);
        }
Beispiel #18
0
        public ValidationMsg Save(EXPPackingList model, int userid, string pageUrl)
        {
            _vmMsg = new ValidationMsg();
            try
            {
                #region Save

                using (var tx = new TransactionScope())
                {
                    using (_context)
                    {
                        model.PLNo = DalCommon.GetPreDefineNextCodeByUrl(pageUrl);//DalCommon.GetPreDefineValue("1", "00045");
                        if (model.PLNo != null)
                        {
                            #region CI

                            EXP_PackingList tblEXPPackingList = SetToModelObject(model, userid);
                            _context.EXP_PackingList.Add(tblEXPPackingList);
                            _context.SaveChanges();

                            #endregion

                            #region CIPI

                            model.EXPPLPIList[0].PLID = tblEXPPackingList.PLID;
                            EXP_PLPI tblEXPPLPI = SetToModelObject(model.EXPPLPIList[0], userid);
                            _context.EXP_PLPI.Add(tblEXPPLPI);
                            _context.SaveChanges();

                            #endregion

                            #region CIPIItem

                            if (model.EXPPLPIItemColorList != null)
                            {
                                foreach (EXPPLPIItemColor objEXPPLPIItemColor in model.EXPPLPIItemColorList)
                                {
                                    objEXPPLPIItemColor.PLPIID = tblEXPPLPI.PLPIID;

                                    EXP_PLPIItemColor tblEXPCIPIItem = SetToModelObject(objEXPPLPIItemColor, userid);
                                    _context.EXP_PLPIItemColor.Add(tblEXPCIPIItem);
                                    _context.SaveChanges();

                                    #region CIPIItemColor

                                    if (model.EXPPLPIItemColorBaleList != null)
                                    {
                                        if ((objEXPPLPIItemColor.ArticleID == model.EXPPLPIItemColorBaleList[0].ArticleID) && (objEXPPLPIItemColor.ColorID == model.EXPPLPIItemColorBaleList[0].ColorID))
                                        {
                                            foreach (EXPPLPIItemColorBale objEXPCIPIItemColor in model.EXPPLPIItemColorBaleList)
                                            {
                                                objEXPCIPIItemColor.PLPIItemColorID = tblEXPCIPIItem.PLPIItemColorID;
                                                EXP_PLPIItemColorBale tblEXPCIPIItemColor = SetToModelObject(objEXPCIPIItemColor, userid);
                                                _context.EXP_PLPIItemColorBale.Add(tblEXPCIPIItemColor);
                                            }
                                        }
                                    }
                                    #endregion
                                }
                            }

                            #endregion

                            _context.SaveChanges();
                            tx.Complete();

                            PLID        = tblEXPPackingList.PLID;
                            PLNo        = model.PLNo;
                            PLPIID      = tblEXPPLPI.PLPIID;
                            _vmMsg.Type = Enums.MessageType.Success;
                            _vmMsg.Msg  = "Saved Successfully.";
                        }
                        else
                        {
                            _vmMsg.Type = Enums.MessageType.Error;
                            _vmMsg.Msg  = "PLNo Predefine Value not Found.";
                        }
                    }
                }

                //#region CIPIItemColor

                //if (model.EXPPLPIItemColorBaleList != null)
                //{
                //    //if ((objEXPPLPIItemColor.ArticleID == model.EXPPLPIItemColorBaleList[0].ArticleID) && (objEXPPLPIItemColor.ColorID == model.EXPPLPIItemColorBaleList[0].ColorID))
                //    //{
                //    foreach (EXPPLPIItemColorBale objEXPCIPIItemColor in model.EXPPLPIItemColorBaleList)
                //    {
                //        objEXPCIPIItemColor.PLPIItemColorID = 5;// tblEXPCIPIItem.PLPIItemColorID;
                //        objEXPCIPIItemColor.Remarks = "";// tblEXPCIPIItem.PLPIItemColorID;
                //        if (string.IsNullOrEmpty(objEXPCIPIItemColor.GradeName))
                //            objEXPCIPIItemColor.GradeID = null;
                //        else
                //            objEXPCIPIItemColor.GradeID = 5;// _context.Sys_Grade.Where(m => m.GradeName == objEXPCIPIItemColor.GradeName).FirstOrDefault().GradeID;

                //        if (string.IsNullOrEmpty(objEXPCIPIItemColor.GrossBaleWeightUnitName))
                //        {
                //            objEXPCIPIItemColor.NetWeightUnit = null;
                //            objEXPCIPIItemColor.GrossBaleWeightUnit = null;
                //        }
                //        else
                //        {
                //            objEXPCIPIItemColor.NetWeightUnit = 5;// _context.Sys_Unit.Where(m => m.UnitName == objEXPCIPIItemColor.GrossBaleWeightUnitName).FirstOrDefault().UnitID;
                //            objEXPCIPIItemColor.GrossBaleWeightUnit = 5;// objEXPCIPIItemColor.NetWeightUnit;// _context.Sys_Unit.Where(m => m.UnitName == objEXPCIPIItemColor.GrossBaleWeightUnitName).FirstOrDefault().UnitID;
                //        }

                //        SqlConnection con = new SqlConnection(_connString);
                //        //SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionDB"].ToString());
                //        con.Open();
                //        string query = "UspInsertPLColorBale";         //Stored Procedure name
                //        //cmd.Connection = conn;
                //        //cmd.CommandText = "UspConfirmWetBlueIssue";
                //        SqlCommand com = new SqlCommand(query, con);  //creating  SqlCommand  object
                //        com.CommandType = CommandType.StoredProcedure;  //here we declaring command type as stored Procedure

                //        com.Parameters.AddWithValue("@PLPIItemColorBaleNo", objEXPCIPIItemColor.PLPIItemColorBaleNo);
                //        com.Parameters.AddWithValue("@PLPIItemColorID", objEXPCIPIItemColor.PLPIItemColorID);
                //        com.Parameters.AddWithValue("@GradeID", objEXPCIPIItemColor.GradeID);
                //        com.Parameters.AddWithValue("@PcsInBale", objEXPCIPIItemColor.PcsInBale);
                //        com.Parameters.AddWithValue("@SideInBale", objEXPCIPIItemColor.SideInBale);
                //        com.Parameters.AddWithValue("@FootPLPIBaleQty", objEXPCIPIItemColor.FootPLPIBaleQty);
                //        com.Parameters.AddWithValue("@MeterPLPIBaleQty", objEXPCIPIItemColor.MeterPLPIBaleQty);
                //        com.Parameters.AddWithValue("@PLPIBaleNetWeight", objEXPCIPIItemColor.PLPIBaleNetWeight);
                //        com.Parameters.AddWithValue("@PLPIBGrossaleWeight", objEXPCIPIItemColor.PLPIBGrossaleWeight);
                //        com.Parameters.AddWithValue("@NetWeightUnit", objEXPCIPIItemColor.NetWeightUnit);
                //        com.Parameters.AddWithValue("@GrossBaleWeightUnit", objEXPCIPIItemColor.GrossBaleWeightUnit);
                //        com.Parameters.AddWithValue("@Remarks", objEXPCIPIItemColor.Remarks);

                //        com.ExecuteNonQuery();

                //        //EXP_PLPIItemColorBale tblEXPCIPIItemColor = SetToModelObject(objEXPCIPIItemColor, userid);
                //        //_context.EXP_PLPIItemColorBale.Add(tblEXPCIPIItemColor);
                //    }
                //    //}
                //}
                //#endregion

                #endregion
            }
            catch (Exception ex)
            {
                _vmMsg.Type = Enums.MessageType.Error;
                _vmMsg.Msg  = "Failed to save.";
                if (ex.InnerException.InnerException.Message.Contains("UNIQUE KEY"))
                {
                    _vmMsg.Type = Enums.MessageType.Error;
                    _vmMsg.Msg  = "Packinglist No Already Exit.";
                }
            }
            return(_vmMsg);
        }
Beispiel #19
0
        public ValidationMsg SaveData(PrqChemPurcReq modelReq, int userId, string pageUrl)
        {
            try
            {
                using (var tx = new TransactionScope())
                {
                    var currentRequisitionId   = 0;
                    var currentRequisitionCode = DalCommon.GetPreDefineNextCodeByUrl(pageUrl);
                    //var currentRequisitionCode = DalCommon.GetPreDefineValue("1", "00051");
                    using (_context)
                    {
                        var chemPurcReq = new PRQ_ChemPurcReq
                        {
                            RequisitionNo       = currentRequisitionCode,
                            RequisitionCategory = modelReq.RequisitionCategory,
                            RequisitionType     = modelReq.RequisitionType,
                            ReqRaisedOn         = DalCommon.SetDate(modelReq.ReqRaisedOn),
                            RequisitionFrom     = modelReq.RequisitionFrom,
                            RequisitionTo       = modelReq.RequisitionTo,
                            RequiredByTime      = modelReq.RequiredByTime,
                            ReqRaisedBy         = modelReq.ReqRaisedBy,
                            RecordStatus        = "NCF",
                            RequisitionState    = "RNG",
                            SetOn     = DateTime.Now,
                            SetBy     = userId,
                            IPAddress = GetIPAddress.LocalIPAddress()
                        };
                        _context.PRQ_ChemPurcReq.Add(chemPurcReq);
                        _context.SaveChanges();

                        currentRequisitionId = chemPurcReq.RequisitionID;

                        if (modelReq.ChemPurcReqItems != null)
                        {
                            foreach (var chemItem in modelReq.ChemPurcReqItems.Select(item => new PRQ_ChemPurcReqItem()
                            {
                                RequisitionID = currentRequisitionId,
                                ItemID = item.ItemID,
                                SupplierID = modelReq.RequisitionTo,
                                PackSize = item.SizeID,
                                SizeUnit = item.PackUnitID,
                                PackQty = item.PackQty,
                                RequsitionQty = item.RequisitionQty,
                                RequisitionUnit = item.RequisitionUnit,
                                ManufacturerID = item.ManufacturerID,
                                SetOn = DateTime.Now,
                                SetBy = userId
                            }))
                            {
                                _context.PRQ_ChemPurcReqItem.Add(chemItem);
                                _context.SaveChanges();
                            }
                        }
                    }
                    tx.Complete();

                    _vmMsg.Type       = Enums.MessageType.Success;
                    _vmMsg.Msg        = "Saved Successfully.";
                    _vmMsg.ReturnId   = currentRequisitionId;
                    _vmMsg.ReturnCode = currentRequisitionCode;
                }
            }
            catch (Exception)
            {
                _vmMsg.Type = Enums.MessageType.Error;
                _vmMsg.Msg  = "Failed to save.";
            }
            return(_vmMsg);
        }