Esempio n. 1
0
        public InsuranceAllotmentDTO GetInsuranceAllotment(int insuranceAllotmentId)
        {
            InsuranceAllotmentDTO dto = new InsuranceAllotmentDTO();

            try
            {
                using (var entity = new ManiMotorsEntities1())
                {
                    dto = (from vbfa in entity.VehicleBookingInsuranceAllotments
                           join fi in entity.InsuranceInfoes on vbfa.InsuranceInfoID equals fi.InsuranceInfoID
                           where vbfa.VehicleBookingInsuranceAllotmentID == insuranceAllotmentId
                           select new InsuranceAllotmentDTO
                    {
                        VehicleBookingInsuranceAllotmentID = insuranceAllotmentId,
                        VehicleBookingId = vbfa.VehicleBookingID,
                        InsuranceByDealer = vbfa.InsuranceByDealer,
                        InsuranceInfoID = vbfa.InsuranceInfoID,
                        InsuranceName = fi.Name,
                        CoverNoteNo = vbfa.CoverNoteNo,
                        PolicyNumber = vbfa.PolicyNo,
                        PolicyAmount = vbfa.PolicyAmount,
                        FromDate = vbfa.FromDate,
                        ToDate = vbfa.ToDate,
                        PolicyDeliveredDate = vbfa.PolicyDeliveredDate,
                        ContactNo = vbfa.ContactNo,
                    }
                           ).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(dto);
        }
Esempio n. 2
0
        public int SaveInsuranceAllotment(InsuranceAllotmentDTO dto, string mode = "")
        {
            var insuranceAllotmentId = 0;

            try
            {
                using (var entity = new ManiMotorsEntities1())
                {
                    if (mode == "EDIT")
                    {
                        var obj = entity.VehicleBookingInsuranceAllotments.FirstOrDefault(vbfa => vbfa.VehicleBookingInsuranceAllotmentID == dto.VehicleBookingInsuranceAllotmentID);
                        obj.VehicleBookingID    = dto.VehicleBookingId;
                        obj.InsuranceByDealer   = dto.InsuranceByDealer;
                        obj.InsuranceInfoID     = dto.InsuranceInfoID;
                        obj.CoverNoteNo         = dto.CoverNoteNo;
                        obj.PolicyNo            = dto.PolicyNumber;
                        obj.PolicyAmount        = dto.PolicyAmount;
                        obj.FromDate            = dto.FromDate;
                        obj.ToDate              = dto.ToDate;
                        obj.PolicyDeliveredDate = dto.PolicyDeliveredDate;
                        obj.ContactNo           = dto.ContactNo;
                        obj.Createdby           = dto.CreatedBy;
                        obj.CreatedDate         = dto.CreatedDate;
                        obj.Modifiedby          = dto.ModifiedBy;
                        obj.ModifiedDate        = dto.ModifiedDate;
                        entity.SaveChanges();
                        insuranceAllotmentId = obj.VehicleBookingInsuranceAllotmentID;
                    }
                    else
                    {
                        VehicleBookingInsuranceAllotment obj = new VehicleBookingInsuranceAllotment()
                        {
                            VehicleBookingID    = dto.VehicleBookingId,
                            InsuranceByDealer   = dto.InsuranceByDealer,
                            InsuranceInfoID     = dto.InsuranceInfoID,
                            CoverNoteNo         = dto.CoverNoteNo,
                            PolicyNo            = dto.PolicyNumber,
                            PolicyAmount        = dto.PolicyAmount,
                            FromDate            = dto.FromDate,
                            ToDate              = dto.ToDate,
                            PolicyDeliveredDate = dto.PolicyDeliveredDate,
                            Createdby           = dto.CreatedBy,
                            CreatedDate         = dto.CreatedDate,
                            Modifiedby          = dto.ModifiedBy,
                            ModifiedDate        = dto.ModifiedDate
                        };
                        entity.VehicleBookingInsuranceAllotments.Add(obj);
                        entity.SaveChanges();
                        insuranceAllotmentId = obj.VehicleBookingInsuranceAllotmentID;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(insuranceAllotmentId);
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            InsuranceAllotmentBL obj = new InsuranceAllotmentBL();
            //InsuranceId

            int insuranceId = 0;

            if (ddlInsurance.SelectedIndex != -1)
            {
                var insuranceItem = (ComboboxItem)ddlInsurance.SelectedItem;
                insuranceId = Convert.ToInt32(insuranceItem.Value);
            }

            bool isInsByDealer = false;

            if (rdnYesbyDealer.Checked)
            {
                isInsByDealer = true;
            }

            int _coverNoteNo = 0;

            if (txtCoverNote.Text != "")
            {
                _coverNoteNo = Convert.ToInt32(txtCoverNote.Text);
            }

            int _policyAmount = 0;

            if (txtPolicyAmount.Text != "")
            {
                _policyAmount = Convert.ToInt32(txtPolicyAmount.Text);
            }


            //Populate dto
            InsuranceAllotmentDTO dto = new InsuranceAllotmentDTO()
            {
                VehicleBookingId    = Convert.ToInt32(lblVehicleBookingId.Text),
                InsuranceInfoID     = insuranceId,
                InsuranceByDealer   = isInsByDealer,
                CoverNoteNo         = _coverNoteNo,
                PolicyAmount        = _policyAmount,
                PolicyNumber        = txtPolicyNo.Text,
                FromDate            = Convert.ToDateTime(dtPolicyFromDate.Text),
                ToDate              = Convert.ToDateTime(dtPolicyToDate.Text),
                PolicyDeliveredDate = Convert.ToDateTime(dtPolicyDeliveredDate.Text),
                ContactNo           = txtContactNo.Text,
                CreatedBy           = GlobalSetup.Userid,
                CreatedDate         = DateTime.Now,
                ModifiedBy          = GlobalSetup.Userid,
                ModifiedDate        = DateTime.Now
            };

            if (_mode == "EDIT")
            {
                dto.VehicleBookingInsuranceAllotmentID = _insuranceAllotmentId;
            }

            int insuranceAllotmentId = obj.SaveInsuranceAllotment(dto, _mode);

            lblnsuranceAllotmentId.Text = insuranceAllotmentId.ToString();
            this.Close();
        }