public VehicleInfoDTO GetVehicleInfo(int VehicleInfoID) { VehicleInfoDTO obj = new VehicleInfoDTO(); try { using (var entities = new ManiMotorsEntities1()) { var lstVehicleInfo = entities.VehicleInfoes.Where(x => x.VehicleInfoID == VehicleInfoID).FirstOrDefault(); obj.VehicleInfoID = lstVehicleInfo.VehicleInfoID; obj.VehicleTypeID = lstVehicleInfo.VehicleTypeID; obj.ModelCode = lstVehicleInfo.ModelCode; obj.ModelName = lstVehicleInfo.ModelName; obj.ExShowRoomPrice = lstVehicleInfo.ExShowRoomPrice; obj.LT_RT_OtherExp = lstVehicleInfo.LT_RT_OtherExp; obj.InsurancePrice = lstVehicleInfo.InsurancePrice; obj.OnRoadPrice = lstVehicleInfo.OnRoadPrice; obj.MarginPrice = lstVehicleInfo.MarginPrice; obj.Margin50 = lstVehicleInfo.C50PercentMargin; obj.Margin70 = lstVehicleInfo.C70PercentMargin; obj.CreatedDate = lstVehicleInfo.CreatedDate ?? DateTime.Now; obj.CreatedBy = lstVehicleInfo.Createdby ?? 0; obj.ModifiedDate = lstVehicleInfo.ModifiedDate ?? DateTime.Now; obj.ModifiedBy = lstVehicleInfo.Modifiedby ?? 0; obj.WarrantyPrice = lstVehicleInfo.WarrantyPrice ?? 0; } } catch (Exception ex) { throw ex; } return(obj); }
public bool SaveVehicleInfo(VehicleInfoDTO dto, string mode) { var flag = false; try { using (var entities = new ManiMotorsEntities1()) { if (mode == "EDIT") { var info = entities.VehicleInfoes.FirstOrDefault(v => v.VehicleInfoID == dto.VehicleInfoID); info.VehicleTypeID = dto.VehicleTypeID; info.ModelCode = dto.ModelCode; info.ModelName = dto.ModelName; info.ExShowRoomPrice = dto.ExShowRoomPrice; info.LT_RT_OtherExp = dto.LT_RT_OtherExp; info.InsurancePrice = dto.InsurancePrice; info.OnRoadPrice = dto.OnRoadPrice; info.MarginPrice = dto.MarginPrice; info.C50PercentMargin = dto.Margin50; info.C70PercentMargin = dto.Margin70; info.CreatedDate = dto.CreatedDate; info.Createdby = dto.CreatedBy; info.ModifiedDate = dto.ModifiedDate; info.Modifiedby = dto.ModifiedBy; info.WarrantyPrice = dto.WarrantyPrice; entities.SaveChanges(); flag = true; } else { VehicleInfo info = new VehicleInfo(); info.VehicleTypeID = dto.VehicleTypeID; info.ModelCode = dto.ModelCode; info.ModelName = dto.ModelName; info.ExShowRoomPrice = dto.ExShowRoomPrice; info.LT_RT_OtherExp = dto.LT_RT_OtherExp; info.InsurancePrice = dto.InsurancePrice; info.OnRoadPrice = dto.OnRoadPrice; info.MarginPrice = dto.MarginPrice; info.C50PercentMargin = dto.Margin50; info.C70PercentMargin = dto.Margin70; info.CreatedDate = dto.CreatedDate; info.Createdby = dto.CreatedBy; info.ModifiedDate = dto.ModifiedDate; info.Modifiedby = dto.ModifiedBy; info.WarrantyPrice = dto.WarrantyPrice; entities.VehicleInfoes.Add(info); entities.SaveChanges(); flag = true; } } } catch (Exception ex) { throw ex; } return(flag); }
public List <VehicleInfoDTO> GetAllVehicleInfo() { List <VehicleInfoDTO> obj = new List <VehicleInfoDTO>(); try { using (var entities = new ManiMotorsEntities1()) { var lstVehicleInfo = entities.VehicleInfoes.ToList(); foreach (var Info in lstVehicleInfo) { VehicleInfoDTO dto = new VehicleInfoDTO(); dto.VehicleInfoID = Info.VehicleInfoID; dto.VehicleTypeID = Info.VehicleTypeID; dto.ModelCode = Info.ModelCode; dto.ModelName = Info.ModelName; dto.ExShowRoomPrice = Info.ExShowRoomPrice; dto.LT_RT_OtherExp = Info.LT_RT_OtherExp; dto.InsurancePrice = Info.InsurancePrice; dto.OnRoadPrice = Info.OnRoadPrice; dto.MarginPrice = Info.MarginPrice; dto.Margin50 = Info.C50PercentMargin; dto.Margin70 = Info.C70PercentMargin; dto.CreatedDate = Info.CreatedDate ?? DateTime.Now; dto.CreatedBy = Info.Createdby ?? 0; dto.ModifiedDate = Info.ModifiedDate ?? DateTime.Now; dto.ModifiedBy = Info.Modifiedby ?? 0; dto.WarrantyPrice = Info.WarrantyPrice ?? 0; obj.Add(dto); } } } catch (Exception ex) { throw ex; } return(obj); }
private void btnSave_Click(object sender, EventArgs e) { if (ddlVehicleType.SelectedIndex == -1 || txtModelName.Text == "" || txtLTRTOtherExp.Text == "" || txtMarginPrice.Text == "" || txt70Margin.Text == "" || txtModelCode.Text == "" || txtShowRoomPrice.Text == "" || txtOnRoadPrice.Text == "" || txt50Margin.Text == "" || txtInsurancePrice.Text == "" || txtWarranty.Text == "") { MyMessageBox.ShowBox("Please Enter All Mandatory Fields!!!"); return; } VehicleInfoDTO info = new VehicleInfoDTO(); var selItem = (ComboboxItem)ddlVehicleType.SelectedItem; info.VehicleInfoID = _vehicleInfoID; info.VehicleTypeID = Convert.ToInt32(selItem.Value); info.ModelCode = txtModelCode.Text; info.ModelName = txtModelName.Text; info.ExShowRoomPrice = Convert.ToInt32(txtShowRoomPrice.Text); info.LT_RT_OtherExp = Convert.ToInt32(txtLTRTOtherExp.Text); info.InsurancePrice = Convert.ToInt32(txtInsurancePrice.Text); info.OnRoadPrice = Convert.ToInt32(txtOnRoadPrice.Text); info.MarginPrice = Convert.ToInt32(txtMarginPrice.Text); info.Margin50 = Convert.ToInt32(txt50Margin.Text); info.Margin70 = Convert.ToInt32(txt70Margin.Text); info.CreatedDate = System.DateTime.Now; info.CreatedBy = GlobalSetup.Userid; info.ModifiedDate = System.DateTime.Now; info.WarrantyPrice = Convert.ToInt32(txtWarranty.Text); VehicleInfoBL viBL = new VehicleInfoBL(); var flag = viBL.SaveVehicleInfo(info, _mode); if (flag) { MyMessageBox.ShowBox("Vehicle Information Saved", "Vehicle Info"); Clear(); } else { MyMessageBox.ShowBox("Vehicle Information Failed to Save", "Vehicle Info"); } }