i have this sets of code with setsession and getsession in it
protected void btnCall_Click(Object sender, EventArgs e)
{
if (isCallComplete())
{
Collection<Greeting> collGreeting = sessionHelper.GetSession("CurrentGreetingData") as Collection<Greeting>;
if (collGreeting.Count > 0)
{
Collection<CounterbySA> collCounterBySA = new ServiceFacade(User).SelectByFieldName<CounterbySA>("SAID", 106);//CurrentApplicationUser.id
if (collCounterBySA.Count > 0)
{
Counter counter = new ServiceFacade(User).SelectById<Counter>(collCounterBySA[0].CounterID);
Greeting greeting = collGreeting[0];
BoardQueue boardQueue = new BoardQueue();
boardQueue.BranchID = CurrentApplicationUser.BranchID;
boardQueue.CounterID = counter.ID;
boardQueue.SAID = 106; //CurrentApplicationUser.ID
boardQueue.PlatNumber = greeting.PlatNumber;
boardQueue.Status = (int)CallCustomerStatus.Open;
ResultStatus rs = new ServiceFacade(User).InsertBoardQueue(boardQueue);
voiceCall(string.Format("{0}di{1}", greeting.PlatNumber, counter.Name));
MessageBox.Show(string.Format("{0} Silahkan ke {1}", greeting.PlatNumber, counter.Name));
btnCall.Enabled = false;
btnReCall.Enabled = true;
btnComplete.Enabled = true;
sessionHelper.SetSession("CurrentCallData", boardQueue);
sessionHelper.SetSession("CurrentGreetingTemp", greeting);
}
else
{
MessageBox.Show("SA ini Belom terdaftar di Loket, Silahkan ke manu AssignSA untuk mendaftarkan/menempatkan SA ke Loket");
}
}
else
{
MessageBox.Show("Tidak Ada Customer Untuk Di panggil");
}
}
else if (isCurrentUser())
{
MessageBox.Show("sedang memanggil customer, click panggil ulang apabila customer belum datang");
btnCall.Enabled = true;
btnReCall.Enabled = true;
btnComplete.Enabled = true;
}
else
{
MessageBox.Show("SA lain sedang memanggil Customer, harap menunggu");
}
so if i click button call it will set the 2 session
and this where i get the session
protected void btnReCall_Click(Object sender, EventArgs e)
{
BoardQueue boardQueue = sessionHelper.GetSession("CurrentCallData") as BoardQueue;
if (boardQueue != null)
{
Counter counter = new ServiceFacade(User).SelectById<Counter>(boardQueue.CounterID);
voiceCall(string.Format("{0}di{1}", boardQueue.PlatNumber, counter.Name));
MessageBox.Show(string.Format("{0} Silahkan ke {1}", boardQueue.PlatNumber, counter.Name));
btnNext.Enabled = true;
}
else
{
MessageBox.Show("Harap Memanggil Customer terlebih Dahulu");
}
}
Before the page is refresh it works fine. but after the page refresh the session is gone.
i have done some research about this topic but i couldn't get the answer
Here are the get and set method for the session
public void SetSession(string sKey, object sValue)
{
HttpContext.Current.Session[sKey] = sValue;
AddSession(sKey, true);
}
public object GetSession(string sKey)
{
return ((object)(HttpContext.Current.Session[sKey]));
}
Related
{
public partial class BookNow : Form
{
private const int CP_NOCLOSE_BUTTON = 0x200;
private string title;
private string ad; //Adult
private string ch; //Child
private string sd; //StartDate
private string rd; //ReturnDate
private string ins; //Insurance
private string extb; //Extra Baggage
private int people;
private double total = 0;
Cart c = new Cart();
ArrayList arr = new ArrayList(30);
public BookNow()
{
InitializeComponent();
adult.SelectedIndex = 1;
child.SelectedIndex = 0;
insuranceNo.Checked = true;
tenKG.Checked = true;
}
private void Next_Click(object sender, EventArgs e)
{
if (tour.Text == "Choose A Tour")
{
MessageBox.Show("Please select a tour of your choice", "Choice of Tour Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
tour.Focus();
}
else if (adult.Text == "0" && child.Text == "0")
{
MessageBox.Show("Please select number of Travellers", "Number of Travellers Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
adult.Focus();
}
else if (startDate.Text == returnDate.Text)
{
MessageBox.Show("Start Date and Return Date Cannot be the Same. Please Edit Dates to Continue", "Dates Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
returnDate.Focus();
}
else
{
if (tour.Text == "TSIN - Singapore's Discovery")
total += 1299.00;
else if (tour.Text == "TSEO - Seoul's Highlights")
total += 1899.00;
else if(tour.Text == "TTAI - Taiwan Spotlight")
total += 1000.00;
title = tour.Text;
ad = adult.Text;
ch = child.Text ;
sd = startDate.Text;
rd = returnDate.Text;
if (insuranceYes.Checked)
{
ins += insuranceYes.Text;
total += 29.99;
}
else
{
ins = insuranceNo.Text;
}
if (tenKG.Checked)
extb = tenKG.Text;
else if (twentyKG.Checked)
{
extb = twentyKG.Text;
total += 50.00;
}
else
{
extb = thirtyKG.Text;
total += 80.00;
}
people = int.Parse(ad) + int.Parse(ch);
total = total * people;
cartNow(c);
total = 0;
var result = MessageBox.Show("Added To Cart, Continue To Your Cart?","Cart Updated", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (result == DialogResult.Yes)
{
c.add(c);
Hotel h = new Hotel();
h.Show();
}
}
}
private void Reset_Click(object sender, EventArgs e)
{
}
private void Cart_Click(object sender, EventArgs e)
{
c.Show();
}
This method is to Add into my listview so that i can display and i tried using an array but still unable to do it
public void cartNow (Cart instance)
{
ListViewItem lvl = new ListViewItem(arr[0].ToString());
lvl.SubItems.Add(arr[1].ToString());
lvl.SubItems.Add(ch);
lvl.SubItems.Add(sd);
lvl.SubItems.Add(rd);
lvl.SubItems.Add(ins);
lvl.SubItems.Add(extb);
lvl.SubItems.Add(total.ToString("c2"));
instance.listView1.Items.Add(lvl);
}
private void Close_Click(object sender, EventArgs e)
{
var confirmResult = MessageBox.Show("Closing the booking System will result in clearing the Cart.","Are You sure you want to continue?",
MessageBoxButtons.YesNo);
if (confirmResult == DialogResult.Yes)
{
this.WindowState = FormWindowState.Minimized;
this.ShowInTaskbar = false;
}
}
public void showCart()
{
c.Show();
}
protected override CreateParams CreateParams
{
get
{
CreateParams myCp = base.CreateParams;
myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON;
return myCp;
}
}
}
}
I am able to open up my Cart and display the items inside my listview but when i close the cart and want to run from another form it does not work as the information becomes empty e.g(variable ad which has the number of adults becomes null and nth will be displayed if i try to run the cartNow() method from another class
I am selecting a row from Gridview, working good except for checkbox, like I am assigning value of checkbox retreived from gridview to checkbox that is placed on web form but it isn't represented by checkbox on form, it shows empty checkbox in every case
if (gridviewDesignations.SelectedRow.Cells[5].Text == " ")
{
chkIsHead.Text = gridviewDesignations.SelectedRow.Cells[5].Text;
}
in short, checkbox is not picking value from gridview
Update:
tried this too:
CheckBox chkIsHead = (CheckBox) gridviewDesignations.SelectedRow.Cells[5].Controls[0];
if (chkIsHead.Checked == false)
{
chkIsHead.Checked = false;
}
else
{
chkIsHead.Checked = true;
}
Update:
my full code:
public partial class frmDesignations : System.Web.UI.Page
{
AccessibleVariables accessVariables = new AccessibleVariables(); //Used to access global variables
public void Clear(params TextBox[] txtBoxes)
{
foreach (TextBox txtbx in txtBoxes)
{
txtbx.Text = "";
}
}
public void fillddlDepartments()
{
ManageDepartmentsBizz mngDepBizz = new ManageDepartmentsBizz();
DataSet ds = (DataSet)mngDepBizz.SelectDepartments();
if (ds.Tables[0].Rows.Count != 0)
{
ddlDepartments.DataValueField = "DepID";
ddlDepartments.DataTextField = "DepName";
ddlDepartments.DataSource = ds.Tables[0];
// ddlDepartments.SelectedIndex = -1;
ddlDepartments.DataBind();
ddlDepartments.Items.Insert(0, "--Select--");
}
//else
// ddlDepartments.SelectedIndex = -1;
}
protected void Page_Load(object sender, EventArgs e)
{
if (Session.Count <= 0)
{
Response.Redirect("login.aspx");
}
lblMsgPopUp.Visible = false;
if (!IsPostBack)
{
fillddlDepartments();
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
try
{
int DepartmentID = Convert.ToInt32(ddlDepartments.SelectedValue);
bool IsHead = Convert.ToBoolean(chkIsHead.Checked);
DesignationsBizz DesigBizz = new DesignationsBizz(-1, txtTitle.Text, DepartmentID, txtContactNo.Text, IsHead);
//-1 is bogus,used to fill parameters criteria i.e no of params
ManageDesignationsBizz mngDesigBizz = new ManageDesignationsBizz();
bool Result = mngDesigBizz.Insert(DesigBizz);
if (Result == true)
{
HiddenFieldSetMessage.Value = "Saved";
HiddenFieldShowMessage.Value = "True";
Clear(txtTitle, txtSelectedID, txtContactNo);
}
else
{
HiddenFieldSetMessage.Value = "RecordAlreadyExists";
HiddenFieldShowMessage.Value = "True";
}
}
catch (Exception)
{
HiddenFieldSetMessage.Value = "NotSaved";
HiddenFieldShowMessage.Value = "True";
}
}
protected void btnSearchPopup_Click(object sender, EventArgs e)
{
string DesignationTitle = txtDesignationPopUp.Text;
ManageDesignationsBizz mngDepsBizz = new ManageDesignationsBizz();
DataSet ds = (DataSet)mngDepsBizz.Select(DesignationTitle);
if (ds.Tables[0].Rows.Count != 0)
{
lblMsgPopUp.Visible = false;
gridviewDesignations.DataSource = ds.Tables[0];
gridviewDesignations.DataBind();
gridviewDesignations.Visible = true;
}
else
{
lblMsgPopUp.Visible = true;
gridviewDesignations.Visible = false;
}
}
protected void gridviewDesignations_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
string DesignationTitle = txtDesignationPopUp.Text;
ManageDesignationsBizz mngDepBizz = new ManageDesignationsBizz();
DataSet ds = (DataSet)mngDepBizz.Select(DesignationTitle);
if (ds.Tables[0].Rows.Count != 0)
{
gridviewDesignations.PageIndex = e.NewPageIndex;
gridviewDesignations.DataSource = ds.Tables[0];
gridviewDesignations.DataBind();
gridviewDesignations.Visible = true;
}
}
protected void btnEdit_Click(object sender, EventArgs e)
{
if (gridviewDesignations.SelectedRow != null)
{
if (gridviewDesignations.SelectedRow.Cells[1].Text == " ")
{
txtSelectedID.Text = string.Empty;
}
else
{
txtSelectedID.Text = gridviewDesignations.SelectedRow.Cells[1].Text;
}
if (gridviewDesignations.SelectedRow.Cells[2].Text == " ")
{
txtTitle.Text = string.Empty;
}
else
{
txtTitle.Text = gridviewDesignations.SelectedRow.Cells[2].Text;
}
if (gridviewDesignations.SelectedRow.Cells[3].Text == " ")
{
ddlDepartments.SelectedValue = string.Empty;
}
else
{
ddlDepartments.SelectedValue = gridviewDesignations.SelectedRow.Cells[3].Text;
accessVariables.DepID = Convert.ToInt32(gridviewDesignations.SelectedRow.Cells[3].Text);
ViewState["depID"] = accessVariables.DepID;
}
if (gridviewDesignations.SelectedRow.Cells[4].Text == " ")
{
txtContactNo.Text = string.Empty;
}
else
{
txtContactNo.Text = gridviewDesignations.SelectedRow.Cells[4].Text;
}
CheckBox chkIsHead = (CheckBox) gridviewDesignations.SelectedRow.Cells[5].Controls[0];
if (chkIsHead.Checked == false)
{
chkIsHead.Checked = false;
}
else
{
chkIsHead.Checked = true;
}
gridviewDesignations.DataBind();
gridviewDesignations.SelectedIndex = -1;
HiddenFieldShowHideButtons.Value = "True";
}
}
protected void btnUpdatePopUp_Click(object sender, EventArgs e)
{
try
{
int id = Convert.ToInt32(txtSelectedID.Text);
int DepartmentID = Convert.ToInt32(ddlDepartments.SelectedValue);
bool IsHead = Convert.ToBoolean(chkIsHead.Checked);
DesignationsBizz DesigBizz = new DesignationsBizz(id, txtTitle.Text, DepartmentID, txtContactNo.Text, IsHead );
ManageDesignationsBizz mngDesigBizz = new ManageDesignationsBizz();
bool Result = mngDesigBizz.Update(DesigBizz);
if (Result == true)
{
HiddenFieldSetMessage.Value = "Updated";
HiddenFieldShowMessage.Value = "True";
Clear(txtSelectedID, txtTitle, txtContactNo);
}
else
{
HiddenFieldSetMessage.Value = "NotUpdated";
HiddenFieldShowMessage.Value = "True";
}
}
catch (Exception)
{
HiddenFieldSetMessage.Value = "NotUpdated";
HiddenFieldShowMessage.Value = "True";
}
}
protected void btnDeletePopUp_Click(object sender, EventArgs e)
{
try
{
int ID = Convert.ToInt32(txtSelectedID.Text.Trim());
ManageDesignationsBizz mngDepBizz = new ManageDesignationsBizz();
mngDepBizz.Delete(ID);
Clear(txtTitle, txtSelectedID, txtContactNo);
HiddenFieldSetMessage.Value = "Deleted";
HiddenFieldShowMessage.Value = "True";
}
catch (Exception)
{
HiddenFieldSetMessage.Value = "NotDeleted";
HiddenFieldShowMessage.Value = "True";
}
}
protected void btnClosePopup_Click(object sender, EventArgs e)
{
Clear(txtTitle, txtSelectedID, txtContactNo);
}
protected void ddlDepartments_SelectedIndexChanged(object sender, EventArgs e)
{
if (txtSelectedID.Text != "")
{
accessVariables.DepID = Convert.ToInt32(ddlDepartments.SelectedValue);
ViewState["depID"] = accessVariables.DepID;
}
else
{
accessVariables.DepID = Convert.ToInt32(ddlDepartments.SelectedValue);
ViewState["depID"] = accessVariables.DepID;
}
}
protected void chkIsHead_CheckedChanged(object sender, EventArgs e)
{
if (txtSelectedID.Text != "")
{
int DepID = Convert.ToInt32(ViewState["depID"]);
ManageDesignationsBizz mngDesig = new ManageDesignationsBizz();
bool isHead = mngDesig.SelectIsHeadExistsByDepID(DepID);
if (isHead == true)
{
HiddenFieldSetMessage.Value = "HeadExists";
HiddenFieldShowMessage.Value = "True";
chkIsHead.Checked = false;
}
}
else
{
int DepID = Convert.ToInt32(ViewState["depID"]);
ManageDesignationsBizz mngDesig = new ManageDesignationsBizz();
bool isHead = mngDesig.SelectIsHeadExistsByDepID(DepID);
if (isHead == true)
{
HiddenFieldSetMessage.Value = "HeadExists";
HiddenFieldShowMessage.Value = "True";
chkIsHead.Checked = false;
}
}
}
}
I believe the following is what you need to do:
Then select EditProgrammatically.
I'm not sure if yoou'll need to manually put data into the grid though but that won't be too hard. Examples can be seen here : http://msdn.microsoft.com/en-us/library/system.data.datatable(v=vs.110).aspx
PS : You can set the DataSource in the grid view to the DataTable.
Hello im learning c# at the moment and wish to If a statement is true then redirect to another ASpage so far with no luck.
My attempt is below, what the code does is check the text boxes to see if they have a value and if they do then it will save that record in the database as a new user.The code works its just the redirect at the end that isn't working.
Any help would be great
protected void Button2_Click(object sender, EventArgs e)
{
if (!String.IsNullOrWhiteSpace(txtTitle.Text))
{
user.Title = txtTitle.Text;
}
if (!String.IsNullOrWhiteSpace(txtFirstName.Text))
{
user.Forename = txtFirstName.Text;
}
if (!String.IsNullOrWhiteSpace(txtSurname.Text))
{
user.Surname = txtSurname.Text;
}
if (!String.IsNullOrWhiteSpace(txtUsername.Text))
{
user.Username = txtUsername.Text;
}
// call save function at end of statements
if (!String.IsNullOrWhiteSpace(txtAddress.Text))
{
user.Address1 = txtAddress.Text;
}
if (!String.IsNullOrWhiteSpace(txtAddress2.Text))
{
user.Address2 = txtAddress.Text;
}
if (!String.IsNullOrWhiteSpace(txtPostcode.Text))
{
user.PostCode = txtPostcode.Text;
}
if (!String.IsNullOrWhiteSpace(txtCode.Text))
{
user.CountryCode = txtCode.Text;
}
if (!String.IsNullOrWhiteSpace(txtEmail.Text))
{
user.Email = txtEmail.Text;
}
//if (!string.IsNullOrWhiteSpace(txtDate.Text))
//{
// DateTime _entrydate;
// if (DateTime.TryParse(txtDate.Text, out _entrydate))
// {
// user.EntryDate = _entrydate;
// }
//}
user.CompanyID = AppSession.Company.ID;
user.Status = 1;
user.PasswordHash = "test";
user.EntryDate = DateTime.Now;
user.UpdateDate = DateTime.Now;
user.Deleted = false;
bool result = userDao.SaveNewUser(user);
if (result == true)
{
Response.Redirect("User/List/");
}
}
}
}
You need to Redirect to another ASPX page, not a directory.
Something like
Response.Redirect("User/List/UserList.aspx");
Private static string CheckValues(TextBox t)
{
if(!string.IsnullOrEmpty(t.Text.Trim())
{
return t.Text;
}
}
protected void Button2_Click(object sender, EventArgs e)
{
user.Title =CheckValues(txtTitle.Text);
user.Forename = CheckValues(txtFirstName.Text);
user.Surname = CheckValues(txtSurname.Text);
user.Username = CheckValues(txtUsername.Text);
user.Address1 = CheckValues(txtAddress.Text);
user.Address2 = CheckValues(txtAddress.Text);
user.PostCode = CheckValues(txtPostcode.Text);
user.CountryCode = CheckValues(txtCode.Text);
user.Email = CheckValues(txtEmail.Text);
if(CheckValues(txtDate.Text))
{
DateTime _entrydate;
if (DateTime.TryParse(txtDate.Text, out _entrydate))
{
user.EntryDate = _entrydate;
}
}
bool result = userDao.SaveNewUser(user);
if (result)
{
Response.Redirect("~/User/List/somepage"); //~ for root directory , if there is any page use that or use the exact url here.
}
}
Kindly note the above url format will only work if you have URL Rewriting/Routing in your app
I have been looking all over the Internet for this and have found similar, but none of it will work for me. Everything I have found assumes the listbox is on the main form and not the secondary form, or the code is for an older version of C# or Visual Studio (I am using VS2008).
I am creating a web browser that has a button on the main form (called frmMyBrowser) to open a dialog (frmBookmarks) with a listbox (lstBookmark) with bookmarked URLs. I need to be able to double click on an item (the bookmarked URL) and have the text pasted into the address bar (cmbAddress) of the main form.
Any help would be GREATLY appreciated.
I figured out that if I create the window at runtime, I can get it to work. In case anyone is interested, the code I used is below.
public void frmMyBrowser_ShowFavorites(object sender, EventArgs e)
{
frmFavorites.ShowIcon = false;
frmFavorites.ShowInTaskbar = false;
frmFavorites.MinimizeBox = false;
frmFavorites.MaximizeBox = false;
frmFavorites.ControlBox = false;
frmFavorites.Text = "Bookmarks";
frmFavorites.Width = 500;
frmFavorites.Height = 350;
frmFavorites.Controls.Add(lstFavorites);
frmFavorites.Controls.Add(btnRemoveFavorite);
frmFavorites.Controls.Add(btnAddFavorite);
frmFavorites.Controls.Add(btnCloseFavorites);
frmFavorites.Controls.Add(txtCurrentUrl);
lstFavorites.Width = 484;
lstFavorites.Height = 245;
btnRemoveFavorite.Location = new Point(8, 280);
btnAddFavorite.Location = new Point(8, 255);
btnCloseFavorites.Location = new Point(400, 255);
txtCurrentUrl.Location = new Point(110, 255);
txtCurrentUrl.Size = new Size(255, 20);
btnAddFavorite.Text = "Add";
btnRemoveFavorite.Text = "Remove";
btnCloseFavorites.Text = "Close";
txtCurrentUrl.Text = wbBrowser.Url.ToString();
btnAddFavorite.Click += new EventHandler(btnAddFavorite_Click);
btnRemoveFavorite.Click += new EventHandler(btnRemoveFavorite_Click);
frmFavorites.Load += new EventHandler(frmFavorites_Load);
btnCloseFavorites.Click += new EventHandler(btnCloseFavorites_Click);
lstFavorites.MouseDoubleClick += new MouseEventHandler(lstFavorites_MouseDoubleClick);
frmFavorites.Show();
}
public void btnCloseFavorites_Click(object sender, EventArgs e)
{
if (lstFavorites.Items.Count > 0)
{
using (StreamWriter writer = new System.IO.StreamWriter(#Application.StartupPath + "\\favorites.txt"))
{
for (int i = 0; i < lstFavorites.Items.Count; i++)
{
writer.WriteLine(lstFavorites.Items[i].ToString());
}
writer.Close();
}
}
frmFavorites.Hide();
}
public void btnAddFavorite_Click(object sender, EventArgs e)
{
string strFavoriteAddress = wbBrowser.Url.ToString();
if (!lstFavorites.Items.Contains(strFavoriteAddress))
{
lstFavorites.Items.Add(strFavoriteAddress);
MessageBox.Show("Favorite Added", "Message");
}
else if (lstFavorites.Items.Contains(strFavoriteAddress))
{
MessageBox.Show("This site already exists in your Favorites list!", "Error");
}
else
{
}
}
public void btnRemoveFavorite_Click(object sender, EventArgs e)
{
try
{
lstFavorites.Items.RemoveAt(lstFavorites.SelectedIndices[0]);
}
catch
{
MessageBox.Show("You need to select an item", "Error");
}
}
public void frmFavorites_Load(object sender, EventArgs e)
{
try
{
using (StreamReader reader = new System.IO.StreamReader(#Application.StartupPath + "\\favorites.txt"))
{
while (!reader.EndOfStream)
{
for (int i = 0; i < 4; i++)
{
string strListItem = reader.ReadLine();
if (!String.IsNullOrEmpty(strListItem))
{
lstFavorites.Items.Add(strListItem);
}
}
}
reader.Close();
}
}
catch
{
MessageBox.Show("An error has occured", "Error");
}
}
private void lstFavorites_MouseDoubleClick(object sender, MouseEventArgs e)
{
string strSelectedAddress = lstFavorites.Text.ToString();
cmbAddress.Text = strSelectedAddress;
wbBrowser.Navigate(strSelectedAddress);
frmFavorites.Hide();
}
Firefox is causing a few problems for me at the moment and I can't quite figure them out.
I have two listboxes, one is populated when the page is loaded, and the other when an item from the first is selected then click view button. The problem I am having is the 2nd listbox populates for just a split second and then everything is deleted. The function works in all other browsers I have tested.. IE, Chrome, and Safari..
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Data;
using System.Data.SqlClient;
using DAL;
namespace ACESAdmin2.AcesSetup
{
public partial class storefront : System.Web.UI.Page
{
private string selectedCustomer
{
get { return Session["selectedCustomer"] != null ? (string)Session["selectedCustomer"] : string.Empty; }
set { Session["selectedCustomer"] = value; }
}
private string selectedCatalog
{
get { return Session["selectedCatalog"] != null ? (string)Session["selectedCatalog"] : string.Empty; }
set { Session["selectedCatalog"] = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadPage();
}
}
private void LoadPage()
{
initControls();
#region role setting
try
{
//check user role to determine editing rights
string usersRole = Roles.GetRolesForUser(Membership.GetUser().UserName)[0];
MembershipUser user = Membership.GetUser();
switch (usersRole)
{
case "BasicUser":
AlignTextNoneRadio.Enabled = false;
AlignTextLeftRadio.Enabled = false;
AlignRightRadio.Enabled = false;
AlignCenterRadio.Enabled = false;
headerText.Enabled = false;
returnPolicy.Enabled = false;
welcomeMessageTextBox.Enabled = false;
homeText.Enabled = false;
homeLink.Enabled = false;
updateStoreButton.Enabled = false;
break;
case "Customer":
homeLink.Enabled = false;
homeText.Enabled = false;
break;
case "SalesRep":
case "Admin":
case "SuperAdmin":
break;
default:
break;
}
}
catch (NullReferenceException error)
{
string message;
message = error.ToString();
Response.Redirect("../error.aspx");
}
#endregion
#region Accordion Pane Settings
if (ViewState["SelectedAccordionIndex"] == null)
{
MyAccordion.SelectedIndex = -1;
}
else
{
MyAccordion.SelectedIndex = (int)ViewState["SelectedAccordionIndex"];
}
#endregion
}
private void initControls()
{
//Viewable to all
#region customer label
if (selectedCustomer != null)
{
string customerName = DAL.Util.getCustomerName().ToString();
if (customerName != null || customerName != String.Empty)
{
lblCustomer.Text = "Customer: <font color=maroon>" + customerName + "</font>";
lblCustomer.Visible = true;
}
else
{
lblCustomer.Text = "Customer: <font color=maroon>" + selectedCustomer.ToString() + "</font>";
lblCustomer.Visible = true;
}
}
#endregion
//Edit Store Front
#region Populate Fields
#region headerAlign
string headerAlign = DAL.Util.getHeaderAlign().ToString();
switch (headerAlign)
{
case "left":
AlignTextLeftRadio.Checked = true;
break;
case "center":
AlignCenterRadio.Checked = true;
break;
case "right":
AlignRightRadio.Checked = true;
break;
default:
AlignTextNoneRadio.Checked = true;
break;
}
#endregion
welcomeMessageTextBox.Text = DAL.Util.getWelcome().ToString();
headerText.Text = DAL.Util.getHeaderText().ToString();
returnPolicy.Text = DAL.Util.getReturn().ToString();
homeLink.Text = DAL.Util.getHomeLink().ToString();
homeText.Text = DAL.Util.getHomeText().ToString();
#endregion
//BJIT Setup
#region popultae fields
ddlSelectVendor.DataSource = DAL.Util.getVendors();
ddlSelectVendor.DataBind();
listCatalogs.DataSource = DAL.Util.getCatalogs();
listCatalogs.DataBind();
#endregion
}
protected void returnButton_Click(object sender, EventArgs e)
{
//Takes user back to main admin page
Response.Redirect("../Admin/mainAdmin.aspx");
}
protected void dropdownlist_SelectedInexChange(object sender, EventArgs e)
{
ViewState["SelectedAccordionIndex"] = MyAccordion.SelectedIndex;
}
protected void updateStoreButton_Click(object sender, EventArgs e)
{
switch(MyAccordion.SelectedIndex)
{
case 0:
#region Header Value
string selectedHeaderAlign = null;
foreach (Control control in this.RadioPanel.Controls)
{
if (control is RadioButton)
{
RadioButton radio = control as RadioButton;
if (radio.Checked)
{
selectedHeaderAlign = radio.Text.ToLower();
}
}
}
#endregion
//updates customer information in the table
string sqlSf = "Update Store SET HeaderAlign = #HeaderAlign, HeaderText=#HeaderText, ReturnPolicy=#ReturnPolicy, WelcomeMessage=#WelcomeMessage, HomeTextLink=#HomeTextLink, HomeLink=#HomeLink"
+ " WHERE CustomerID='" + HttpContext.Current.Session["selectedCustomer"].ToString() + "'";
//setting parameters
#region Parameter Values
AdoUtil.ACESSQLParameterCollection parameters = new AdoUtil.ACESSQLParameterCollection();
AdoUtil.ACESSQLParameter param = new AdoUtil.ACESSQLParameter();
param.ParamName = "#HeaderAlign";
param.ParamValue = selectedHeaderAlign.ToString();
param.ParamDBType = SqlDbType.VarChar;
parameters.Add(param);
param = new AdoUtil.ACESSQLParameter();
param.ParamName = "#HeaderText";
param.ParamValue = headerText.Text.ToString();
param.ParamDBType = SqlDbType.VarChar;
parameters.Add(param);
param = new AdoUtil.ACESSQLParameter();
param.ParamName = "#ReturnPolicy";
param.ParamValue = returnPolicy.Text.ToString();
param.ParamDBType = SqlDbType.VarChar;
parameters.Add(param);
param = new AdoUtil.ACESSQLParameter();
param.ParamName = "#WelcomeMessage";
param.ParamValue = welcomeMessageTextBox.Text.ToString();
param.ParamDBType = SqlDbType.VarChar;
parameters.Add(param);
param = new AdoUtil.ACESSQLParameter();
param.ParamName = "#HomeTextLink";
param.ParamValue = homeText.Text.ToString();
param.ParamDBType = SqlDbType.VarChar;
parameters.Add(param);
param = new AdoUtil.ACESSQLParameter();
param.ParamName = "#HomeLink";
param.ParamValue = homeLink.Text.ToString();
param.ParamDBType = SqlDbType.VarChar;
parameters.Add(param);
#endregion
AdoUtil.ExecuteNonQuery(sqlSf, parameters);
break;
case 1:
//BJIT Updates
string sqlBJIT = "Update";
break;
default:
break;
}
MyAccordion.SelectedIndex = -1;
}
#region BJIT Control Events
//BJIT Button
protected void btnAddCustomer_Click(object sender, EventArgs e)
{
if (listItems.SelectedIndex != -1)
{
ArrayList removeArr = new ArrayList();
listItemProfiles.SelectedIndex = -1;
//Copy selected items to listItemProfiles
foreach (ListItem li in listItems.Items)
{
if (li.Selected)
{
listItemProfiles.Items.Add(li);
removeArr.Add(li);
}
}
//Remove the selected items from listItems
foreach (ListItem li in removeArr)
{
listItems.Items.Remove(li);
}
Util.WebFunctions.SortListBox(listItemProfiles);
}
}
//BJIT Button
protected void btnRemoveCustomer_Click(object sender, EventArgs e)
{
if (listItemProfiles.SelectedIndex != -1)
{
ArrayList removeArr = new ArrayList();
listItems.SelectedIndex = -1;
//Copy selected items to listItems
foreach (ListItem li in listItemProfiles.Items)
{
if (li.Selected)
{
li.Selected = false;
listItems.Items.Add(li);
removeArr.Add(li);
}
}
//Remove the selected items from listItemProfiles
foreach (ListItem li in removeArr)
{
listItemProfiles.Items.Remove(li);
}
Util.WebFunctions.SortListBox(listItems);
}
}
//BJIT Button
protected void viewBtn_Click(object sender, EventArgs e)
{
if (listCatalogs.SelectedItem != null)
{
listItemCatalogs.DataSource = DAL.Util.getCatalogProfile(listCatalogs.SelectedValue.ToString());
listItemCatalogs.DataBind();
}
}
//BJIT Button
protected void editBtn_Click(object sender, EventArgs e)
{
if (listCatalogs.SelectedItem != null)
{
#region controls visible
lblVendor.Visible = true;
ddlSelectVendor.Visible = true;
lblItemProfile.Visible = true;
lblItems.Visible = true;
listItems.Visible = true;
listItemProfiles.Visible = true;
btnAddCustomer.Visible = true;
btnRemoveCustomer.Visible = true;
lblItemsCatalog.Visible = false;
listItemCatalogs.Visible = false;
//listItemCatalogs.Items.Clear();
#endregion
#region disable controls
//listCatalogs.Enabled = false;
listItemCatalogs.Enabled = false;
editBtn.Enabled = false;
viewBtn.Enabled = false;
#endregion
listItemProfiles.DataSource = DAL.Util.getCatalogProfile(listCatalogs.SelectedValue.ToString());
listItemProfiles.DataBind();
}
}
//BJIT Drop Down List
protected void ddlSelectVendor_Changed(object sender, EventArgs e)
{
listItems.DataSource = DAL.Util.getVenorItems(ddlSelectVendor.SelectedItem.ToString());
listItems.DataBind();
}
#endregion
}
}
With this there is a little more functionality that was not described previously and with this Firefox also does not keep the data / keep the controls visible when the editBtn_Click is initiated.
And again if there is anything i can clear up I will do my best to reword or anything.
Thank you.
I don't exactly know what happened, but it is working now. I rebuilt the .cs page and recompiled the whole site and everything works. Also cleared the cache of all browsers..