Exemple #1
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (tbPayPwd.Text != StaticData.userLocal.UserPayPwd)
            {
                MessageBox.Show("支付密码错误");
                return;
            }
            if (remainTime.TotalMinutes < -30)
            {
                decimal  extraCost;
                CostRule costRule = ruleDal.RuleSelectByUserLevel(order.UserLevel);
                var      hours    = Convert.ToDecimal(remainTime.TotalHours);
                hours     = Math.Ceiling(hours);
                extraCost = Math.Abs(hours * costRule.HourCost);
                MessageBox.Show("你已超时还车超过30分钟, 我们将按时租价格额外收取你:" + extraCost.ToString("c"));
                StaticData.userLocal.RemainMoney -= extraCost;
                new UserDal().UpdateUser(StaticData.userLocal);
                order.OrderCost += extraCost;
            }
            order.EndTime = DateTime.Now;
            order.Status  = RentalOrder.OrderStatus.已完成;

            orderDal.UpdateOrder(order);
            carInfo.Status = CarInfo.CarStatus.在库;
            carInfo.UserId = 0;
            new CarDal().CarUpdate(carInfo);
            MessageBox.Show("已还车");
            this.Close();
        }
Exemple #2
0
 private void btnUpdateRule_Click(object sender, EventArgs e)
 {
     if (lvRuleList.SelectedItems.Count > 0)
     {
         int            UserLevel      = Convert.ToInt32(lvRuleList.SelectedItems[0].SubItems[1].Text);
         CostRule       ruleTemp       = costRuleDal.RuleSelectByUserLevel(UserLevel);
         UpdateRuleForm updateRuleForm = new UpdateRuleForm(ruleTemp);
         updateRuleForm.ShowDialog();
     }
     else
     {
         MessageBox.Show("请先选择要修改的规则");
     }
 }
Exemple #3
0
        private decimal CalculateCost()
        {
            if (cbRentalType.Text == "")
            {
                return(0);
            }
            CostRule costRule  = ruleDal.RuleSelectByUserLevel(StaticData.userLocal.UserLevel);
            decimal  totalCost = 0;

            if (costRule == null)
            {
                lbTotal.Text = "总计费用: " + "计算费用错误!";
            }
            if (cbRentalType.Text == "时租")
            {
                var     timespan = dtEndTime.Value - dtStartTime.Value;
                decimal hours    = Convert.ToDecimal(timespan.TotalHours);
                hours              = Math.Ceiling(hours);
                totalCost          = hours * costRule.HourCost;
                lbTotal.Text       = "总计费用: " + (hours * costRule.HourCost).ToString("C");
                dtActualTime.Value = dtStartTime.Value.AddHours((double)hours);
            }
            if (cbRentalType.Text == "日租")
            {
                var     timespan = dtEndTime.Value - dtStartTime.Value;
                decimal days     = Convert.ToDecimal(timespan.TotalDays);
                days               = Math.Ceiling(days);
                totalCost          = days * costRule.DayCost;
                lbTotal.Text       = "总计费用: " + (days * costRule.DayCost).ToString("C");
                dtActualTime.Value = dtStartTime.Value.AddDays((double)days);
            }
            if (cbRentalType.Text == "周租")
            {
                var     timespan = dtEndTime.Value - dtStartTime.Value;
                decimal days     = Convert.ToDecimal(timespan.TotalDays);
                decimal weeks    = days / 7;
                weeks              = Math.Ceiling(weeks);
                totalCost          = weeks * costRule.WeekCost;
                lbTotal.Text       = "总计费用: " + (weeks * costRule.WeekCost).ToString("C");
                dtActualTime.Value = dtStartTime.Value.AddDays((double)(weeks * 7));
            }
            if (cbRentalType.Text == "月租")
            {
                var     timespan = dtEndTime.Value - dtStartTime.Value;
                decimal days     = Convert.ToDecimal(timespan.TotalDays);
                decimal months   = days / 30;
                months             = Math.Ceiling(months);
                totalCost          = months * costRule.MonthCost;
                lbTotal.Text       = "总计费用: " + (months * costRule.MonthCost).ToString("C");
                dtActualTime.Value = dtStartTime.Value.AddMonths((int)months);
            }
            if (cbRentalType.Text == "季租")
            {
                var     timespan = dtEndTime.Value - dtStartTime.Value;
                decimal days     = Convert.ToDecimal(timespan.TotalDays);
                decimal months   = days / 30;
                decimal seasons  = months / 3;
                seasons            = Math.Ceiling(seasons);
                totalCost          = seasons * costRule.SeasonCost;
                lbTotal.Text       = "总计费用: " + (seasons * costRule.SeasonCost).ToString("C");
                dtActualTime.Value = dtStartTime.Value.AddMonths((int)(seasons * 3));
            }
            if (cbRentalType.Text == "年租")
            {
                var     timespan = dtEndTime.Value - dtStartTime.Value;
                decimal days     = Convert.ToDecimal(timespan.TotalDays);
                decimal years    = days / 365;
                years              = Math.Ceiling(years);
                totalCost          = years * costRule.YearCost;
                lbTotal.Text       = "总计费用: " + (years * costRule.YearCost).ToString("C");
                dtActualTime.Value = dtStartTime.Value.AddYears((int)years);
            }
            return(totalCost);
        }