/// <summary>
 /// 新增单个数据
 /// </summary>
 /// <param name="driverAbnormalNameList"></param>
 /// <returns></returns>
 public bool InsertObject(CarUseHisotry carUseHisotry)
 {
     string sql = "insert into TB_CarUseHisotry (GroupId,UserName,Telephone,DriverIdNumber,CarIdNumber,CreateTime) values(" +
         carUseHisotry.GroupId + ",'" + carUseHisotry.UserName + "','" + carUseHisotry.Telephone + "','" + carUseHisotry.DriverIdNumber + "','" +
         carUseHisotry.CarIdNumber + "','" + carUseHisotry.CreateTime + "' )";
     return AccessHelper.SQLExecute(sql);
 }
 public void InsertObject(CarUseHisotry carUseHisotry)
 {
     carUseHisotryDAL.InsertObject(carUseHisotry);
 }
        private void btnSaveManageCar_Click(object sender, EventArgs e)
        {
            if (txtdriverNameManage.Text == "")
            {
                MessageBox.Show("请配置司机");
                return;
            }
            if (txtCarManage.Text == "")
            {
                MessageBox.Show("请配置车辆");
                return;
            }
            CarUseHisotry carUseHisotry = new CarUseHisotry();
            if (dgvCustomerInfor.CurrentRow == null) {
                MessageBox.Show("请选择人员进行配置");
                return;
            }
            int currentDriverListIndex = dgvWriteDriverList.CurrentRow.Index;
            int driverId = Convert.ToInt32(dgvWriteDriverList.Rows[currentDriverListIndex].Cells["DriverId"].Value);
            carUseHisotry.DriverIdNumber = dgvWriteDriverList.Rows[currentDriverListIndex].Cells["身份证件号码"].Value.ToString();

            int currentCarListIndex = dgvCarList.CurrentRow.Index;
            int carId = Convert.ToInt32(dgvCarList.Rows[currentCarListIndex].Cells["CarId"].Value);
            carUseHisotry.CarIdNumber = dgvCarList.Rows[currentCarListIndex].Cells["车牌号"].Value.ToString();

            int currentUserListIndex = dgvCustomerInfor.CurrentRow.Index;
            int userId = Convert.ToInt32(dgvCustomerInfor.Rows[currentUserListIndex].Cells["Id"].Value);
            int groupId = dgvGroupList1.CurrentRow.Index;
            carUseHisotry.GroupId = Convert.ToInt32(dgvGroupList1.Rows[groupId].Cells["GroupId"].Value);

            int currentCustomerListIndex = dgvCustomerInfor.CurrentRow.Index;
            string currentCustomerUserName = dgvCustomerInfor.Rows[currentCustomerListIndex].Cells["用户名"].Value.ToString();
            carUseHisotry.UserName = dgvCustomerInfor.Rows[currentCustomerListIndex].Cells["用户名"].Value.ToString();
            carUseHisotry.Telephone = dgvCustomerInfor.Rows[currentCustomerListIndex].Cells["联系方式"].Value.ToString();
            carUseHisotry.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");

            int currentCarReuirmentIndex = dgvCarReuirment.CurrentRow.Index;
            string CarYaoqiu = dgvCarReuirment.Rows[currentCarReuirmentIndex].Cells["CarYaoqiu"].Value.ToString();
            string CarYongtu = dgvCarReuirment.Rows[currentCarReuirmentIndex].Cells["CarYongtu"].Value.ToString();
            string Other = dgvCarReuirment.Rows[currentCarReuirmentIndex].Cells["Other"].Value.ToString();

            //userBLL.UpdateIsUseStatus(userId);
            //User user = new User();
            //user.Id = carId;
            //dgvCustomerInfor.DataSource = userBLL.SelectbyUser(user);

            ManageCarRequiredment manageCarRequiredment = new ManageCarRequiredment();
            manageCarRequiredment.GroupId = Convert.ToInt32(dgvGroupList1.Rows[groupId].Cells["GroupId"].Value);
            manageCarRequiredment.UserName = currentCustomerUserName;
            manageCarRequiredment.DriverId = driverId;
            manageCarRequiredment.CarId = carId;
            manageCarRequiredment.CarYaoqiu = CarYaoqiu;
            manageCarRequiredment.CarYongtu = CarYaoqiu;
            manageCarRequiredment.Other = CarYaoqiu;

            manageCarRequiredment.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
            try
            {
                manageCarRequiredmentBLL.InsertObject(manageCarRequiredment);
            }
            catch (Exception ex)
            {

                MessageBox.Show("编辑信息错误");
            }

            driverWriteListBLL.UpdateIsUseStatus(driverId,1);
            calBll.UpdateIsUseStatus(carId,1);
            dgvWriteDriverList.DataSource = driverWriteListBLL.FindAllInfo();
            dgvCarList.DataSource = calBll.FindAllInfo();

            dgvManagedInfo.DataSource = manageCarRequiredmentBLL.FindAllInfo();
            MessageBox.Show("编辑成功!");
            try
            {
                carUseHisotryBLL.InsertObject(carUseHisotry);
            }
            catch (Exception ex)
            {

                MessageBox.Show("插入历史数据表错误");
                return;
            }
        }