//搜索车牌 private void button1_Click(object sender, EventArgs e) { string plate = txtPlate.Text; if (string.IsNullOrEmpty(plate.ToString())) { MessageBox.Show("请输入车牌号!!!"); return; } CarDal car = new CarDal(); DataTable dt = car.GetByPlate(plate); //判断该用户搜索的车牌号是否存在 if (dt.Rows.Count <= 0) { MessageBox.Show("该车牌号不存在或者以结算了...."); return; } DataRow row = dt.Rows[0]; DateTime startTime = Convert.ToDateTime(row["CreateDateTime"]); DateTime closeTime = DateTime.Now; int day = (closeTime - startTime).Days; int hourse = (closeTime - startTime).Hours; int minutes = (closeTime - startTime).Minutes; int totalTime = 0; if (day > 0) { totalTime += day * 60; } if (hourse > 0) { totalTime += hourse * 60; } totalTime += minutes; //MessageBox.Show(totalTime.ToString()); txtPlate2.Text = row["Plate"].ToString(); txtStartTime.Text = row["CreateDateTime"].ToString(); txtMoney.Text = row["money"].ToString(); txtManager.Text = row["ManagerId"].ToString(); txtCloseTime.Text = DateTime.Now.ToString(); txtCarType.Text = row["CarTypeId"].ToString(); txtCarPosition.Text = row["CarPositionId"].ToString(); float lastMoney = 0; //判断用户停车是否大于2个小时,不大于两小时按两小时收费 if (totalTime / 120 > 0) { //计算出该车超出多少分钟 int moreThanMinues = totalTime - 120; lastMoney = Convert.ToInt32(txtMoney.Text); //超过2小时,每分钟收3毛钱 lastMoney += moreThanMinues * 0.3f; txtMoney.Text = lastMoney.ToString(); } }
private void LookCollectFee_Load(object sender, EventArgs e) { CarDal cars = new CarDal(); DataTable dt = cars.GetAll(); dataGridView1.DataSource = dt; }
//结算车费 private void button2_Click(object sender, EventArgs e) { CarDal dal = new CarDal(); int n = dal.DeletedByPlate(txtPlate.Text, txtMoney.Text, Convert.ToDateTime(txtCloseTime.Text)); CarPositionDal position = new CarPositionDal(); int positionId = Convert.ToInt32(txtCarPosition.Text); int n2 = position.IsDeleted(positionId); if (n > 0 && n2 > 0) { MessageBox.Show("结算成功"); } else { MessageBox.Show("结算失败!"); } }
public frmPosAd() { InitializeComponent(); common = new CommonDal(); carCrud = new CarDal(); imageCrud = new ImageDal(); cbMarka.DataSource = common.GetBrandsByIdName(); cbMarka.SelectedIndex = -1; cbBodyType.DataSource = common.GetBanTypesByIdName(); cbBodyType.SelectedIndex = -1; cbColor.DataSource = common.GetColorsByIdName(); cbColor.SelectedIndex = -1; cbFuelType.DataSource = common.GetFuelTypesByIdName(); cbFuelType.SelectedIndex = -1; cbGearBox.DataSource = common.GetGearboxTypesByIdName(); cbGearBox.SelectedIndex = -1; cbTransmission.DataSource = common.GetTansmitionTypesByIdName(); cbTransmission.SelectedIndex = -1; cbEngineCapacity.DataSource = common.GetEngineCapacitiesByIdName(); cbEngineCapacity.SelectedIndex = -1; cbCity.DataSource = common.GetCityByIdName(); cbCity.SelectedIndex = -1; }
static void Main(string[] args) { Console.WriteLine("welcome to CarComparisionApp --- StephenGao"); Console.WriteLine("Loading Data......"); CarDal carManager = new CarDal(); carManager.loadData(); Console.WriteLine("Sample data loaded succesfully!"); while (true) { List <Car> results = new List <Car>(); Car result = new Car(); decimal distance = 0; ShowMenu(); string command = Console.ReadLine(); switch (command.ToUpper()) { case "1": results = carManager.getNewestVehiclesInOrder(); displayResults(results); break; case "2": results = carManager.getalphabetizedr(); displayResults(results); break; case "3": results = carManager.getOrderByPrice(); displayResults(results); break; case "4": result = carManager.getBestValue(); displaySingleResult(result); break; case "5": Console.WriteLine("Enter the distance"); distance = Convert.ToInt32(Console.ReadLine()); var fuleConsumptions = carManager.getFuleConsumption(distance); displayFuelConsumption(fuleConsumptions); break; case "6": result = carManager.getRandomCar(); displaySingleResult(result); break; case "7": Console.WriteLine("Enter the year(2016 or 2017)"); int year = Convert.ToInt32(Console.ReadLine()); var avgMPG = carManager.averageMPGByYear(year); displayAvgMPG(avgMPG, year); break; case "Q": Environment.Exit(1); break; default: Console.WriteLine("Invalid Command"); break; } } }