static public DataTable GetAllDataListCategory() { String SQL = "select Category, Category from Sch.DesignformDatalist group by category"; DBManager db = new DBManager(); return db.GetDataTableFromSQL(SQL); }
static public Int32 GetMaxTabID() { DBManager oDB = new DBManager(); DataTable oDS = oDB.GetDataTableFromSQL("Select Max(FormTabID)as MaxTabID From sch.DesignFormTab"); if (oDS.Rows.Count > 0) { if (oDS.Rows[0]["MaxTabID"] != null && oDS.Rows[0]["MaxTabID"].ToString() != string.Empty ) { Int32 rCount = Convert.ToInt32(oDS.Rows[0]["MaxTabID"].ToString()); rCount = rCount + 1; return rCount; } } return 0; }
public static DataTable GetAllFieldsByTableName(String TableName) { String SQL = @" GetDBSchema @Type ='GetAllFiledsByTableName' , @TableName='" + TableName + "'"; DBManager db = new DBManager(); DataTable oDS = db.GetDataTableFromSQL(SQL); return oDS; }
public static DataTable GetDataTableStructure(string TableName, string IDName, Int64 IDValue) { String SQL = @" Select * from " + TableName + " where " + IDName + " = " + IDValue; DBManager db = new DBManager(); DataTable oDS = db.GetDataTableFromSQL(SQL); return oDS; }
public void SetPanelControl(TabPanel oPanel, List<DesignFormField> oControlList) { // DataMappingDataContext db = new DataMappingDataContext(AppModuleManager.ConnectionString); // hash table to hold all build in control Hashtable BuildInControlList = new Hashtable(); if (HttpContext.Current.Session[SessionFormDesignControlList] != null) { BuildInControlList = (Hashtable)HttpContext.Current.Session[SessionFormDesignControlList]; } //Session[AppConstManager.SessionFormDesignControlList] = string.Empty ; string cssStyle = string.Empty; int num; foreach (var oItem in oControlList) { // Button if (oItem.ControlType == Convert.ToInt32(ControlType.Button)) { Button oButton = new Button(); oButton.ID = oItem.Name; // add some buid in control to session if ((oButton.ID == BuildInChangeButtonControl) || (oButton.ID == BuildInChangeLoginNameButtonControl)) { if (!BuildInControlList.ContainsKey(oButton.ID)) { BuildInControlList.Add(oButton.ID, oButton); } } if (oButton.SkinID != null) { if (oItem.SkinID != string.Empty) { oButton.SkinID = oItem.SkinID; } else { oButton.SkinID = ButtonSkinID; } } else { oButton.SkinID = ButtonSkinID; } string cStyle = string.Empty; bool IsTop = int.TryParse(oItem.ControlTop.ToString(), out num); if (IsTop == true) { cssStyle = ccsRelative + ccsTop + num.ToString() + ccsPX; } cStyle = cssStyle; bool IsLeft = int.TryParse(oItem.ControlLeft.ToString(), out num); if (IsLeft == true) { cssStyle = cssStyle + ccsLeft + num.ToString() + ccsPX; } LiteralControl oLiteral = new LiteralControl(); oLiteral.Text = "<Div id=\"DIV" + oButton.ID + "\" Style='" + cssStyle + "'>"; // oLabel.Attributes.Add(AppConstManager.cStyle, cssStyle); oPanel.Controls.Add(oLiteral); oButton.Text = oItem.Label; oButton.ToolTip = oItem.Label; oPanel.Controls.Add(oButton); LiteralControl oEndLiteral = new LiteralControl(); oEndLiteral.Text = "</Div>"; // Button oExist = (Button)oPanel.FindControl(oButton.ID); //if (oExist == null) { oPanel.Controls.Add(oEndLiteral); } //oButton.Attributes.Add(AppConstManager.cStyle, cssStyle); } //Literal if (oItem.ControlType == Convert.ToInt32(ControlType.Literal)) { Literal oLiteral = new Literal(); oLiteral.ID = oItem.Name; if (oLiteral.SkinID != null) { if (oItem.SkinID != string.Empty) { oLiteral.SkinID = oItem.SkinID; } else { oLiteral.SkinID = LieralSkinID; } } else { oLiteral.SkinID = LieralSkinID; } string cStyle = string.Empty; bool IsTop = int.TryParse(oItem.ControlTop.ToString(), out num); if (IsTop == true) { cssStyle = ccsRelative + ccsTop + num.ToString() + ccsPX; } cStyle = cssStyle; bool IsLeft = int.TryParse(oItem.ControlLeft.ToString(), out num); if (IsLeft == true) { cssStyle = cssStyle + ccsLeft + num.ToString() + ccsPX; } cStyle = cStyle + "; " + cssStyle; String oHTML = oItem.Label.Replace("[position]", cStyle); oLiteral.Text = oHTML; oPanel.Controls.Add(oLiteral); } else if (oItem.ControlType == Convert.ToInt32(ControlType.DrowDownList)) { DropDownList oDDL = new DropDownList(); oDDL.ID = oItem.Name; // +oItem.ControlType; oDDL.ToolTip = oItem.Name; if (oItem.SkinID != null) { if (oItem.SkinID != string.Empty) { oDDL.SkinID = oItem.SkinID; } else { oDDL.SkinID = DropDownListSkinID; } } else { oDDL.SkinID = DropDownListSkinID; } //oDDL.SkinID = "sDropDownList"; if (oItem.IsVisible == true) { if (oItem.IsEnabled == false) { oDDL.Enabled = false; } bool IsTop = int.TryParse(oItem.ControlTop.ToString(), out num); if (IsTop == true) { cssStyle = ccsRelative + ccsTop + num.ToString() + ccsPX; // oDDL.Attributes.Add(AppConstManager.cStyle, AppConstManager.ccsRelative); // oDDL.Attributes.Add(AppConstManager.cStyle, num.ToString() + AppConstManager.ccsPX); } bool IsLeft = int.TryParse(oItem.ControlLeft.ToString(), out num); if (IsLeft == true) { cssStyle = cssStyle + ccsLeft + num.ToString() + ccsPX; //oDDL.Attributes.Add(AppConstManager.cStyle, AppConstManager.ccsLeft + num.ToString() + AppConstManager.ccsPX); } // oDDL.Attributes.Add(AppConstManager.cStyle, cssStyle); //Get data source if (oItem.QueryStatement != null) { if (oItem.QueryStatement != string.Empty) { DBManager oDB = new DBManager(); DataTable oDS = oDB.GetDataTableFromSQL(oItem.QueryStatement); string DisplayValue = oDS.Columns[0].ColumnName; string IDValue = oDS.Columns[1].ColumnName; SetListToDropDownList(oDS, oDDL, DisplayValue, IDValue); // oDDLManager.SetDatasetToDropDownList(oDS, oDDL, DisplayValue, IDValue, true); } } else { if (oItem.DataListType != null && oItem.DataListType != string.Empty) { List<DesignFormDataList> oDDLList = DesignFormDataList.GetDataListByType(oItem.DataListType); oDDL.DataSource = oDDLList; oDDL.DataTextField = "DisplayField"; oDDL.DataValueField = "ValueField"; oDDL.DataBind(); } } //set label if (oItem.IsReadOnly == true) { oDDL.Enabled = false; } SetControlLabel(oPanel, oItem, eFormID); LiteralControl oLiteral = new LiteralControl(); oLiteral.Text = "<Div id=\"DIV" + oDDL.ID + "\" Style='" + cssStyle + "'>"; // oLabel.Attributes.Add(AppConstManager.cStyle, cssStyle); oPanel.Controls.Add(oLiteral); oPanel.Controls.Add(oDDL); LiteralControl oEndLiteral = new LiteralControl(); oEndLiteral.Text = "</Div>"; oPanel.Controls.Add(oEndLiteral); } } else if (oItem.ControlType == Convert.ToInt32(ControlType.CheckBox)) { CheckBox oChk = new CheckBox(); oChk.ID = oItem.Name; //+ oItem.ControlType; oChk.ToolTip = oItem.Name; if (oItem.SkinID != null) { if (oItem.SkinID != string.Empty) { oChk.SkinID = oItem.SkinID; } else { oChk.SkinID = CheckBoxSkinID; } } else { oChk.SkinID = CheckBoxSkinID; } if (oItem.HasDefault== true) { oChk.Checked = true; } else { oChk.Checked = false; } //oChk.SkinID = "DesignCheckBox"; if (oItem.IsVisible == true) { if (oItem.IsEnabled == false) { oChk.Enabled = false; } bool IsTop = int.TryParse(oItem.ControlTop.ToString(), out num); if (IsTop == true) { cssStyle = ccsRelative + ccsTop + num.ToString() + ccsPX; // oDDL.Attributes.Add(AppConstManager.cStyle, AppConstManager.ccsRelative); // oDDL.Attributes.Add(AppConstManager.cStyle, num.ToString() + AppConstManager.ccsPX); } bool IsLeft = int.TryParse(oItem.ControlLeft.ToString(), out num); if (IsLeft == true) { cssStyle = cssStyle + ccsLeft + num.ToString() + ccsPX; //oDDL.Attributes.Add(AppConstManager.cStyle, AppConstManager.ccsLeft + num.ToString() + AppConstManager.ccsPX); } Boolean IsSetTrue = false; //oChk.Attributes.Add(AppConstManager.cStyle, cssStyle); //set label SetControlLabel(oPanel, oItem, eFormID); if (IsSetTrue) { oChk.Checked = true; } LiteralControl oLiteral = new LiteralControl(); oLiteral.Text = "<Div id=\"DIV" + oChk.ID + "\" Style='" + cssStyle + "'>"; // oLabel.Attributes.Add(AppConstManager.cStyle, cssStyle); oPanel.Controls.Add(oLiteral); oPanel.Controls.Add(oChk); LiteralControl oEndLiteral = new LiteralControl(); oEndLiteral.Text = "</Div>"; oPanel.Controls.Add(oEndLiteral); oChk = null; } } //Text area else if (oItem.ControlType == Convert.ToInt32(ControlType.TextArea)) { TextBox oTextArea = new TextBox(); oTextArea.TextMode = System.Web.UI.WebControls.TextBoxMode.MultiLine; oTextArea.ID = oItem.Name;// +oItem.ControlType; oTextArea.ToolTip = oItem.Name; oTextArea.Width = Unit.Pixel(Convert.ToInt16(oItem.Width)); oTextArea.Height = Unit.Pixel(Convert.ToInt16(oItem.Height)); if (oItem.SkinID != null) { if (oItem.SkinID != string.Empty) { oTextArea.SkinID = oItem.SkinID; } else { oTextArea.SkinID = TextAreaSkinID; } } else { oTextArea.SkinID = TextAreaSkinID; } if (oItem.IsVisible == true) { if (oItem.IsEnabled == false) { oTextArea.Enabled = false; } if (oItem.IsReadOnly == true) { oTextArea.ReadOnly = true; } bool IsTop = int.TryParse(oItem.ControlTop.ToString(), out num); if (IsTop == true) { cssStyle = ccsRelative + ccsTop + num.ToString() + ccsPX; // oDDL.Attributes.Add(AppConstManager.cStyle, AppConstManager.ccsRelative); // oDDL.Attributes.Add(AppConstManager.cStyle, num.ToString() + AppConstManager.ccsPX); } bool IsLeft = int.TryParse(oItem.ControlLeft.ToString(), out num); if (IsLeft == true) { cssStyle = cssStyle + ccsLeft + num.ToString() + ccsPX; //oDDL.Attributes.Add(AppConstManager.cStyle, AppConstManager.ccsLeft + num.ToString() + AppConstManager.ccsPX); } //oTextArea.Attributes.Add(AppConstManager.cStyle, cssStyle); //set label SetControlLabel(oPanel, oItem, eFormID); LiteralControl oLiteral = new LiteralControl(); oLiteral.Text = "<Div id=\"DIV" + oTextArea.ID + "\" Style='" + cssStyle + "'>"; // oLabel.Attributes.Add(AppConstManager.cStyle, cssStyle); oPanel.Controls.Add(oLiteral); oPanel.Controls.Add(oTextArea); LiteralControl oEndLiteral = new LiteralControl(); oEndLiteral.Text = "</Div>"; oPanel.Controls.Add(oEndLiteral); //oPanel.Controls.Add(oTextArea); } } //Hyperlink else if (oItem.ControlType == Convert.ToInt32(ControlType.HyperLink)) { HyperLink oHyperlink = new HyperLink(); oHyperlink.ID = oItem.Name;// +oItem.ControlType; oHyperlink.ToolTip = oItem.Message; oHyperlink.Text = oItem.Message; if (oItem.NewWindow == true) { // "popOpenWindow('FileUpload.aspx', 'FileUpload', // 'ImageClientID=ImageLoad<%= this.ClientID %>&ImageHiddenPath=<%=this.HidImagePath.ClientID %>', 450, 120, 'No', false)" oHyperlink.NavigateUrl = @"Javascript: popOpenWindow('" + oItem.URL + "', 'URLNewWindow', '', 900, 600, 'Yes', true)"; } else { oHyperlink.NavigateUrl = oItem.URL; } if (oItem.NewWindow == true) { } if (oItem.IsMandatory == true) { oHyperlink.Target = "_blank"; } if (oItem.SkinID != null) { if (oItem.SkinID != string.Empty) { oHyperlink.SkinID = oItem.SkinID; } else { oHyperlink.SkinID = HyperlinkSkinID; } } else { oHyperlink.SkinID = HyperlinkSkinID; } if (oItem.IsVisible == true) { if (oItem.IsEnabled == false) { oHyperlink.Enabled = false; } bool IsTop = int.TryParse(oItem.ControlTop.ToString(), out num); if (IsTop == true) { cssStyle = ccsRelative + ccsTop + num.ToString() + ccsPX; // oDDL.Attributes.Add(AppConstManager.cStyle, AppConstManager.ccsRelative); // oDDL.Attributes.Add(AppConstManager.cStyle, num.ToString() + AppConstManager.ccsPX); } bool IsLeft = int.TryParse(oItem.ControlLeft.ToString(), out num); if (IsLeft == true) { cssStyle = cssStyle + ccsLeft + num.ToString() + ccsPX; //oDDL.Attributes.Add(AppConstManager.cStyle, AppConstManager.ccsLeft + num.ToString() + AppConstManager.ccsPX); } //oTextArea.Attributes.Add(AppConstManager.cStyle, cssStyle); LiteralControl oLiteral = new LiteralControl(); //set label if (oItem.WithLabel == true) { SetControlLabel(oPanel, oItem, eFormID); // oLiteral.Text = "<Div id=\"DIV" + oHyperlink.ID + "\" Style='" + cssStyle + "'>"; } oLiteral.Text = "<Div id=\"DIV" + oHyperlink.ID + "\" Style='" + cssStyle + "'>"; // oLabel.Attributes.Add(AppConstManager.cStyle, cssStyle); oPanel.Controls.Add(oLiteral); oPanel.Controls.Add(oHyperlink); LiteralControl oEndLiteral = new LiteralControl(); oEndLiteral.Text = "</Div>"; oPanel.Controls.Add(oEndLiteral); //oPanel.Controls.Add(oTextArea); } } //Image else if (oItem.ControlType == Convert.ToInt32(ControlType.Image)) { //UserControl oImageControl = (UserControl)oPage.LoadControl("~/" + AppConstManager.ctrFormDesignImageControl); ////Set this into a hash table and session // DesignFormField oImageDesign = (DesignFormField)oItem; if (HttpContext.Current.Session[SessionImageList] != null) { oImageList = (Hashtable)HttpContext.Current.Session[SessionImageList]; } if (!oImageList.ContainsKey(oItem.Name)) { oImageList.Add(oItem.Name, oItem); HttpContext.Current.Session[SessionImageList] = oImageList; } //DesignFormField oTextBoxField = (DesignFormField)oItem; //if (HttpContext.Current.Session[SessionTextBoxList] != null) //{ // oTextBoxList = (Hashtable)HttpContext.Current.Session[SessionTextBoxList]; //} //if (!oTextBoxList.ContainsKey(oItem.Name)) //{ // oTextBoxList.Add(oItem.Name, oTextBoxField); // HttpContext.Current.Session[SessionTextBoxList] = oTextBoxList; //} } //datetime else if (oItem.ControlType == Convert.ToInt32(ControlType.DateTime)) { TextBox oDateTime = new TextBox(); oDateTime.Width = Unit.Pixel(Convert.ToInt16(oItem.Width)); oDateTime.Height = Unit.Pixel(Convert.ToInt16(oItem.Height)); DesignFormField oTextBoxdesign = (DesignFormField)oItem; if (HttpContext.Current.Session[SessionTextBoxList] != null) { oTextBoxList = (Hashtable)HttpContext.Current.Session[SessionTextBoxList]; } if (!oTextBoxList.ContainsKey(oItem.Name)) { oTextBoxList.Add(oItem.Name, oTextBoxdesign); HttpContext.Current.Session[SessionTextBoxList] = oTextBoxList; } oDateTime.ID = oItem.Name;// +oItem.ControlType; oDateTime.ToolTip = oItem.Name; if (oItem.SkinID != null) { if (oItem.SkinID != string.Empty) { oDateTime.SkinID = oItem.SkinID; } else { oDateTime.SkinID = TextBoxSkinID; } } else { oDateTime.SkinID = TextBoxSkinID; } if (oItem.IsVisible == true) { if (oItem.IsEnabled == false) { oDateTime.Enabled = false; } //if (oItem.IsReadOnly == true) //{ // oDateTime.ReadOnly = true; //} bool IsTop = int.TryParse(oItem.ControlTop.ToString(), out num); if (IsTop == true) { cssStyle = ccsRelative + ccsTop + num.ToString() + ccsPX; // oDDL.Attributes.Add(AppConstManager.cStyle, AppConstManager.ccsRelative); // oDDL.Attributes.Add(AppConstManager.cStyle, num.ToString() + AppConstManager.ccsPX); } bool IsLeft = int.TryParse(oItem.ControlLeft.ToString(), out num); if (IsLeft == true) { cssStyle = cssStyle + ccsLeft + num.ToString() + ccsPX; //oDDL.Attributes.Add(AppConstManager.cStyle, AppConstManager.ccsLeft + num.ToString() + AppConstManager.ccsPX); } // oTextBox.Attributes.Add(AppConstManager.cStyle, cssStyle); oDateTime.MaxLength = 40; //set label SetControlLabel(oPanel, oItem, eFormID); LiteralControl oLiteral = new LiteralControl(); oLiteral.Text = "<Div id=\"DIV" + oDateTime.ID + "\" Style='" + cssStyle + "'>"; // oLabel.Attributes.Add(AppConstManager.cStyle, cssStyle); oPanel.Controls.Add(oLiteral); oPanel.Controls.Add(oDateTime); //Add calendar if (oItem.IsCalendar == true) { DateFormat oDF = DateFormat.Load<DateFormat>(oItem.DateFormat); FormDesign.AddCalendar(oDateTime.ID, oPanel, oDF.Format); } LiteralControl oEndLiteral = new LiteralControl(); oEndLiteral.Text = "</Div>"; oPanel.Controls.Add(oEndLiteral); } } //Money box //text box else if (oItem.ControlType == Convert.ToInt32(ControlType.TextBox) || oItem.ControlType == Convert.ToInt32(ControlType.Money)) { TextBox oTextBox = new TextBox(); oTextBox.ID = "txtEform" + oItem.Name;// +oItem.ControlType; oTextBox.ToolTip = oItem.Name; oTextBox.Width = Unit.Pixel(Convert.ToInt16(oItem.Width)); oTextBox.Height = Unit.Pixel(Convert.ToInt16(oItem.Height)); if (oItem.SkinID != null) { if (oItem.SkinID != string.Empty) { oTextBox.SkinID = oItem.SkinID; } else { oTextBox.SkinID = TextBoxSkinID; } } else { oTextBox.SkinID = TextBoxSkinID; } if (oItem.IsVisible == true) { if (oItem.IsEnabled == false) { oTextBox.Enabled = false; } if (oItem.ControlType == Convert.ToInt32(ControlType.TextBox)) { if (oItem.IsReadOnly == true) { oTextBox.ReadOnly = true; DesignFormField oDesign = (DesignFormField)oItem; if (HttpContext.Current.Session[SessionTextBoxList] != null) { oTextBoxList = (Hashtable)HttpContext.Current.Session[SessionTextBoxList]; } if (!oTextBoxList.ContainsKey(oItem.Name)) { oTextBoxList.Add(oItem.Name, oDesign); HttpContext.Current.Session[SessionTextBoxList] = oTextBoxList; } } } if (oItem.ControlType == Convert.ToInt32(ControlType.Money)) { DesignFormField oDesign = (DesignFormField)oItem; if (HttpContext.Current.Session[SessionTextBoxList] != null) { oTextBoxList = (Hashtable)HttpContext.Current.Session[SessionTextBoxList]; } if (!oTextBoxList.ContainsKey(oItem.Name)) { oTextBoxList.Add(oItem.Name, oDesign); HttpContext.Current.Session[SessionTextBoxList] = oTextBoxList; } } bool IsTop = int.TryParse(oItem.ControlTop.ToString(), out num); if (IsTop == true) { cssStyle = ccsRelative + ccsTop + num.ToString() + ccsPX; // oDDL.Attributes.Add(AppConstManager.cStyle, AppConstManager.ccsRelative); // oDDL.Attributes.Add(AppConstManager.cStyle, num.ToString() + AppConstManager.ccsPX); } bool IsLeft = int.TryParse(oItem.ControlLeft.ToString(), out num); if (IsLeft == true) { cssStyle = cssStyle + ccsLeft + num.ToString() + ccsPX; //oDDL.Attributes.Add(AppConstManager.cStyle, AppConstManager.ccsLeft + num.ToString() + AppConstManager.ccsPX); } // oTextBox.Attributes.Add(AppConstManager.cStyle, cssStyle); string MaxLength = Option.GetOptionByKey(MaxLenghtOptionKey); if (MaxLength == string.Empty) { MaxLength = "100"; } oTextBox.MaxLength = Convert.ToInt32(MaxLength); //set label SetControlLabel(oPanel, oItem, eFormID); LiteralControl oLiteral = new LiteralControl(); oLiteral.Text = "<Div id=\"DIV" + oTextBox.ID + "\" Style='" + cssStyle + "'>"; // oLabel.Attributes.Add(AppConstManager.cStyle, cssStyle); oPanel.Controls.Add(oLiteral); oPanel.Controls.Add(oTextBox); LiteralControl oEndLiteral = new LiteralControl(); oEndLiteral.Text = "</Div>"; oPanel.Controls.Add(oEndLiteral); //oPanel.Controls.Add(oTextBox); } } } HttpContext.Current.Session[SessionFormDesignControlList] = BuildInControlList; }