private void btnBook_Click(object sender, EventArgs e) { string custName = txtCustomerName.Text; string custLastName = txtCustomerLastname.Text; int carID = Convert.ToInt32(txtcarID.Text); RentalInfoService _rentalInfoService = new RentalInfoService(); CarService _carService = new CarService(); UserService _userService = new UserService(); User newUser = new User(); newUser.email = "-"; newUser.password = "******"; newUser.roleID = 3; newUser.userName = "******" + custName + custLastName; _userService.Add(newUser); Car selectedCar = new Car(); selectedCar = _carService.Get(carID); _carService.Update(selectedCar); RentalInformation _rentInfo = new RentalInformation(); _rentInfo.carID = carID; _rentInfo.companyID = selectedCar.companyID; _rentInfo.rentalDate = DateTime.Now; _rentInfo.rentalDay = 3; _rentalInfoService.Add(_rentInfo); List <Car> Cars = _carService.GetAll(); txtList.Clear(); foreach (Car car in Cars) { if (car.rentalStatus == false) { txtList.Text += "Car ID: " + car.carID + " -- Car Name: " + car.CarInformation.carName + " //// Car Daily Rental Price: " + car.CarInformation.dailyRentalPrice + " TL -- Rental Status: " + car.rentalStatus + "\r\n"; } } }
private void saveButton_Click(object sender, EventArgs e) { aRentalInformation = new RentalInformation(); Vehicle selectedVehicle = (Vehicle)vehicleRegNocomboBox.SelectedItem; string regNo = selectedVehicle.RegNO; aRentalInformation.RentDate = saveDateTimePicker.Text; aRentalInformation.Destination = destinationSaveTextBox.Text; aRentalInformation.Payment = Convert.ToDouble(rentCostSaveTextBox.Text); aRentalInformation.Cost = Convert.ToDouble(costSaveTextBox.Text); aRentalInformation.Profit = Convert.ToDouble(aRentalInformation.Payment-aRentalInformation.Cost); aRentalInformation.Commission = ((selectedVehicle.Deal*aRentalInformation.Profit)/100); aRentalInformation.PaymentStatus = (string) StatusSaveComboBox.SelectedItem; string msg = aRentalInformationBll.SaveRentalInformation(regNo,aRentalInformation.RentDate,aRentalInformation.Destination, aRentalInformation.Payment,aRentalInformation.Cost,aRentalInformation.Profit,aRentalInformation.Commission, aRentalInformation.PaymentStatus); MessageBox.Show(msg); saveDateTimePicker.Text = ""; destinationSaveTextBox.Text = ""; rentCostSaveTextBox.Text = ""; costSaveTextBox.Text = ""; StatusSaveComboBox.Text = ""; PopulateComboBox(); }
public UserItem(BinaryReader reader, int version = int.MaxValue, int Customversion = int.MaxValue) { UniqueID = reader.ReadUInt64(); ItemIndex = reader.ReadInt32(); CurrentDura = reader.ReadUInt16(); MaxDura = reader.ReadUInt16(); Count = reader.ReadUInt32(); AC = reader.ReadByte(); MAC = reader.ReadByte(); DC = reader.ReadByte(); MC = reader.ReadByte(); SC = reader.ReadByte(); Accuracy = reader.ReadByte(); Agility = reader.ReadByte(); HP = reader.ReadByte(); MP = reader.ReadByte(); AttackSpeed = reader.ReadSByte(); Luck = reader.ReadSByte(); SoulBoundId = reader.ReadInt32(); byte Bools = reader.ReadByte(); Identified = (Bools & 0x01) == 0x01; Cursed = (Bools & 0x02) == 0x02; Strong = reader.ReadByte(); MagicResist = reader.ReadByte(); PoisonResist = reader.ReadByte(); HealthRecovery = reader.ReadByte(); ManaRecovery = reader.ReadByte(); PoisonRecovery = reader.ReadByte(); CriticalRate = reader.ReadByte(); CriticalDamage = reader.ReadByte(); Freezing = reader.ReadByte(); PoisonAttack = reader.ReadByte(); int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { if (reader.ReadBoolean()) { continue; } UserItem item = new UserItem(reader, version, Customversion); Slots[i] = item; } GemCount = reader.ReadUInt32(); Awake = new Awake(reader); RefinedValue = (RefinedValue)reader.ReadByte(); RefineAdded = reader.ReadByte(); WeddingRing = reader.ReadInt32(); if (version < 65) { return; } if (reader.ReadBoolean()) { ExpireInfo = new ExpireInfo(reader, version, Customversion); } if (version < 76) { return; } if (reader.ReadBoolean()) { RentalInformation = new RentalInformation(reader, version, Customversion); } }
public void Update(RentalInformation entity) { throw new NotImplementedException(); }
public void Add(RentalInformation entity) { _rentalInfoManager.Add(entity); }
public void Add(RentalInformation entity) { _rentalInfoDAL.Add(entity); }
public UserItem(BinaryReader reader, int version = int.MaxValue, int customVersion = int.MaxValue) { UniqueID = reader.ReadUInt64(); ItemIndex = reader.ReadInt32(); CurrentDura = reader.ReadUInt16(); MaxDura = reader.ReadUInt16(); if (version <= 84) { Count = (ushort)reader.ReadUInt32(); } else { Count = reader.ReadUInt16(); } if (version <= 84) { AddedStats = new Stats(); AddedStats[Stat.MaxAC] = reader.ReadByte(); AddedStats[Stat.MaxMAC] = reader.ReadByte(); AddedStats[Stat.MaxDC] = reader.ReadByte(); AddedStats[Stat.MaxMC] = reader.ReadByte(); AddedStats[Stat.MaxSC] = reader.ReadByte(); AddedStats[Stat.Accuracy] = reader.ReadByte(); AddedStats[Stat.Agility] = reader.ReadByte(); AddedStats[Stat.HP] = reader.ReadByte(); AddedStats[Stat.MP] = reader.ReadByte(); AddedStats[Stat.AttackSpeed] = reader.ReadSByte(); AddedStats[Stat.Luck] = reader.ReadSByte(); } SoulBoundId = reader.ReadInt32(); byte Bools = reader.ReadByte(); Identified = (Bools & 0x01) == 0x01; Cursed = (Bools & 0x02) == 0x02; if (version <= 84) { AddedStats[Stat.Strong] = reader.ReadByte(); AddedStats[Stat.MagicResist] = reader.ReadByte(); AddedStats[Stat.PoisonResist] = reader.ReadByte(); AddedStats[Stat.HealthRecovery] = reader.ReadByte(); AddedStats[Stat.SpellRecovery] = reader.ReadByte(); AddedStats[Stat.PoisonRecovery] = reader.ReadByte(); AddedStats[Stat.CriticalRate] = reader.ReadByte(); AddedStats[Stat.CriticalDamage] = reader.ReadByte(); AddedStats[Stat.Freezing] = reader.ReadByte(); AddedStats[Stat.PoisonAttack] = reader.ReadByte(); } int count = reader.ReadInt32(); SetSlotSize(count); for (int i = 0; i < count; i++) { if (reader.ReadBoolean()) { continue; } UserItem item = new UserItem(reader, version, customVersion); Slots[i] = item; } if (version <= 84) { GemCount = (ushort)reader.ReadUInt32(); } else { GemCount = reader.ReadUInt16(); } if (version > 84) { AddedStats = new Stats(reader); } Awake = new Awake(reader); RefinedValue = (RefinedValue)reader.ReadByte(); RefineAdded = reader.ReadByte(); if (version > 85) { RefineSuccessChance = reader.ReadInt32(); } WeddingRing = reader.ReadInt32(); if (version < 65) { return; } if (reader.ReadBoolean()) { ExpireInfo = new ExpireInfo(reader, version, customVersion); } if (version < 76) { return; } if (reader.ReadBoolean()) { RentalInformation = new RentalInformation(reader, version, customVersion); } if (version < 83) { return; } IsShopItem = reader.ReadBoolean(); }
public List<RentalInformation> GetAllRentalDetails(string regNo) { aConnection.Open(); string query = string.Format("SELECT * FROM t_rental_information WHERE reg_no = '{0}'",regNo); SqlCommand aCommand = new SqlCommand(query, aConnection); SqlDataReader aReader = aCommand.ExecuteReader(); List<RentalInformation> rentalInformations = new List<RentalInformation>(); if (aReader.HasRows) { while (aReader.Read()) { aRentalInformation = new RentalInformation(); aRentalInformation.RegNo = aReader[1].ToString(); aRentalInformation.RentDate = aReader[2].ToString(); aRentalInformation.Destination = aReader[3].ToString(); aRentalInformation.Payment = Convert.ToDouble(aReader[4].ToString()); aRentalInformation.Cost = Convert.ToDouble(aReader[5].ToString()); aRentalInformation.Profit = Convert.ToDouble(aReader[6].ToString()); aRentalInformation.Commission = Convert.ToDouble(aReader[7].ToString()); aRentalInformation.PaymentStatus = aReader[8].ToString(); rentalInformations.Add(aRentalInformation); } } aConnection.Close(); return rentalInformations; }
public RentalInformation GetRentalInformation(string regNo, string rentDate) { aConnection.Open(); string query = string.Format("SELECT * FROM t_rental_information WHERE reg_no = '{0}'AND rent_date = '{1}'", regNo,rentDate); SqlCommand aCommand = new SqlCommand(query, aConnection); SqlDataReader aReader = aCommand.ExecuteReader(); aRentalInformation = new RentalInformation(); if (aReader.HasRows) { while (aReader.Read()) { aRentalInformation.RegNo = aReader[1].ToString(); aRentalInformation.RentDate = aReader[2].ToString(); aRentalInformation.Destination = aReader[3].ToString(); aRentalInformation.Payment = Convert.ToDouble(aReader[4].ToString()); aRentalInformation.Cost = Convert.ToDouble(aReader[5].ToString()); aRentalInformation.Profit = Convert.ToDouble(aReader[6].ToString()); aRentalInformation.Commission = Convert.ToDouble(aReader[7].ToString()); aRentalInformation.PaymentStatus = aReader[8].ToString(); } } aConnection.Close(); return aRentalInformation; }
public ActionResult ViewRentals(string SearchInput, FormCollection frm, RentalInformation rentalinfo, string isEdit) { ApplicationDbContext context = new ApplicationDbContext(); var userid = User.Identity.GetUserId(); string ZoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup; var username = User.Identity.GetUserName(); RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.FirstOrDefault(m => m.UserName == username); ViewBag.IsValidRole = roleAssignmentMatrix.Rentals; //Result of initial search button if (!string.IsNullOrEmpty(SearchInput)) { SearchCompany searchcompany1 = new SearchCompany(); searchcompany1.SearchInput = SearchInput.ToString(); List <Company> NewCompanies = new List <Company>(); NewCompanies = db.Company.SqlQuery("Select * from Companies where CompanyName like '%" + SearchInput + "%'").ToList(); SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup); searchcompany1.CompanyList = searchCompanyPerGroup.Companies; //searchcompany1.CompanyList = db.Company.SqlQuery("Select * from Companies where CompanyName like '%" + SearchInput + "%' and ZoneGroup").ToList(); ViewBag.CompanySelected = ""; return(View(searchcompany1)); } //Result of selected company shown by "Search button" else if (frm.Count == 2) { int OutParseValue; bool CanParse = int.TryParse(frm[1].ToString(), out OutParseValue); SearchCompany searchcompany1 = new SearchCompany(); if (CanParse) { int ParsedCompanyID = int.Parse(frm[1].ToString()); searchcompany1.RentalInformationList = db.RentalInformation.Where(m => m.CompanyId == ParsedCompanyID).ToList(); searchcompany1.CompanyList = db.Company.Where(m => m.CompanyID == ParsedCompanyID).ToList(); searchcompany1.BillingRate = db.BillingRates.Where(m => m.Category == "Rental Fee").Where(m => m.ZoneGroup == ZoneGroup).ToList(); var bill = searchcompany1.BillingRate.GroupBy(m => m.SubCategory).ToList(); foreach (var item in bill) { searchcompany1.SubCategory.Add(item.Key.ToString()); } SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Rental - Search Company - from Terminal: " + ipaddress); ViewBag.CompanySelected = "OK"; } else { ViewBag.CompanySelected = ""; } return(View(searchcompany1)); } else if (isEdit == "True") //Edit transaction { var area = frm["Area"].Split(','); var newArea = ""; foreach (var item in area) { newArea = newArea + item; } RentalInformation rent = new RentalInformation(); int CompanyID = int.Parse(frm["CompanyID"].ToString()); //TryUpdateModel(rent); //if (ModelState.IsValid) //{ RentalInformation rentinfo = null; int ParsedIntRentID = int.Parse(frm["rentID"]); rentinfo = db.RentalInformation.Find(ParsedIntRentID); if (rentinfo != null) { rentinfo.Type = frm["Type"].ToString(); rentinfo.Rate = decimal.Parse(frm["Rate"]); rentinfo.Area = Math.Round(decimal.Parse(newArea), 2); rentinfo.Amount = Math.Round(decimal.Parse(frm["Rate"]) * decimal.Parse(frm["Area"]), 2); rentinfo.StartDate = DateTime.Parse(frm["StartDate"].ToString()); rentinfo.EndDate = DateTime.Parse(frm["EndDate"].ToString()); rentinfo.BillMode = frm["BillMode"].ToString(); rentinfo.DueOn = int.Parse(frm["DueOn"]); rentinfo.BillingMonths = frm["billingMonths"]; //rentinfo.BillingMonths = "1,2,3,4,5,6,7,8,9,10,11,12"; rentinfo.Currency = frm["Currency"].ToString(); rentinfo.UpdateDate = DateTime.Now; rentinfo.UpdatedBy = userid; db.Entry(rentinfo).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); ViewBag.ValidatePostback = "True"; SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Rental - Edit - from Terminal: " + ipaddress); TempData["TransactionSuccess"] = "Edit"; //ViewBag.TransactionSuccess = "Edit"; } //} else { ViewBag.ValidatePostback = "False"; } SearchCompany searchcompany = new SearchCompany(); searchcompany.RentalInformationList = db.RentalInformation.Where(m => m.CompanyId == CompanyID).ToList(); searchcompany.CompanyList = db.Company.Where(m => m.CompanyID == CompanyID).ToList(); searchcompany.BillingRate = db.BillingRates.Where(m => m.Category == "Rental Fee").Where(m => m.ZoneGroup == ZoneGroup).ToList(); var bill = searchcompany.BillingRate.GroupBy(m => m.SubCategory).ToList(); foreach (var item in bill) { searchcompany.SubCategory.Add(item.Key); } ViewBag.CompanySelected = "OK"; TempData["SearchCompany"] = searchcompany; return(RedirectToAction("ViewRentalsRPG", "DataEntryRental")); //return View(searchcompany); } //If returned key/value pairs is > 3. "Add transaction is invoked else if (frm.Count > 3) { int OutIntParse; decimal OutDecimalParse; bool canParse = int.TryParse(frm["CompanyID"].ToString(), out OutIntParse); int parsedCompanyID = (canParse) ? int.Parse(frm["CompanyID"].ToString()) : 0; //int ParsedIntRentID = int.Parse(frm["RentalInformationId"]); RentalInformation rent = new RentalInformation(); TryUpdateModel(rent); //var errors = ModelState.Values.SelectMany(v => v.Errors); //UpdateModel<IRentalInformation>(rent); //if (ModelState.IsValid) //{ try { var r = frm["Rate"].ToString(); var s = r.Split(','); var newRate = ""; foreach (var item in s) { newRate += item; } decimal rate = Math.Round((decimal.TryParse(newRate, out OutDecimalParse)) ? decimal.Parse(newRate) : 0, 2); decimal area = Math.Round((decimal.TryParse(frm["Area"].ToString(), out OutDecimalParse)) ? decimal.Parse(frm["Area"].ToString()) : 0, 2); decimal amt = Math.Round(rate * area, 2); int RentalBillMode = (int.TryParse(frm["BillMode"].ToString(), out OutIntParse)) ? int.Parse(frm["BillMode"].ToString()) : 0; RentalInformation rentalinformation = new RentalInformation(); rentalinformation.CompanyId = parsedCompanyID; rentalinformation.Type = frm["Type"].ToString(); rentalinformation.Rate = rate; rentalinformation.Area = area; string str = frm["StartDate"].ToString(); rentalinformation.StartDate = Convert.ToDateTime(frm["StartDate"].ToString()); rentalinformation.EndDate = Convert.ToDateTime(frm["EndDate"].ToString()); //rentalinformation.BillMode = (int.TryParse(frm["BillMode"].ToString(), out OutIntParse)) ? int.Parse(frm["BillMode"].ToString()) : 0; rentalinformation.BillMode = frm["BillMode"].ToString(); rentalinformation.DueOn = (int.TryParse(frm["DueOn"].ToString(), out OutIntParse)) ? int.Parse(frm["DueOn"].ToString()) : 0; rentalinformation.BillingMonths = frm["billingMonths"]; //rentalinformation.BillingMonths = "1,2,3,4,5,6,7,8,9,10,11,12"; rentalinformation.CreatedDate = DateTime.Now; rentalinformation.Amount = amt; rentalinformation.Currency = frm["Currency"].ToString(); rentalinformation.CreatedBy = userid; db.RentalInformation.Add(rentalinformation); db.SaveChanges(); SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Rental - Add - from Terminal: " + ipaddress); TempData["TransactionSuccess"] = "Add"; //ViewBag.TransactionSuccess = "Add"; ViewBag.ValidatePostback = "True"; } catch (Exception) { ViewBag.ValidatePostback = "False"; } //} //else //{ // ViewBag.ValidatePostback = "False"; //} ViewBag.CompanySelected = "OK"; SearchCompany searchcompany = new SearchCompany(); searchcompany.RentalInformationList = db.RentalInformation.Where(m => m.CompanyId == parsedCompanyID).ToList(); searchcompany.CompanyList = db.Company.Where(m => m.CompanyID == parsedCompanyID).ToList(); searchcompany.BillingRate = db.BillingRates.Where(m => m.Category == "Rental Fee").Where(m => m.ZoneGroup == ZoneGroup).ToList(); var bill = searchcompany.BillingRate.GroupBy(m => m.SubCategory).ToList(); foreach (var item in bill) { searchcompany.SubCategory.Add(item.Key); } TempData["SearchCompany"] = searchcompany; return(RedirectToAction("ViewRentalsRPG", "DataEntryRental")); //return View(searchcompany); } //Default value else { SearchCompany searchcompany1 = new SearchCompany(); return(View(searchcompany1)); } }
private void updateButton_Click(object sender, EventArgs e) { aRentalInformation = new RentalInformation(); aRentalInformation.RegNo = vehicleRegNoUpdatecomboBox.Text; aRentalInformation.RentDate = updateDateTimePicker.Text; aRentalInformation.Destination = destinationUpdateTextBox.Text; aRentalInformation.Payment = Convert.ToDouble(rentalCostUpdateTextBox.Text); aRentalInformation.Cost = Convert.ToDouble(costUpdateTextBox.Text); aRentalInformation.Profit = Convert.ToDouble(aRentalInformation.Payment - aRentalInformation.Cost); Vehicle selectedVehicle = (Vehicle)vehicleRegNocomboBox.SelectedItem; aRentalInformation.Commission = ((selectedVehicle.Deal * aRentalInformation.Profit) / 100); aRentalInformation.PaymentStatus = (string)StatusUpdateComboBox.SelectedItem; string msg = aRentalInformationBll.UpdateRentalInformation(aRentalInformation.RegNo, aRentalInformation.RentDate, aRentalInformation.Destination, aRentalInformation.Payment, aRentalInformation.Cost, aRentalInformation.Profit, aRentalInformation.Commission, aRentalInformation.PaymentStatus); MessageBox.Show(msg); }