Exemple #1
0
    private List <CarUseRecord> getRecordList()
    {
        List <CarUseRecord> result = new List <CarUseRecord>();
        //添加单品
        int row_num = Convert.ToInt16(ViewState["count"]);


        string[] ak = Request.Form.AllKeys;
        for (int i = 0; i < Request.Form.Count; i++)
        {
            //只筛选出动态生成的三个控件的值
            int counter = 0;
            if (ak[i].IndexOf("box") > -1)
            {
                CarUseRecord item = new CarUseRecord();
                item.Durings     = Request.Form[i++].ToString();
                item.Destination = Request.Form[i++].ToString();
                item.MilesBefore = Convert.ToDouble(Request.Form[i++]);
                item.MilesAfter  = Convert.ToDouble(Request.Form[i]);

                result.Add(item);
            }
        }

        return(result);
    }
Exemple #2
0
    protected void confirm_Click(object sender, EventArgs e)
    {
        CarUse ci = new CarUse();

        ci.StaffName      = staffName.Text;
        ci.DepartmentName = department.Text;
        ci.AlongCount     = Convert.ToInt32(alongCount.Value);
        ci.StartDate      = Convert.ToDateTime(startDate.Value);
        ci.EndDate        = Convert.ToDateTime(endDate.Value);
        ci.AlongName      = alongName.Text;
        ci.Destination    = destination.Value;
        ci.Driver         = driver.Value;
        ci.CarNum         = carNum.Value;
        ci.Reason         = reason.Text;
        ci.Note           = note.Text;
        ci.ApproveProcess = "";

        int recordid = CarUse.SetCarUseByID(-1, ci);
        List <CarUseRecord> recordList = getRecordList();

        CarUseRecord.SetCarUseRecord(recordList, recordid);



        Response.Redirect("~/Account/ApplyListPage.aspx");
    }
Exemple #3
0
    /// <summary>
    /// 新增或更新单条行车记录
    /// </summary>
    /// <param name="os"></param>
    /// <param name="applyID"></param>
    /// <param name="conn"></param>
    private static void SetSingleRecord(CarUseRecord os, int applyID, SqlConnection conn)
    {
        SqlCommand cmd = new SqlCommand("INSERT INTO [CarUseRecord] ([ApplyID], [Durings], [Destination], [MilesBefore], [MilesAfter]) VALUES (@ApplyID, @Durings, @Destination, @MilesBefore,  @MilesAfter)", conn);

        cmd.Parameters.Add("@ApplyID", SqlDbType.Int).Value         = applyID;
        cmd.Parameters.Add("@Durings", SqlDbType.VarChar).Value     = os.durings;
        cmd.Parameters.Add("@Destination", SqlDbType.VarChar).Value = os.destination;
        cmd.Parameters.Add("@MilesBefore", SqlDbType.Float).Value   = os.milesBefore;
        cmd.Parameters.Add("@MilesAfter", SqlDbType.Float).Value    = os.milesAfter;

        cmd.ExecuteNonQuery();
    }
Exemple #4
0
    /// <summary>
    /// 根据编号返回特定的车辆使用登记记录
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public static CarUse GetCarUseByID(int id)
    {
        SqlConnection conn = new SqlConnection(connString);
        SqlCommand    cmd  = new SqlCommand("SELECT * FROM [CarUseApplies] WHERE [ApplyID] = @ApplyID", conn);

        cmd.Parameters.Add("@ApplyID", SqlDbType.Int).Value = id;
        conn.Open();
        SqlDataReader sdr = cmd.ExecuteReader();
        CarUse        ci  = null;

        if (sdr.Read())
        {
            ci                  = new CarUse();
            ci.staffName        = (string)sdr["StaffName"];
            ci.departmentName   = (string)sdr["Department"];
            ci.startDate        = Convert.ToDateTime(sdr["StartDate"]);
            ci.endDate          = Convert.ToDateTime(sdr["EndDate"]);
            ci.alongCount       = (int)sdr["AlongCount"];
            ci.alongName        = (string)sdr["AlongName"];
            ci.reason           = (string)sdr["Reason"];
            ci.destination      = (string)sdr["Destination"];
            ci.driver           = (string)sdr["Driver"];
            ci.driveHistoryList = new List <CarUseRecord>();
            ci.carNum           = (string)sdr["CarNum"];
            ci.ApproveProcess   = sdr["ApproveProcess"] == DBNull.Value ? "" : (string)sdr["ApproveProcess"];
        }
        sdr.Close();
        conn.Close();

        List <CarUseRecord> result = new List <CarUseRecord>();

        result = CarUseRecord.GetCarUseRecordListByID(id);
        ci.driveHistoryList.AddRange(result);


        return(ci);
    }
Exemple #5
0
    /// <summary>
    /// 根据申购编号,获取对应的行车记录清单
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public static List <CarUseRecord> GetCarUseRecordListByID(int id)
    {
        SqlConnection conn = new SqlConnection(connString);
        SqlCommand    cmd  = new SqlCommand("SELECT * FROM [CarUseRecord] WHERE [ApplyID] = @ApplyID", conn);

        cmd.Parameters.Add("@ApplyID", SqlDbType.Int).Value = id;
        conn.Open();
        SqlDataReader       sdr    = cmd.ExecuteReader();
        List <CarUseRecord> result = new List <CarUseRecord>();

        while (sdr.Read())
        {
            CarUseRecord temp = new CarUseRecord();
            temp.durings     = (string)sdr["Durings"];
            temp.destination = (string)sdr["Destination"];
            temp.milesBefore = Convert.ToDouble(sdr["MilesBefore"]);
            temp.milesAfter  = Convert.ToDouble(sdr["MilesAfter"]);

            result.Add(temp);
        }

        conn.Close();
        return(result);
    }