码迷,mamicode.com
首页 > Windows程序 > 详细

C# FINEUI 多页签(tab)中的笔记

时间:2017-09-05 21:55:10      阅读:472      评论:0      收藏:0      [点我收藏+]

标签:sas   部分   void   制度   action   tostring   images   token   显示   

 

   一。FINEUI (MVC) 日期格式问题:

   FINEUI 日期控件从VIEW 到control 中的值传递问题(view 中的传值代码如 “txtDate1: F.ui.DatePicker1.getValue(),”  但是在control 里得到的格式 并非标准的 ‘yyyy-MM-dd’格式Thu Jun 01 2017 00:00:00 GMT+0800

 这种带时区的字符串不可转换成日期格式 可以用Substring()  取时区前面的部分。转换成日期格式 在转换成想要的格式 我的转换方式如:Convert.ToDateTime(txtDate2.Substring(0, 24)).ToString("yyyy-MM-dd");

二。FINEUI(MVC) 多页签公用查询 条件, 查询按钮导出按钮的解决方法。

  技术分享

由于页签的内容比较多,表头形式各异,所以在页面布局和公用部分做了很多尝试,现在写出的是比较笨的方法,把所有的页面全部的View代码和control 全部放一个view 页面和控制器页面 这样代码的复制度 确实复杂了很多。但是在这里我尝试着有了switch 语句 简化了代码 和逻辑。

a. 在View上 :  F.ui.TabStrip1.getActiveTabIndex() 获取当前活动的tab index ; 在活动的tab找到对应的Grid 的ID 再将所得Grid 做查询和导出按钮的参数

具体代码如下:

//alert("1");
//grid 表头
var grid_fields;
var grid_fields2;
//获取grid 的ID
var grid;
var grid2;
//获取活动tab
var active = F.ui.TabStrip1.getActiveTabIndex() + 1;
var active2 = F.ui.TabStrip2.getActiveTabIndex() + 3;

switch(active)
{

case 1:
grid_fields = F.ui.Grid1.fields;
grid = F.ui.Grid1;

break;
case 2:
grid_fields = F.ui.Grid2.fields;
grid = F.ui.Grid2;

break;
default:

break;

}
switch(active2)
{
case 3:
grid_fields2 = F.ui.Grid3.fields;
grid2 = F.ui.Grid3;
break;
case 4:
grid_fields2 = F.ui.Grid4.fields;
grid2 = F.ui.Grid4;
break;
case 5:
grid_fields2 = F.ui.Grid5.fields;
grid2 = F.ui.Grid5;
break;
case 6:
grid_fields2 = F.ui.Grid6.fields;
grid2 = F.ui.Grid6;
break;
default:
break;

}

// 触发后台事件
F.doPostBack(‘@Url.Action("Grid_ReBindGrid")‘, {
fields: grid_fields,
fields2: grid_fields2,
index1: active,
index2: active2,
pageIndex: grid.pageIndex,
pageSize: F.ui.ddlPageSize2.getValue(),
txtSite: F.ui.ddl_Site.getValue(),
txtDate1: F.ui.DatePicker1.getValue(),
txtDate2: F.ui.DatePicker2.getValue()
})

 

b control 页的 方法 在初始化时 ,给每一个tab 中的Grid 赋初值:

string sp_name1 = "P_MA_SASAD_LIST";
string sp_name2 = "P_MA_SASSG_LIST";
string sp_name3 = "P_MA_SASSM_LIST";
string sp_name4 = "P_MA_SASSC_LIST";
string sp_name5 = "P_MA_SASSS_LIST";
string sp_name6 = "P_MA_SASAD_LIST";


BindDDL_List();
string[] param = new string[3];
param[0] = "S10";
param[1] = "2017-06-01";
param[2] = "2017-12-01";
BindGrid1(sp_name1, param);
BindGrid(sp_name2, param);
BindGrid(sp_name3, param);
BindGrid(sp_name4, param);
BindGrid(sp_name5, param);
BindGrid(sp_name6, param);

由于取值方法查不到 我把它和并成一个方法

private void BindGrid(string sp_name, string[] param)
{
//表头

int iPageIndex = 1;
int iPageSize = 20;
string WhereStr = " 1=1 ";
//表内容
DataTable dtHead = QueryCommonTst.GetQueryResult(sp_name, "column", iPageIndex, iPageSize, WhereStr, param);

DataTable dt = QueryCommonTst.GetQueryResult(sp_name, "list", iPageIndex, iPageSize, WhereStr, param);

switch (sp_name)
{
case "P_MA_SASSG_LIST":
//表头
ViewBag.Grid2Columns = GridCommon.GridHeadColumns(dtHead);
//表记录
ViewBag.Grid2RecordCount = Convert.ToInt32(QueryCommonTst.GetQueryResult(sp_name, "count", 1, 99999, WhereStr, param).Rows[0][0]);
//表内容
ViewBag.Grid2DataSource = dt;
break;
case "P_MA_SASSM_LIST":
//表头
ViewBag.Grid3Columns = GridCommon.GridHeadColumns(dtHead);
//表记录
ViewBag.Grid3RecordCount = Convert.ToInt32(QueryCommonTst.GetQueryResult(sp_name, "count", 1, 99999, WhereStr, param).Rows[0][0]);
//表内容
ViewBag.Grid3DataSource = dt;
break;
case "P_MA_SASSC_LIST":
//表头
ViewBag.Grid4Columns = GridCommon.GridHeadColumns(dtHead);
//表记录
ViewBag.Grid4RecordCount = Convert.ToInt32(QueryCommonTst.GetQueryResult(sp_name, "count", 1, 99999, WhereStr, param).Rows[0][0]);
//表内容
ViewBag.Grid4DataSource = dt;
break;
case "P_MA_SASSS_LIST":
//表头
ViewBag.Grid5Columns = GridCommon.GridHeadColumns(dtHead);
//表记录
ViewBag.Grid5RecordCount = Convert.ToInt32(QueryCommonTst.GetQueryResult(sp_name, "count", 1, 99999, WhereStr, param).Rows[0][0]);
//表内容
ViewBag.Grid5DataSource = dt;
break;
case "P_MA_SASAD_LIST":
//表头
ViewBag.Grid6Columns = GridCommon.GridHeadColumns(dtHead);
//表记录
ViewBag.Grid6RecordCount = Convert.ToInt32(QueryCommonTst.GetQueryResult(sp_name, "count", 1, 99999, WhereStr, param).Rows[0][0]);
//表内容
ViewBag.Grid6DataSource = dt;
break;
default:
break;

}

}
#endregion 数据绑定

 

查询数据方法和初始化时思路一样

#region 查询数据
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Grid_ReBindGrid(JArray fields, JArray fields2, int index1, int index2, int pageIndex, int pageSize, string txtSite, string txtDate1, string txtDate2)
{
string sp_name = "";
string sp_name2 = "";
FineUIMvc.GridAjaxHelper grid ;
FineUIMvc.GridAjaxHelper grid2;

switch (index1)
{
case 1:

grid = UIHelper.Grid("Grid1");
sp_name = "P_MA_SASSD_LIST";
break;
case 2:
grid = UIHelper.Grid("Grid2");
sp_name = "P_MA_SASSG_LIST";
break;
default:
grid = UIHelper.Grid("Grid1");
sp_name = "P_MA_SASSD_LIST";
break;
}
switch (index2)
{
case 3:
grid2 = UIHelper.Grid("Grid3");
sp_name2 = "P_MA_SASSM_LIST";
break;
case 4:
grid2 = UIHelper.Grid("Grid4");
sp_name2 = "P_MA_SASSC_LIST";
break;
case 5:
grid2 = UIHelper.Grid("Grid5");
sp_name2 = "P_MA_SASSS_LIST";
break;
case 6:
grid2 = UIHelper.Grid("Grid6");
sp_name2 = "P_MA_SASAD_LIST";
break;
default:
grid2 = UIHelper.Grid("Grid1");
sp_name2 = "P_MA_SASSD_LIST";
break;
}

string text = txtDate1.Substring(1, 24);
string txtBegin = Convert.ToDateTime(txtDate1.Substring(0,24)).ToString("yyyy-MM-dd");
string txtEnd = Convert.ToDateTime(txtDate2.Substring(0, 24)).ToString("yyyy-MM-dd");

string[] aryKey = new string[3];
aryKey[0] = txtSite;
aryKey[1] = txtBegin;
aryKey[2] = txtEnd;

string WhereStr = " 1=1 ";

DataTable dt = QueryCommonTst.GetQueryResult(sp_name, "list", pageIndex + 1, pageSize, WhereStr, aryKey);
DataTable dt2 = QueryCommonTst.GetQueryResult(sp_name2, "list", pageIndex + 1, pageSize, WhereStr, aryKey);
//表记录
int count1 = Convert.ToInt32(QueryCommonTst.GetQueryResult(sp_name, "count", 1, 99999, WhereStr, aryKey).Rows[0][0]);
int count2 = Convert.ToInt32(QueryCommonTst.GetQueryResult(sp_name2, "count", 1, 99999, WhereStr, aryKey).Rows[0][0]);

// 1.设置总项数(数据库分页回发时,如果总记录数不变,可以不设置RecordCount)
grid.RecordCount(count1);
grid2.RecordCount(count2);

// 2. 设置每页显示项数(每页记录数改变时,要设置PageSize)
grid.PageSize(pageSize);
grid2.PageSize(pageSize);

grid.DataSource(dt, fields);
grid2.DataSource(dt2, fields2);
return UIHelper.Result();
}
#endregion 查询数据
}

 

C# FINEUI 多页签(tab)中的笔记

标签:sas   部分   void   制度   action   tostring   images   token   显示   

原文地址:http://www.cnblogs.com/hzf08/p/7481975.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!