protected void ExportMedicineWarehouseInven_Click(object sender, EventArgs e) { string sTime = STime.Value; string eTime = ETime.Value; string Warehousing = Warehouse.Value; string DrugName = drugname.Value; WarehouseInvenModel rm = new WarehouseInvenModel(); DataTable dt = rm.finMedicineInventoryInfor(Warehousing, sTime, eTime, DrugName); System.DateTime currentTime = new System.DateTime(); currentTime = System.DateTime.Now; string now = currentTime.ToString("yyyyMMdd"); CreateExcel(dt, "application/ms-excel", "药房库存盘点" + now); }
} //提供数据的方法 public dotNetFlexGrid.DataHandlerResult DotNetFlexGrid1DataHandler(dotNetFlexGrid.DataHandlerParams p) { dotNetFlexGrid.DataHandlerResult result = new dotNetFlexGrid.DataHandlerResult(); result.page = p.page; //设定当前返回的页号 result.total = 100; //总计的数据条数,此处用100进行模拟,查询和筛选时需要根据实际 WarehouseInvenModel rm = new WarehouseInvenModel(); string Warehouse = ""; if (p.extParam.ContainsKey("Warehouse")) { Warehouse = p.extParam["Warehouse"]; } string STime = ""; if (p.extParam.ContainsKey("STime")) { STime = p.extParam["STime"]; } string ETime = ""; if (p.extParam.ContainsKey("ETime")) { ETime = p.extParam["ETime"]; } string drugname = ""; if (p.extParam.ContainsKey("drugname")) { drugname = p.extParam["drugname"]; } int pageSize = p.rp; result.table = rm.finMedicineInventoryInfor(Warehouse, STime, ETime, drugname); dotNetFlexGrid.FieldFormatorHandle proc = delegate(DataRow dr) { int a = Convert.ToInt32(dr["InventoryStatus"].ToString()); if (a == 0) { return("安全"); } else { return("不安全"); } }; result.FieldFormator.Register("InventoryStatus", proc); dotNetFlexGrid.FieldFormatorHandle proc2 = delegate(DataRow dr) { int a = Convert.ToInt32(dr["StorageCondition"].ToString()); if (a == 0) { return("合格"); } else { return("不合格"); } }; result.FieldFormator.Register("StorageCondition", proc2); result.FieldFormator.Register("InventoryStatus", proc); /* dotNetFlexGrid.FieldFormatorHandle proc4 = delegate(DataRow dr) * { * int iamount=0; * int famount = 0; * if (dr["iamount"].ToString() == "") * { * iamount = 0; * } * else * { * iamount = Convert.ToInt32(dr["iamount"].ToString()); * } * * if (dr["famount"].ToString() == "") * { * famount=0; * } * else * { * * famount = Convert.ToInt32(dr["famount"].ToString()); * } * * int c = iamount - famount; * if (c < 0) * { * c = -c; * } * * string cstr = c.ToString(); * * return cstr; * * }; * result.FieldFormator.Register("kucun", proc4); * * */ /* dotNetFlexGrid.FieldFormatorHandle proc5 = delegate(DataRow dr) * { * * if (dr["iamount"].ToString() == "") * { * return "0"; * } * else * { * return dr["iamount"].ToString(); * } * * }; * result.FieldFormator.Register("iamount", proc5); * * * dotNetFlexGrid.FieldFormatorHandle proc6 = delegate(DataRow dr) * { * * if (dr["famount"].ToString() == "") * { * return "0"; * } * else * { * return dr["famount"].ToString(); * } * * }; * result.FieldFormator.Register("famount", proc6); */ dotNetFlexGrid.FieldFormatorHandle proc3 = delegate(DataRow dr) { int a = Convert.ToInt32(dr["kucun"].ToString()) - Convert.ToInt32(dr["ActualCapacity"].ToString()); if (a < 0) { a = -a; } return(a.ToString()); }; result.FieldFormator.Register("chazhi", proc3); return(result); }