using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; using Infragistics.WebUI.UltraWebGrid; using System.Drawing; using System.Text.RegularExpressions; using System.IO; using Infragistics.WebUI.UltraWebGrid.Exporter; /// <summary> /// Ctr_comm 的摘要说明 /// </summary> public class Ctr_comm { public Ctr_comm() { // // TODO: 在此处添加构造函数逻辑 // } //UltraWebGrid 初始化函数 public void initializeUD(UltraWebGrid ud, string StrHeadText, string ColSize, int IntWidth, int IntHeight, int RowHead, int SortYN, int RowSel, int RowDefault, int Groupby) {//初始化控件 try { string[] HeadTextArray, HeadSizeArray; string Str_Select = "", Str_Sql = ""; int i,Width = 0; Color HeadCol = Color.FromName("#e1eded"); Color SelCol = Color.FromName("#FFFFCD"); //ud.DisplayLayout switch(IntWidth) { case 1280: Width = 960; break; case 1024: Width = 720; break; case 1440: Width = 1130; break; case 600: Width = 750; break; default : Width = 800; break; } ud.Width = Width; ud.Height = IntHeight; //禁止生成列 ud.DisplayLayout.AutoGenerateColumns = false; //ud.DisplayLayout. HeadTextArray = Regex.Split(StrHeadText, "//", RegexOptions.IgnoreCase); HeadSizeArray = Regex.Split(ColSize, "//", RegexOptions.IgnoreCase); //style name ud.StyleSetName = "Office2007Black"; //ud.Rows.Add(); //calculate the columns width for (i = 0; i < HeadTextArray.Length; i++) { ud.Columns.Add("Col" + i.ToString().ToUpper()); ud.Columns[i].Header.Caption = HeadTextArray[i]; ud.Columns[i].Header.Style.HorizontalAlign = HorizontalAlign.Center; ud.Columns[i].Header.Style.Font.Bold = true; ud.Columns[i].Width = Convert.ToInt32(HeadSizeArray[i]); Str_Select += HeadTextArray[i] + ","; } //行头颜色 ud.DisplayLayout.HeaderStyleDefault.BackColor = HeadCol; //居中显示 ud.DisplayLayout.RowStyleDefault.HorizontalAlign = HorizontalAlign.Center; //设置是否要行头 switch (RowHead) { case 0://使用 ud.DisplayLayout.Bands[0].RowSelectors = RowSelectors.Yes; ud.DisplayLayout.AllowRowNumberingDefault = RowNumbering.ByBandLevel; ud.DisplayLayout.RowSelectorStyleDefault.Width = Unit.Pixel(30); ud.DisplayLayout.Bands[0].RowSelectorStyle.BackColor = SelCol; break; case 1: //不使用 ud.DisplayLayout.Bands[0].RowSelectors = RowSelectors.No; break; } //是否默认可以点击排序 switch (SortYN) { case 0: //使用 ud.DisplayLayout.HeaderClickActionDefault = HeaderClickAction.SortMulti; ud.DisplayLayout.HeaderStyleDefault.HorizontalAlign = HorizontalAlign.Center; ud.DisplayLayout.AllowSortingDefault = AllowSorting.OnClient; break; case 1: ud.DisplayLayout.HeaderClickActionDefault = HeaderClickAction.NotSet; break; } //默认颜色排列 switch (RowDefault) { case 0: //Color MyColor = Color.FromName("#BDFCC9"); //for (int j = 0; j < ud.Rows.Count; j++) //{ // if (j % 2 == 0) // { // ud.DisplayLayout.Rows[j].Style.BackColor = SelCol; // } // else // { // ud.DisplayLayout.Rows[j].Style.BackColor = Color.WhiteSmoke; // } //} break; } switch (RowSel) { case 0: //使用 ud.DisplayLayout.CellClickActionDefault = CellClickAction.RowSelect; ud.DisplayLayout.SelectTypeCellDefault = SelectType.Single; ud.DisplayLayout.SelectedRowStyleDefault.BackColor = SelCol; break; case 1: ud.DisplayLayout.HeaderClickActionDefault = HeaderClickAction.NotSet; break; } //是否使用outlook Group by switch (Groupby) { case 0: //使用 ud.DisplayLayout.GroupByBox.Hidden = false; break; case 1: ud.DisplayLayout.GroupByBox.Hidden = true; break; } } catch (Exception ex) { HttpContext.Current.Response.Write(ex.Message); } } //get present's path public string WebGridPresetsPath() { return System.Web.HttpContext.Current.Server.MapPath(".") + @"/XmlFiles/"; } webcombo控件检查 //public void initializeWB(Infragistics.WebUI.C) //{ //} //columns format //tel format //(###)###-####, ###-###-####, 1 - (###) ###-####, ##### ###### //number format //###-##-####, #####-####, #%, CAT ###-###/## //date format //MMMM dd, yyyy, dddd dd/MM/yy, dddd MM/dd/yyyy, MM/dd/yy //currency fromat //$###,###.##, ###,###$, $####.###, ######### public void Format_Col(UltraWebGrid ud, int Col_Index, string Format_Type) { ud.Bands[0].Columns[Col_Index].Format = Format_Type; } //以下都是为空检查 public bool Empty_Check_WebText(Page page, Infragistics.WebUI.WebDataInput.WebTextEdit WebText, string Str) { Common_fun cf = new Common_fun(); if (WebText.Text.Length == 0) { cf.Show(page, "请输入 - > " + Str); WebText.Focus(); return false; } else { return true; } } public bool Empty_Check_WebNum(Page page, Infragistics.WebUI.WebDataInput.WebNumericEdit WebText, string Str) { Common_fun cf = new Common_fun(); if (WebText.Text.Length == 0) { cf.Show(page, "请输入 - > " + Str); WebText.Focus(); return false; } else { return true; } } public bool Empty_Check_WebCombo(Page page, Infragistics.WebUI.WebCombo.WebCombo WebText, string Str) { Common_fun cf = new Common_fun(); if (WebText.DisplayValue == null) { cf.Show(page, "请输入 - > " + Str); WebText.Focus(); return false; } else { return true; } } public bool Empty_Check_Label(Page page, Label WebText, string Str) { Common_fun cf = new Common_fun(); if (WebText.Text == null) { cf.Show(page, "请输入 - > " + Str); WebText.Focus(); return false; } else { return true; } } //web combo的初始化 public void WebCombo_Init(Page page, Infragistics.WebUI.WebCombo.WebCombo WebText, int Width, int Height) { try { WebText.DropDownLayout.DropdownHeight = Height; WebText.DropDownLayout.DropdownWidth = Width; WebText.DropDownLayout.HeaderStyle.HorizontalAlign = HorizontalAlign.Center; } catch (Exception ex) { throw new Exception(ex.Message); } } }