/// <summary> /// 初始化Grid /// </summary> /// <param name="ModuleCode"></param> /// <param name="Namespace"></param> /// <param name="param"></param> /// <returns></returns> public DataTable GetListPageAllRecords(string ModuleCode, string Namespace, Dictionary <string, string> param) { //读出配置存储过程及参数 Bll_Sys_Config_ListPage ConfigMInstance = new Bll_Sys_Config_ListPage(); Bll_Bse_Dict DictInstance = new Bll_Bse_Dict(); Bll_Sys_Config_Fieled FieldInstance = new Bll_Sys_Config_Fieled(); Sys_Config_ListPage config = ConfigMInstance.GetListByCode(" AND M_ModuleCode='" + ModuleCode + "' ")[0]; List <Sys_Config_Fieled> ListField = FieldInstance.GetListByCode(" AND D_ModuleCode='" + ModuleCode + "'"); List <SqlParameter> list = new List <SqlParameter>(); SqlParameter search = new SqlParameter("@Search", param["@Search"]); list.Add(search); SqlParameter sidx = new SqlParameter("@Sidx", param["@Sidx"]); list.Add(sidx); SqlParameter sord = new SqlParameter("@Sord", param["@Sord"]); list.Add(sord); SqlParameter userid = new SqlParameter("@Userid", param["@Userid"]); list.Add(userid); SqlParameter deptid = new SqlParameter("@Deptid", param["@Deptid"]); list.Add(deptid); SqlParameter modulecode = new SqlParameter("@ModuleCode", ModuleCode); list.Add(modulecode); SqlParameter _namespace = new SqlParameter("@NameSpace", Namespace); list.Add(_namespace); SqlParameter InlineType = new SqlParameter("@InlineType", param["@InlineType"]); list.Add(InlineType); SqlParameter GeneralType = new SqlParameter("@GeneralType", param["@GeneralType"]); list.Add(GeneralType); DataTable newDt = instance.idb.RunProcReturnDatatable(config.M_SQL, list.ToArray()); #region Old,已被废弃掉的代码片段 By Ye Fei 2011-01-30 //首先获取config_filed表中有数据字典的列及相关数据字典标示 //var newList = ListField.Where(o => !string.IsNullOrEmpty(o.D_DictKey) && o.D_EditType.ToLower()=="dict" && o.D_Hidden!="true" ); //if (newList.Count()>0) //{ // for (int i = 0; i < newDt.Rows.Count; i++) // { // foreach (Sys_Config_Fieled item in newList) // { // var DictResult = DictInstance.GetListByCode(" AND Dict_Code='" + // newDt.Rows[i][item.D_Index].ToString() // + "' AND Dict_Key='"+item.D_DictKey+"' "); // if (DictResult.Count > 0) // { // newDt.Rows[i][item.D_Index] = DictResult.FirstOrDefault().Dict_Name; // } // if (param["@InlineType"].Length > 0) // { // //物料动态字典取值 // string dynKey = param["@InlineType"] + "TYPE"; // var Result = DictInstance.GetListByCode(" AND Dict_Code='" + // newDt.Rows[i][item.D_Index].ToString() // + "' AND Dict_Key='" + dynKey.ToUpper() + "' "); // if (Result.Count > 0) // { // newDt.Rows[i][item.D_Index] = Result.FirstOrDefault().Dict_Name; // } // } // } // } //} ///排序 //if (!string.IsNullOrEmpty(config.M_TableName)) //{ // Bll_Comm commInstance = new Bll_Comm(); // DataSet ds = commInstance.GetTableInfo(config.M_TableName); // string TableKey = commInstance.GetTableKey(ds); // if (!string.IsNullOrEmpty(TableKey)) // { // DataView dv = newDt.DefaultView; // dv.Sort = TableKey + " desc"; // newDt = dv.ToTable(); // } //} #endregion return(newDt); }
public DataTable GetPagedTable(DataTable dt, int PageIndex, int PageSize, string moduleCode) { if (PageIndex == 0) return null; DataTable newdt = dt.Clone(); #region 获取字典相关信息 //获取列表字段的配置信息 Bll_Sys_Config_Fieled filedInstance = new Bll_Sys_Config_Fieled(); Bll_Bse_Dict DictInstance = new Bll_Bse_Dict(); List<Sys_Config_Fieled> listField = filedInstance.GetListByCode(" AND D_ModuleCode='" + moduleCode + "'"); string dictKeyList = "''"; foreach (var field in listField) { if (!string.IsNullOrEmpty(field.D_DictKey)) { dictKeyList += ",'" + field.D_DictKey + "'"; } } //获取配置信息中所有的字典表关键字里拥有的字典信息 List<Bse_Dict> listDictionary = DictInstance.GetListByCode(" and (dict_key in (" + dictKeyList + "))"); #endregion //newdt.Clear(); int rowbegin = (PageIndex - 1) * PageSize; int rowend = PageIndex * PageSize; if (rowbegin >= dt.Rows.Count)//如果开始列数大于所拥有的列数 rowbegin = 0; if (rowend > dt.Rows.Count) rowend = dt.Rows.Count; for (int i = rowbegin; i <= rowend - 1; i++) { DataRow newdr = newdt.NewRow(); DataRow dr = dt.Rows[i]; foreach (DataColumn column in dt.Columns) { newdr[column.ColumnName] = dr[column.ColumnName]; //更新字典信息 var field = listField.Where(o => o.D_Index == column.ColumnName).FirstOrDefault(); if (field!=null&&!string.IsNullOrEmpty(field.D_DictKey)) { Bse_Dict dict = listDictionary.Where(o => o.Dict_Code == dr[column.ColumnName].ToString()).FirstOrDefault(); if (dict != null) { newdr[column.ColumnName] = dict.Dict_Name; } } //对编码进行转换 //if (field!=null && !string.IsNullOrEmpty(field.D_UDEF1)) //{ // string[] Converts = field.D_UDEF1.Split(','); // if (Converts.Count()==3) // { // if (dr[column.ColumnName]!=null && !string.IsNullOrEmpty(dr[column.ColumnName].ToString())) // { // var data = instance.ListDataByCode(Converts[0], Converts[1] + "='" + dr[column.ColumnName].ToString() + "'"); // if (data.Rows.Count>0) // { // newdr[column.ColumnName] = data.Rows[0][Converts[2]].ToString(); // } // } // } //} } newdt.Rows.Add(newdr); } return newdt; }
public ActionResult List(string id, int page, int rows, string search, string sidx, string sord) { string filters = Request["filters"] == null ? "" : Request["filters"].ToString(); string filtersSql = ""; if (!string.IsNullOrEmpty(filters)) { filtersSql = BulidJqGridSearch.BuildSearch(filters); } //string List<Bse_Employee> list = new List<Bse_Employee>(); if (string.IsNullOrEmpty(id)) { if (!string.IsNullOrEmpty(filtersSql)) { list = hrInstance.GetListByCode(" AND " + filtersSql); }else{ list = hrInstance.GetAll(); } } else { if (!string.IsNullOrEmpty(filtersSql)) { list = hrInstance.GetStuffByDept(id, " AND " + filtersSql); } else { list = hrInstance.GetStuffByDept(id); } } Bll_Bse_Dict dictInstance = new Bll_Bse_Dict(); //字典替换 foreach (var listmodel in list) { switch (listmodel.Emp_Gendar) { case "G001": { listmodel.Emp_Gendar = "男"; break; } case "G002": { listmodel.Emp_Gendar = "女"; break; } } if (!string.IsNullOrEmpty(listmodel.Emp_Title)) { var _model=dictInstance.GetModel(" and dict_key='STUFFTITLE' and dict_code='" + listmodel.Emp_Title + "'"); listmodel.Emp_Title = _model != null ? _model.Dict_Name : ""; } if (!string.IsNullOrEmpty(listmodel.Emp_Duty)) { var _model = dictInstance.GetModel(" and dict_key='STUFFDUTYTYPE' and dict_code='" + listmodel.Emp_Duty + "'"); listmodel.Emp_Duty = _model != null ? _model.Dict_Name : ""; } } var model = list.AsQueryable<Bse_Employee>(); var result = JsonConvert.SerializeObject(model.ToJqGridData(page, rows, null, search, null), new JsonDateConverter("yyyy-MM-dd")); return JavaScript(result); }
public void BindTopTool() { ToolBarHelper tsHelper = new ToolBarHelper(); this.top_tool_bar.SaveClicked += new EventHandler(top_tool_bar_SaveClicked); scanBtn = tsHelper.New("扫描", QX.GenFramework.Properties.Resources.gantan, new EventHandler(scanBtn_Click)); this.top_tool_bar.AddCustomControl(scanBtn); Bll_Bse_Dict dcInstance = new Bll_Bse_Dict(); List<Bse_Dict> list = dcInstance.GetDictByKey("ScanMode"); comboStat.DataSource = list; comboStat.DisplayMember = "Dict_Name"; comboStat.ValueMember = "Dict_Code"; comboStat.Tag = list; ToolStripControlHost comboStatHost = new ToolStripControlHost(comboStat); comboStatHost.Margin = new Padding(5, 0, 0, 0); this.top_tool_bar.AddCustomControl(6, comboStatHost); }
public ActionResult GetData(int page, int rows, string search, string sidx, string sord) { string Name = Request["name"] == null ? "" : Request["name"].ToString(); string filters = Request["filters"] == null ? "" : Request["filters"].ToString(); string filter = Request["filter"] == null ? "" : Request["filter"].ToString(); string ModuleName = Request["m"] == null ? "" : Request["m"].ToString(); string NameSpace = Request["n"] == null ? "" : Request["n"].ToString(); string filtersSql = string.Empty; string mapSqlFilter = string.Empty; if (!string.IsNullOrEmpty(filters)) { filtersSql = BulidJqGridSearch.BuildSearch(filters); } BLL.Bll_Sys_Config_Refer configRefer = new QX.BLL.Bll_Sys_Config_Refer(); BLL.Bll_Sys_Config_Field_Refer configReferList = new Bll_Sys_Config_Field_Refer(); Sys_Config_Refer model = configRefer.GetListByCode(" AND R_ModuleName='" + ModuleName + "'")[0]; var referList = configReferList.GetListByCode(" AND D_ModuleName='" + ModuleName + "'").Where(o=>!string.IsNullOrEmpty(o.D_DictKey)); BLL.Bll_Bse_Dict DictInstance = new Bll_Bse_Dict(); DataTable dt = new DataTable(); if (!string.IsNullOrEmpty(model.R_SQL)) { if (!string.IsNullOrEmpty(filter)) { model.R_SQL = model.R_SQL + filter; } if (!string.IsNullOrEmpty(filtersSql)) { model.R_SQL = model.R_SQL + " AND " + filtersSql; } dt = configRefer.ListBySql(model.R_SQL); } else { string _filtersql = !String.IsNullOrEmpty(model.R_FilterSql) ? model.R_FilterSql : ""; _filtersql = _filtersql + filter; #region 特殊映射处理 if (ModuleName=="HR_StuffModule") { //读取映射配置表中公司配置 Bll_Comm comm = new Bll_Comm(); string mapFilter = ""; var mapModel = comm.CommMap(ModuleName, "Company"); if (mapModel!=null) { var deptList = comm.GetChildListDeptNon(comm.CommMap(ModuleName, "Company").Map_Object); if (deptList.Count()>0) { foreach (var item in deptList) { } for (int i = 0; i < deptList.Count;i++ ) { if (i==(deptList.Count-1)) { mapFilter += "'" + deptList[i].Dept_Code+"'"; } else { mapFilter += "'" + deptList[i].Dept_Code+ "',"; } } mapFilter.TrimEnd(','); } mapSqlFilter = " Stuff_DepCode in(" + mapFilter + ")"; } } #endregion //为空时不初始化 //if (!string.IsNullOrEmpty(filter)) //{ // dt = configRefer.ListDataByCode(Name, _filtersql, filtersSql + mapSqlFilter); //} dt = configRefer.ListDataByCode(Name, _filtersql, filtersSql + mapSqlFilter); } DataTable newdt = DataTablePage.GetPagedTable(dt, page, rows); #region 字典进行转换 //对字典进行转换 for (int i = 0; i < newdt.Rows.Count; i++) { foreach (var item in referList.ToList()) { var value = newdt.Rows[i][item.D_Index] != null ? newdt.Rows[i][item.D_Index].ToString() : ""; var DictResult = DictInstance.GetListByCode(" AND Dict_Code='" + value + "' AND Dict_Key='" + item.D_DictKey + "' "); if (DictResult.Count > 0) { newdt.Rows[i][item.D_Index] = DictResult.FirstOrDefault().Dict_Name; } } } #endregion var json = DataTablePage.JsonForJqgrid(newdt, page, rows, dt.Rows.Count); return JavaScript(json); }
/// <summary> /// 零件图号 回车事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void comCode_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { var uCom = (UltraCombo)sender; string val = uCom.Text; if (!string.IsNullOrEmpty(val)) { try { List<Tpl_ReqDoc> dlist = LoadReqDoc(val); comGrid.EventManager.SetEnabled(EventGroups.AllEvents, false); Bll_Bse_Dict dictInstance = new Bll_Bse_Dict(); comGrid.DisplayLayout.Override.AllowAddNew = AllowAddNew.TemplateOnBottom; var dictList = dictInstance.GetDictByKey("DocType"); foreach (var d in dlist) { UltraGridRow nrow = comGrid.DisplayLayout.Bands[0].AddNew(); nrow.Cells["PRDQ_IsNeed"].Value = d.TPRD_IsReq; var dict = dictList.FirstOrDefault(o => o.Dict_Code == d.TPRD_Type); nrow.Cells["PRDQ_Name"].Value = dict.Dict_Name + "报告"; nrow.Cells["PRDQ_Type"].Value = d.TPRD_Type; nrow.Cells["PRDQ_Date"].Value = DateTime.Now; nrow.Cells["PRDQ_Owner"].Value = SessionConfig.UserName; nrow.Cells["PRDQ_Result"].Value = "Check"; } uCom.Focus(); comGrid.EventManager.SetEnabled(EventGroups.AllEvents, true); } catch (Exception ex) { //写入数据库日志 PlateLog.WriteError(SessionConfig.UserID, SessionConfig.UserName, "", "CompManage", ex.Message, PlateLog.LogMessageType.Error, ex); } } } }
void BatchComp_Load(object sender, EventArgs e) { Bll_Bse_Dict dictInstance = new Bll_Bse_Dict(); DictList = dictInstance.GetDictByKey("DocType"); GModel = new Prod_Components(); this.FormClosed += new FormClosedEventHandler(BatchComp_FormClosed); BindData(); }
/// <summary> /// 初始化Grid /// </summary> /// <param name="ModuleCode"></param> /// <param name="Namespace"></param> /// <param name="param"></param> /// <returns></returns> public DataTable GetListPageAllRecords(string ModuleCode,string Namespace,Dictionary<string,string> param) { //读出配置存储过程及参数 Bll_Sys_Config_ListPage ConfigMInstance = new Bll_Sys_Config_ListPage(); Bll_Bse_Dict DictInstance = new Bll_Bse_Dict(); Bll_Sys_Config_Fieled FieldInstance = new Bll_Sys_Config_Fieled(); Sys_Config_ListPage config = ConfigMInstance.GetListByCode(" AND M_ModuleCode='" + ModuleCode + "' ")[0]; List<Sys_Config_Fieled> ListField = FieldInstance.GetListByCode(" AND D_ModuleCode='" + ModuleCode + "'"); List<SqlParameter> list = new List<SqlParameter>(); SqlParameter search = new SqlParameter("@Search",param["@Search"]); list.Add(search); SqlParameter sidx = new SqlParameter("@Sidx", param["@Sidx"]); list.Add(sidx); SqlParameter sord = new SqlParameter("@Sord", param["@Sord"]); list.Add(sord); SqlParameter userid = new SqlParameter("@Userid", param["@Userid"]); list.Add(userid); SqlParameter deptid = new SqlParameter("@Deptid", param["@Deptid"]); list.Add(deptid); SqlParameter modulecode = new SqlParameter("@ModuleCode", ModuleCode); list.Add(modulecode); SqlParameter _namespace = new SqlParameter("@NameSpace", Namespace); list.Add(_namespace); SqlParameter InlineType = new SqlParameter("@InlineType", param["@InlineType"]); list.Add(InlineType); SqlParameter GeneralType = new SqlParameter("@GeneralType", param["@GeneralType"]); list.Add(GeneralType); DataTable newDt=instance.idb.RunProcReturnDatatable(config.M_SQL,list.ToArray()); #region Old,已被废弃掉的代码片段 By Ye Fei 2011-01-30 //首先获取config_filed表中有数据字典的列及相关数据字典标示 //var newList = ListField.Where(o => !string.IsNullOrEmpty(o.D_DictKey) && o.D_EditType.ToLower()=="dict" && o.D_Hidden!="true" ); //if (newList.Count()>0) //{ // for (int i = 0; i < newDt.Rows.Count; i++) // { // foreach (Sys_Config_Fieled item in newList) // { // var DictResult = DictInstance.GetListByCode(" AND Dict_Code='" + // newDt.Rows[i][item.D_Index].ToString() // + "' AND Dict_Key='"+item.D_DictKey+"' "); // if (DictResult.Count > 0) // { // newDt.Rows[i][item.D_Index] = DictResult.FirstOrDefault().Dict_Name; // } // if (param["@InlineType"].Length > 0) // { // //物料动态字典取值 // string dynKey = param["@InlineType"] + "TYPE"; // var Result = DictInstance.GetListByCode(" AND Dict_Code='" + // newDt.Rows[i][item.D_Index].ToString() // + "' AND Dict_Key='" + dynKey.ToUpper() + "' "); // if (Result.Count > 0) // { // newDt.Rows[i][item.D_Index] = Result.FirstOrDefault().Dict_Name; // } // } // } // } //} ///排序 //if (!string.IsNullOrEmpty(config.M_TableName)) //{ // Bll_Comm commInstance = new Bll_Comm(); // DataSet ds = commInstance.GetTableInfo(config.M_TableName); // string TableKey = commInstance.GetTableKey(ds); // if (!string.IsNullOrEmpty(TableKey)) // { // DataView dv = newDt.DefaultView; // dv.Sort = TableKey + " desc"; // newDt = dv.ToTable(); // } //} #endregion return newDt; }
private void BindTopTool() { #region 库存 Bll_Bse_Dict dcInstance = new Bll_Bse_Dict(); List<Bse_Dict> list = dcInstance.GetDictByKey("SearchType"); comboStat.DataSource = list; comboStat.DisplayMember = "Dict_Name"; comboStat.ValueMember = "Dict_Code"; comboStat.Tag = list; this.top_tool_bar.SearchClicked += new EventHandler(top_tool_bar_SearchClicked); this.top_tool_bar.AddSearchAllModule(); ToolStripControlHost comboStatHost = new ToolStripControlHost(comboStat); comboStatHost.Margin = new Padding(5, 0, 0, 0); this.top_tool_bar.AddCustomControl(6, comboStatHost); ToolBarHelper tsHelper = new ToolBarHelper(); ToolStripButton btnDownload = tsHelper.New("下载", QX.GenFramework.Properties.Resources.import, new EventHandler(btnDownload_Click)); this.top_tool_bar.AddCustomControl(9, btnDownload); #endregion }
public void BindData() { //bmHelper.BindModelToControl<Prod_Components>(GModel, this.gpBse.Controls, ""); BLL.Bll_Bse_Dict dictInstance = new QX.BLL.Bll_Bse_Dict(); List<Bse_Dict> list1 = dictInstance.GetDictByKey("DocType"); List<Prod_Doc> list = new List<Prod_Doc>(); foreach (var d in list1) { Prod_Doc doc = new Prod_Doc(); doc.PRDQ_Type = d.Dict_Code; doc.PRDQ_iType = iTypeEnum.Comp.ToString(); doc.PRDQ_Name = d.Dict_Name + "报告"; doc.PRDQ_IsNeed = "Yes"; list.Add(doc); } //List<Prod_Doc> list = compInstance.getpd(GModel.PRDC_CompNo); List<CC_File> fileList = new List<CC_File>(); CurrentDataSource = fileList.ToList(); BindingSource dataSource = new BindingSource(); dataSource.DataSource = list; comGrid.DataSource = dataSource; BindingSource data11 = new BindingSource(); data11.DataSource = CompSource; otherCompGrid.DataSource = data11; InitRefCompList = new Dictionary<string, List<Prod_Components>>(); RefCompList = new Dictionary<string, List<Prod_Components>>(); }