Winform菜鸟驿站管理系统-数据报表制作方法和逻辑层代码展示

1,上一期分享快递完成度的统计,以及界面代码的展示,本期将展示DAL层和BLL层代码在界面初始化中代码显示如下;

 private void FrmExpCompletionStatistics_Load(object sender, EventArgs e)
 {
     //站点下拉框加载
     FormUtility.LoadCboStations(cboStations, stationBLL);
     cboStations.SelectedIndex = 0;
     //统计当前的完成度
     //默认加载已完成的列表
     dgvExpList.AutoGenerateColumns = false;
     StatisticsCompletionCount();
 }

2, 站点下拉框加载部分 BLL层

  /// 
  /// 加载站点下拉框
  /// 
  /// 
  public static void LoadCboStations(ComboBox cboStations, StationBLL statBLL)
  {
      List stationList01 = statBLL.GetCboStationList();
      stationList01.Insert(0, new StationInfo()
      {
          StationId=0,
          StationName= "请选择站点"
      });
      cboStations.DisplayMember = "StationName";
      cboStations.ValueMember = "StationId";
      cboStations.DataSource = stationList01;
  }

站点下拉框加载部分 DAL层 

/// 
/// 获取绑定下拉框的所有站点列表
/// 
/// 
public List GetCboStationList()
{
    return stationDAL.GetCboStationList();
}

3,上一期有个 根据站点统计完成度的方法实现如下:StatExpressCountData 如下是BLL层和DAL层代码

 /// 
 /// 快递完成度数量统计 
 /// 
 /// 
 /// 
 public List StatExpressCountData(int stationId = 0)
 {
     int[] reCounts = statisticsDAL.StatExpressCountData(stationId);
     List statList = new List();
     statList.Add(new ExpressCountInfo() { ExpState = "已完成数", ExpCount = reCounts[0] });
     statList.Add(new ExpressCountInfo() { ExpState = "未完成数", ExpCount = reCounts[1] });
     return statList;
 }

 DAL层

 /// 
 /// 统计快递完成度数量
 /// 
 /// 
 /// 
 public int[] StatExpressCountData(int stationId = 0)
 {
     string sql = "select * from StatisticsExpCompletion(" + stationId + ")";
     DataTable dt = SqlHelper.GetDataTable(sql, 1);
     int[] reCounts = new int[2];  //定义数组   new int[2] 表示两个长度的数组
     if (dt.Rows.Count>0)
     {
         reCounts[0] = (int)dt.Rows[0][0];
         reCounts[1] = (int)dt.Rows[0][1];
     }
     return reCounts;
 }

 3,数据类型转换  GetInt

/// 
/// 将object转换为int
/// 
/// 
/// 
public static int GetInt(this object oValue)
{
    int reInt = 0;
    try
    {
        reInt = Convert.ToInt32(oValue);
    }
    catch
    {
        reInt = 0;
    }

    return reInt;
}

 4,结果显示如下

Winform菜鸟驿站管理系统-数据报表制作方法和逻辑层代码展示_第1张图片

你可能感兴趣的:(C#,Winform,c#,开发语言)