日期:2014-05-17  浏览次数:21511 次

先道歉,停车场算法,这次自己认真写了。还是有一些问题
本帖最后由 bulls5988 于 2013-11-29 10:50:30 编辑
上次提问有老大说我不认真;确实是这几天硬件工程布线和软件开发一起做,弄的乱七八糟的有时候发了贴隔天才能回,公司物业部把开发和工程布线都给了我这一个部门。这里先诚恳道歉了


大家给了我很多代码,非常非常的感谢。想了想还是自己写代码好一点,是个锻炼尽量不做伸手党。实在解决不了再请教大家。回家认真的写了一下,现在TextBox1.Text返回的值是0,请教大家我的思路对不对?是什么地方出问题呢?


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using my_cardclass;
using System.Data.SqlClient;

namespace carpark_fee_system
{
    public partial class test : Form
    {
        public test()
        {
            InitializeComponent();
        }

        private static int staff_times(DateTime start_time, 
        DateTime end_time, int fee_standard)
        {
            /*
             * 停车时间收费算法;周一到周五,早点~23点免费。
             * 其他时段收费(标准为 fee_standard元 每小时)
             * 周六,日无免费时段(标准为 fee_standard元 每小时);
            */
            int totalhours = 0;//停车总时间
            int totalfee = 0;//总停车费
            TimeSpan ts = end_time.Date - start_time.Date;//停车日期和离开日期的时间差
            if ((int)ts.Days > 0)//如果停车时间和离开时间不是同一天
            {
                totalhours = long_time(start_time, end_time);//调用多日停车时间算法
            }
            else
            {
                totalhours = same_day(start_time, end_time);//调用当日停车时间算法
            }
            totalfee = totalhours * fee_standard;//总费用 = 总时间 * 收费标准
            return totalfee;//返回总费用
        }


        private static int long_time(DateTime dateTime1, DateTime dateTime2)
        {
        &n