示例#1
0
        public SparePartsInventoryDTO GetSparePartsInventory(int inventoryId)
        {
            SparePartsInventoryDTO dto = new SparePartsInventoryDTO();

            try
            {
                using (var entities = new ManiMotorsEntities1())
                {
                    dto = (from invlist in entities.SparePartsInventories
                           join invstatus in entities.SparePartsInventoryStatus
                           on invlist.SparePartsInventoryID equals invstatus.SparePartsInventoryID
                           join vehinfo in entities.SparePartsInfoes
                           on invlist.SparePartsInfoID equals vehinfo.SparePartsInfoID
                           join vehStatus in entities.SparePartsInventoryStatus
                           on invlist.SparePartsInventoryID equals vehStatus.SparePartsInventoryID
                           join vehStatusTypes in entities.SparePartsInventoryStatusTypes
                           on vehStatus.SparePartsInventoryStatusTypeID equals vehStatusTypes.SparePartsInventoryStatusTypeID
                           where invlist.SparePartsInventoryID == inventoryId
                           select new SparePartsInventoryDTO
                    {
                        SparePartsModelName = vehinfo.ModelName,
                        SparePartsInventoryID = invlist.SparePartsInventoryID,
                        SparePartsInfoID = invlist.SparePartsInfoID,
                        IdentificationNo = invlist.IdentificationNo,
                        OtherDescription = invlist.OtherDescription,
                        SparePartsInventoryStatusTypeID = vehStatus.SparePartsInventoryStatusTypeID,
                        SparePartsInventoryStatusName = vehStatusTypes.Description,
                        MarginPrice = invlist.MarginPrice ?? 0,
                        ShowRoomPrice = invlist.ShowroomPrice ?? 0
                    }).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(dto);
        }
示例#2
0
        public InvoiceDTO GetInvoiceDetails(int VehicleBookingId)
        {
            var Invoicedto     = new InvoiceDTO();
            var vBL            = new VehicleBookingBL();
            var viBL           = new VehicleInventoryBL();
            var vABL           = new VehicleAllotmentBL();
            var spABL          = new SparePartsAllotmentBL();
            var spInventory    = new SparePartsInventoryBL();
            var fABL           = new FinanceAllotmentBL();
            var vehicleBooking = vBL.GetVehicleBooking(VehicleBookingId);
            //Customer Information
            var ctmrDTO = new CustomerDTO();
            //VehicleInventory
            var vIDTO = new VehicleInventoryDTO();
            //VehicleBooking
            var vBDTO = new VehicleBookingDTO();
            //SpareParts Inventory
            var spInvDTOlist = new List <SparePartsInventoryDTO>();
            //Finance Allotment
            var fDTO = new FinanceAllotmentDTO();

            if (vehicleBooking != null)
            {
                vBDTO = vehicleBooking;
                Invoicedto.VclBooking = vBDTO;
                ctmrDTO.CustomerID    = vehicleBooking.CustomerID;
                ctmrDTO.Name          = vehicleBooking.CustomerName;
                Invoicedto.Customer   = ctmrDTO;
                //Get Vehicle Inventory ID from VehicleAllotment Id
                int vInventoryId = vABL.GeInventoryId(vehicleBooking.VehicleBookingAllotmentId ?? 0);

                if (vInventoryId != 0)
                {
                    var invDTO = viBL.GetVehicleInventory(vInventoryId);
                    vIDTO.EngineNo           = invDTO.EngineNo;
                    vIDTO.ChasisNo           = invDTO.ChasisNo;
                    vIDTO.VehicleModelName   = invDTO.VehicleModelName;
                    vIDTO.ExShowRoomPrice    = invDTO.ExShowRoomPrice;
                    vIDTO.LT_RT_OtherExp     = invDTO.LT_RT_OtherExp;
                    vIDTO.InsurancePrice     = invDTO.InsurancePrice;
                    vIDTO.OnRoadPrice        = invDTO.OnRoadPrice;
                    vIDTO.WarrantyPrice      = invDTO.WarrantyPrice;
                    vIDTO.VehicleInventoryID = vInventoryId;
                    if (invDTO.Is70PerMarginPrice)
                    {
                        vIDTO.MarginPrice = invDTO.Margin70;
                    }
                    if (invDTO.Is50PerMarginPrice)
                    {
                        vIDTO.MarginPrice = invDTO.Margin50;
                    }
                    Invoicedto.VehicleInventory = vIDTO;
                }

                //Get SpareParts Allotment Details
                var sPAltList = spABL.GetSparePartsAllotmentbyBookingId(VehicleBookingId);
                if (sPAltList.Count > 0)
                {
                    foreach (var sp in sPAltList)
                    {
                        var spIDTO = new SparePartsInventoryDTO();
                        if (sp.SparePartsInventoryID != 0)
                        {
                            var spI = spInventory.GetSparePartsInventory(sp.SparePartsInventoryID);
                            //SpareParts Inventory
                            SparePartsInventoryDTO spidto = new SparePartsInventoryDTO();
                            spidto.SparePartsInventoryID = sp.SparePartsInventoryID;
                            spidto.ShowRoomPrice         = spI.ShowRoomPrice;
                            spidto.MarginPrice           = spI.MarginPrice;
                            spidto.SparePartsModelName   = spI.SparePartsModelName;
                            spidto.SparePartsInfoID      = spI.SparePartsInfoID;
                            spInvDTOlist.Add(spidto);
                        }
                    }
                    Invoicedto.lstSparePartsInventory = spInvDTOlist;
                }

                //Finance Allotment

                if (vehicleBooking.FinanceAllotmentId != null && vehicleBooking.FinanceAllotmentId != 0)
                {
                    fDTO = fABL.GetFinanceAllotment(vehicleBooking.FinanceAllotmentId ?? 0);
                    Invoicedto.FinanceAllotment = fDTO;
                }
            }


            return(Invoicedto);
        }
示例#3
0
        public bool SaveInventorySpareParts(SparePartsInventoryDTO dto, string mode)
        {
            var flag = false;

            try
            {
                using (var entities = new ManiMotorsEntities1())
                {
                    if (mode == "EDIT")
                    {
                        var info = entities.SparePartsInventories.FirstOrDefault(v => v.SparePartsInventoryID == dto.SparePartsInventoryID);
                        info.SparePartsInfoID = dto.SparePartsInfoID;
                        info.IdentificationNo = dto.IdentificationNo;
                        info.OtherDescription = dto.OtherDescription;
                        info.CreatedDate      = dto.CreatedDate;
                        info.Createdby        = dto.CreatedBy;
                        info.ModifiedDate     = dto.ModifiedDate;
                        info.Modifiedby       = dto.ModifiedBy;
                        info.MarginPrice      = dto.MarginPrice;
                        info.ShowroomPrice    = dto.ShowRoomPrice;
                        entities.SaveChanges();
                        var spInfo = entities.SparePartsInventoryStatus.FirstOrDefault(vi => vi.SparePartsInventoryID == dto.SparePartsInventoryID);
                        if (spInfo != null)
                        {
                            spInfo.SparePartsInventoryStatusTypeID = dto.SparePartsInventoryStatusTypeID;
                            spInfo.Remarks      = dto.OtherDescription;
                            spInfo.Modifiedby   = dto.ModifiedBy;
                            spInfo.ModifiedDate = dto.ModifiedDate;
                            entities.SaveChanges();
                        }
                        flag = true;
                    }
                    else
                    {
                        SparePartsInventory info = new SparePartsInventory()
                        {
                            SparePartsInfoID = dto.SparePartsInfoID,
                            IdentificationNo = dto.IdentificationNo,
                            OtherDescription = dto.OtherDescription,
                            CreatedDate      = dto.CreatedDate,
                            Createdby        = dto.CreatedBy,
                            ModifiedDate     = dto.ModifiedDate,
                            Modifiedby       = dto.ModifiedBy,
                            MarginPrice      = dto.MarginPrice,
                            ShowroomPrice    = dto.ShowRoomPrice,
                        };
                        entities.SparePartsInventories.Add(info);
                        entities.SaveChanges();
                        SparePartsInventoryStatu obj = new SparePartsInventoryStatu();
                        obj.SparePartsInventoryID           = info.SparePartsInventoryID;
                        obj.SparePartsInventoryStatusTypeID = dto.SparePartsInventoryStatusTypeID;
                        obj.Remarks = dto.OtherDescription;
                        entities.SparePartsInventoryStatus.Add(obj);
                        entities.SaveChanges();
                        flag = true;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(flag);
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ddlModelName.SelectedIndex == -1 || txtIdentificationNo.Text == "" || txtOtherDescription.Text == "" || ddlQuantity.SelectedIndex == -1 || txtMarginPrice.Text == "" || txtShowRoomPrice.Text == "")
            {
                MyMessageBox.ShowBox("Please Select All Mandatory Fields !!!");
                return;
            }

            if (txtMarginPrice.Text == "0" || txtShowRoomPrice.Text == "0")
            {
                MyMessageBox.ShowBox("Price cannot be 0 !!!");
                return;
            }

            if (Convert.ToInt32(ddlQuantity.Text) > 5)
            {
                string ok = MyMessageBoxYesorNo.ShowBox("Are you sure you want to add " + ddlQuantity.Text + " Quantity");
                if (ok != "1")
                {
                    return;
                }
            }
            SparePartsInventoryDTO info = new SparePartsInventoryDTO();
            var selItem = (ComboboxItem)ddlModelName.SelectedItem;

            info.SparePartsInventoryID = _SparePartsInventoryID;
            info.SparePartsInfoID      = Convert.ToInt32(selItem.Value);
            info.IdentificationNo      = txtIdentificationNo.Text;
            info.OtherDescription      = txtOtherDescription.Text;
            info.CreatedDate           = System.DateTime.Now;
            info.CreatedBy             = GlobalSetup.Userid;
            info.ModifiedDate          = System.DateTime.Now;
            info.MarginPrice           = Convert.ToInt32(txtMarginPrice.Text);
            info.ShowRoomPrice         = Convert.ToInt32(txtShowRoomPrice.Text);
            var invSelitem = (ComboboxItem)ddlInvStatus.SelectedItem;

            info.SparePartsInventoryStatusTypeID = Convert.ToInt32(invSelitem.Value);
            int quantity = Convert.ToInt32(ddlQuantity.Text);
            SparePartsInventoryBL viBL = new SparePartsInventoryBL();
            var flag    = false;
            var identno = info.IdentificationNo;

            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    for (int i = 1; i <= quantity; i++)
                    {
                        info.IdentificationNo = identno + " --" + i.ToString() + " -" + System.DateTime.Now.ToShortDateString();
                        viBL.SaveInventorySpareParts(info, _mode);
                    }
                    flag = true;
                    scope.Complete();
                }
                catch (Exception ex)
                {
                    flag = false;
                }
                if (flag)
                {
                    MyMessageBox.ShowBox("SpareParts Inventory Saved", "SpareParts Inventory");
                    Clear();
                }
                else
                {
                    MyMessageBox.ShowBox("SpareParts Inventory Failed to Save", "SpareParts Inventory");
                }
            }
            this.Close();
        }