/// <summary> /// Fetch company services /// </summary> public void XmlFetchData() { string xmlFile = BaseSys.GetXmlFilePath("Category.xml"); if (File.Exists(xmlFile)) { category.ReadXml(xmlFile); var cateRows = (from c in category where c.Active == true select c).ToList(); // Declare paged data source for pagging in repeater var _pagedDataSource = new PagedDataSource { AllowCustomPaging = true, AllowPaging = true, PageSize = this.PageSize, DataSource = cateRows.Skip((CurrentPageIndex - 1) * this.PageSize) }; // Get the total pages decimal decimalPages = Decimal.Divide((decimal)cateRows.Count, (decimal)_pagedDataSource.PageSize); this.PageCount = (int)(Math.Ceiling(decimalPages)); this.StylePageNagiation(cateRows.Count); repeaterData.DataSource = _pagedDataSource; repeaterData.DataBind(); } }
/// <summary> /// Search for data in xml file using both xsd dataset & LINQ techniques /// </summary> protected void LinqSearchXmlData() { category.ReadXml(xmlFile); // Note: using [select new] below is most important for showing them in repeater, otherwise we cannot. // !Important: c.Element("id") -> <name>1</name> - c.Element("id").Value -> 1 - same for active var cates = (from c in category where c.Name.Contains(this.Keywrod) || c.Description.Contains(this.Keywrod) select c).ToList(); //select new { Id = c.Element("id").Value, Name = c.Element("name"), Description = c.Element("description"), Active = c.Element("active").Value }).ToList(); var _pagedDataSource = new PagedDataSource { AllowCustomPaging = true, AllowPaging = true, PageSize = this.PageSize, DataSource = category.Skip((this.CurrentPageIndex - 1) * this.PageSize) }; decimal decimalPages = Decimal.Divide((decimal)category.Count, (decimal)_pagedDataSource.PageSize); this.PageCount = (int)(Math.Ceiling(decimalPages)); // Get the pager info BaseSys.GetPaginationInfo(lbPaginationInfo, this.CurrentPageIndex, this.PageCount, Properties.Resources.Search, category.Count); this.StylePageNagiation(category.Count); // Fill Repeater Data from PagedDataSource repeaterData.DataSource = _pagedDataSource; repeaterData.DataBind(); // navibation pager will work for the following this.NavigationFor = "Search"; }
/// <summary> /// Fetch xml data using both xsd dataset & LINQ techniques /// </summary> protected void LinqFetchXmlData() { category.ReadXml(xmlFile); var cates = (from c in category select c).ToList(); var _pagedDataSource = new PagedDataSource { AllowCustomPaging = true, AllowPaging = true, PageSize = this.PageSize, DataSource = category.Skip((this.CurrentPageIndex - 1) * this.PageSize) }; // Get the total pages decimal decimalPages = Decimal.Divide((decimal)category.Count, (decimal)_pagedDataSource.PageSize); this.PageCount = (int)(Math.Ceiling(decimalPages)); // Get the pager info BaseSys.GetPaginationInfo(lbPaginationInfo, this.CurrentPageIndex, this.PageCount, Properties.Resources.CategoryCount, category.Count); //lbPaginationInfo.Text = string.Format("{0} {1} {2} {3}", Properties.Resources.Page, this.CurrentPageIndex, Properties.Resources.Of, this.PageCount); this.StylePageNagiation(category.Count); // Fill Repeater Data from PagedDataSource repeaterData.DataSource = _pagedDataSource; repeaterData.DataBind(); this.NavigationFor = "LoadingData"; }
// Initialize the box for new data or just edit existed data public void InitializeBox(bool newData) { this.AddNew = newData; SharedLinq.LinqFetchPrivilege(ddlPrivilege); msgPanel.Visible = false; if (this.ItsManager == true) { ddlPrivilege.SelectedIndex = 0; ddlPrivilege.Enabled = false; ddlActive.Enabled = false; } else { ddlPrivilege.Items.Insert(0, new ListItem(Properties.Resources.SelectOne, "0")); ddlPrivilege.Enabled = true; ddlActive.Enabled = true; } if (newData == false) { this.LinqFetchRowData(); RFvPassword.Enabled = false; RFvRePassword.Enabled = false; } else { BaseSys.ClearPanelControl(addPanel); lbBoxTitle.Text = string.Format("{0} - {1}", Properties.Resources.UserEntry, Properties.Resources.New); } }
// Initialize the box public void InitializeShowBox() { xmlFile = BaseSys.GetXmlFilePath("Category.xml"); this.GetDataFromXml(); this.LinqFetchXmlData(); }
protected void Page_Load(object sender, EventArgs e) { xmlFile = BaseSys.GetXmlFilePath("Category.xml"); //if (!IsPostBack) // xmlFile = BaseSys.GetXmlFilePath("Category.xml"); }
// Save Button protected void btnSave_Click(object sender, EventArgs e) { msgPanel.Visible = false; string successMsg = string.Format("{0} <b>{1}</b> {2}", Properties.Resources.Save, this.NewsTitle, Properties.Resources.Successfully); bool action = false; if (Page.IsValid) { if (this.AddNew == true) action = this.LinqInsertData(); else action = this.LinqUpdateData(); // Check Saving data.. if (this.Found == true) BaseSys.ShowMsg(msgPanel, lbMsg, Properties.Resources.Found, "error"); else { if (action == true) BaseSys.ShowMsg(msgPanel, lbMsg, successMsg, "ok"); else BaseSys.ShowMsg(msgPanel, lbMsg, Properties.Resources.Failure, "error"); } } else { BaseSys.ShowMsg(msgPanel, lbMsg, Properties.Resources.FailureValid, "error"); } }
/// <summary> /// Do multiple actions to selected (checked) records /// Actions such as Delete, Active, No active, Block, No block ...etc. /// </summary> /// <param name="manner">The action manner</param> /// <param name="value">True or False</param> /// <returns></returns> protected void DoMultiAction(string manner, bool value = false) { bool action = false; string message = null; foreach (RepeaterItem item in repeaterData.Items) { var checkBox = item.FindControl("checkBxSelector") as CheckBox; var lbIdValue = item.FindControl("lbIdValue") as Label; this.ContactUsID = short.Parse(lbIdValue.Text); if (checkBox.Checked)// Check the checked CheckBoxes { if (manner == "DELETE") { action = this.LinqDeleteData(); message = Properties.Resources.NoDelete; } } } // Checking the action if (action == true) this.LinqFetchData(); else // Obstruct: Not allowed to Delete or No Data has been seleccted !IMPORTANT { BaseSys.NoAction(lbMultiActMsg, message); } }
/// <summary> /// Fetch single row data that specified to giving cate /// </summary> /// <param name="id"></param> protected void XmlFetchContent(int id) { string xmlFile = BaseSys.GetXmlFilePath("Category.xml"); if (File.Exists(xmlFile)) { XDocument xmlDoc = XDocument.Load(xmlFile); var cate = xmlDoc.Descendants("Category").FirstOrDefault(c => c.Element("Id").Value == id.ToString()); if (cate == null) return; lbTitle.Text = cate.Element("Name").Value; lbDescription.Text = cate.Element("Description").Value; imgShow.ImageUrl = cate.Element("ImagePath").Value; Page.Title = string.Format("{0} - {1}", Properties.Resources.MainTitle, cate.Element("Name").Value); //category.ReadXml(xmlFile); //var content = (from c in category where c.Id == id select c).First(); //lbTitle.Text = content.Name; //lbDescription.Text = content.Description; //imgShow.ImageUrl = content.ImagePath; //// Make the title as page title //Page.Title = string.Format("{0} - {1}", Properties.Resources.MainTitle, content.Name); } }
protected void Page_Load(object sender, EventArgs e) { xmlFile = BaseSys.GetXmlFilePath("Category.xml"); // !Important - Multilingual resource if (!IsPostBack) { mwcAsyncImageUpload.DestinationFolder = "Category/"; mwcAsyncImageUpload.UploadTitle = Properties.Resources.CategoryImageUpload; } }
protected void Page_Load(object sender, EventArgs e) { xmlFile = BaseSys.GetXmlFilePath("Website.xml"); // !Important - Multilingual resource if (!IsPostBack) { this.XmlFetchRowData(); mwcAsyncImageUpload.UploadTitle = Properties.Resources.LogoImageUpload; } }
/// <summary> /// Fetch company categories /// </summary> public void XmlFetchData() { string xmlFile = BaseSys.GetXmlFilePath("Category.xml"); if (File.Exists(xmlFile)) { category.ReadXml(xmlFile); repeaterData.DataSource = category.Take(3); repeaterData.DataBind(); } }
/// <summary> /// Fetch company services /// </summary> public void XmlFetchData() { string xmlFile = BaseSys.GetXmlFilePath(""); if (File.Exists(xmlFile)) { holder.ReadXml(xmlFile); repeaterData.DataSource = holder; repeaterData.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int count = smartDb.SysUsers.Count(); if (count > 0) this.Visible = true; else { this.Visible = false; this.ShowNewUser(); } string xmlFile = BaseSys.GetXmlFilePath("Company.xml"); ddlLanguage.Items.Clear(); SharedLinq.XmlFetchLanguage(ddlLanguage); ddlLanguage.ClearSelection(); ddlLanguage.Items.FindByValue(this.CultureInfo).Selected = true; } }
/// <summary> /// Count data found that specified to giving cate /// </summary> /// <param name="id"></param> protected void LinqCountRows(int id) { string xmlFile = BaseSys.GetXmlFilePath("Category.xml"); category.ReadXml(xmlFile); int count = (from c in category where c.Id == id select c).Count(); if (count > 0) { msgPanel.Visible = false; contentPanel.Visible = true; this.XmlFetchContent(id); } }
// Delete Icon protected void lnkBtnDelete_Click(object sender, EventArgs e) { //---------------------------------------------- LinkButton lnkBtnDelete = (LinkButton)sender; //---------------------------------------------- this.ContactUsID = Convert.ToInt16(lnkBtnDelete.CommandArgument); if (this.LinqDeleteData() == true) this.LinqFetchData(); else BaseSys.NoAction(lbMultiActMsg, Properties.Resources.NoDelete); }
protected void Page_Load(object sender, EventArgs e) { string xmlFile = BaseSys.GetXmlFilePath("Company.xml"); if (!IsPostBack) { SharedLinq.XmlFetchLanguage(ddlLanguage); ddlLanguage.Items.FindByValue(this.CultureInfo).Selected = true; this.PrivilegedUser(); if (BaseSys.LogInControlPanel == true) this.UserInfo(); } }
// Fetch row data from xml using xml dataset protected void XmlFetchRowData() { string xmlFile = BaseSys.GetXmlFilePath("Home.xml"); if (File.Exists(xmlFile)) { // Get data from xml file home.ReadXml(xmlFile); row = (Company.HomeRow)home.Rows[0]; lbTitle.Text = row.Title; lbInformation.Text = row.Information; lbVision.Text = row.Vision; lbMission.Text = row.Mission; } }
// Fetch row data from xml using xml dataset protected void XmlFetchRowData() { string xmlFile = BaseSys.GetXmlFilePath("About.xml"); if (File.Exists(xmlFile)) { // Get data from xml file about.ReadXml(xmlFile); row = (Company.AboutRow)about.Rows[0]; lbWhoAreWe.Text = row.WhoAreWe; lbManager.Text = string.Format("{0}: {1}", Properties.Resources.Manager, row.Manager); lbProfile.Text = row.Profile; } }
// Initialize the box for new data or just edit existed data public void InitializeBox(bool newData) { this.AddNew = newData; msgPanel.Visible = false; txtName.Focus(); if (newData == false) this.LinqXmlFetchRowData(); else { BaseSys.ClearPanelControl(addPanel); lbBoxTitle.Text = string.Format("{0} - {1}", Properties.Resources.CategoryEntry, Properties.Resources.New); mwcAsyncImageUpload.InitializeUploadBox(true); } }
// Delete ImagePath protected void lnkBtnDelete_Click(object sender, EventArgs e) { //---------------------------------------------- LinkButton lnkBtnDelete = (LinkButton)sender; //---------------------------------------------- this.CategoryID = Convert.ToInt16(lnkBtnDelete.CommandArgument); if (this.LinqDeleteXmlData() == true) { this.LinqFetchXmlData(); BaseSys.DeleteImageFile(this.ImagePath); } else BaseSys.NoAction(lbMultiActMsg, Properties.Resources.NoDelete); }
// Fetch row data from xml using xml dataset protected void XmlFetchRowData() { string xmlFile = BaseSys.GetXmlFilePath("Contact.xml"); if (File.Exists(xmlFile)) { // Get data from xml file contact.ReadXml(xmlFile); row = (Company.ContactUsRow)contact.Rows[0]; lbContact.Text = string.Format("{0}: {1} | {2}: {3}", Properties.Resources.Phone, row.Phone, Properties.Resources.Fax, row.Fax); lbMobile.Text = string.Format("{0}: {1}", Properties.Resources.Mobile, row.Mobile); lbEmail.Text = string.Format("{0}: {1}", Properties.Resources.Email, row.Email); lbAddress.Text = string.Format("{0}: {1}", Properties.Resources.Address, row.Address); } }
// Fetch row data from xml using xml dataset protected void XmlFetchRowData() { if (File.Exists(this.xmlFile)) { // Get data from xml file about.ReadXml(this.xmlFile); row = (Company.AboutRow)about.Rows[0]; txtWhoAreWe.Text = row.WhoAreWe; txtProfile.Text = row.Profile; txtManager.Text = row.Manager; } else { BaseSys.ShowMsg(msgPanel, lbMsg, Properties.Resources.XmlFileNotFound, "error"); } }
// Initialize the box for new data or just edit existed data public void InitializeBox(bool newData) { this.AddNew = newData; this.PopulateDDList(); ddlCategory.Items.Insert(0, new ListItem(Properties.Resources.SelectOne, "0")); msgPanel.Visible = false; txtTitle.Focus(); if (newData == false) this.LinqFetchRowData(); else { BaseSys.ClearPanelControl(addPanel); lbBoxTitle.Text = string.Format("{0} - {1}", Properties.Resources.ServiceEntry, Properties.Resources.New); mwcAsyncImageUpload.InitializeUploadBox(true); } }
// Save Button protected void btnSave_Click(object sender, EventArgs e) { if (File.Exists(this.xmlFile)) { if (Page.IsValid) { bool action = this.XmlSaveData(); if (action == true) BaseSys.ShowMsg(msgPanel, lbMsg, Properties.Resources.Success, "ok"); else BaseSys.ShowMsg(msgPanel, lbMsg, Properties.Resources.Failure, "error"); } else { BaseSys.ShowMsg(msgPanel, lbMsg, Properties.Resources.FailureValid, "error"); } } else { BaseSys.ShowMsg(msgPanel, lbMsg, Properties.Resources.XmlFileNotFound, "error"); } }
// Fetch row data from xml using xml dataset protected void XmlFetchRowData() { if (File.Exists(this.xmlFile)) { // Get data from xml file about.ReadXml(this.xmlFile); row = (Company.WebsiteRow)about.Rows[0]; txtCompany.Text = row.Company; txtTitle.Text = row.Title; mwcAsyncImageUpload.InitializeUploadBox(false, row.Logo); } else { BaseSys.ShowMsg(msgPanel, lbMsg, Properties.Resources.XmlFileNotFound, "error"); } }
// Fetch row data from xml using xml dataset protected void XmlFetchRowData() { if (File.Exists(this.xmlFile)) { // Get data from xml file home.ReadXml(this.xmlFile); row = (Company.HomeRow)home.Rows[0]; txtTitle.Text = row.Title; txtInformation.Text = row.Information; txtVision.Text = row.Vision; txtMission.Text = row.Mission; } else { BaseSys.ShowMsg(msgPanel, lbMsg, Properties.Resources.XmlFileNotFound, "error"); } }
// Save Data protected void btnSave_Click(object sender, EventArgs e) { msgPanel.Visible = false; // Check if the page is valid - this is for more security if (Page.IsValid) { bool action = false; action = this.LinqChangeCurrentUserPassword(); // Check Saving data.. if(this.WrongOldPassword == true) BaseSys.ShowMsg(msgPanel, lbMsg, Properties.Resources.WrongPassword, "error"); else BaseSys.ShowMsg(msgPanel, lbMsg, Properties.Resources.Success, "ok"); } else { BaseSys.ShowMsg(msgPanel, lbMsg, Properties.Resources.FailureValid, "error"); } }
// Fetch row data from xml using xml dataset protected void XmlFetchRowData() { if (File.Exists(this.xmlFile)) { // Get data from xml file home.ReadXml(this.xmlFile); row = (Company.ContactUsRow)home.Rows[0]; txtAddress.Text = row.Address; txtPhone.Text = row.Phone; txtFax.Text = row.Fax; txtMobile.Text = row.Mobile; txtEmail.Text = row.Email; } else { BaseSys.ShowMsg(msgPanel, lbMsg, Properties.Resources.XmlFileNotFound, "error"); } }
/// <summary> /// Fetch data using LINQ techniques /// </summary> public void LinqFetchData() { var contact = (from c in smartDb.ContactUs select new { c.Id, c.Name, c.Email, c.Message, c.SentDate}).ToList(); var _pagedDataSource = new PagedDataSource { AllowCustomPaging = true, AllowPaging = true, PageSize = this.PageSize, DataSource = contact.Skip((this.CurrentPageIndex - 1) * this.PageSize) }; // Get the total pages this.PageCount = BaseSys.CalculateTotalPages(contact.Count, this.PageSize); // Get the pager info BaseSys.GetPaginationInfo(lbPaginationInfo, this.CurrentPageIndex, this.PageCount, Properties.Resources.NewsCount, contact.Count); this.StylePageNagiation(contact.Count); // Fill Repeater Data from PagedDataSource repeaterData.DataSource = _pagedDataSource; repeaterData.DataBind(); this.NavigationFor = "LoadingData"; }