protected void uiGridViewCities_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditCity") { IStock.BLL.Cities objData = new IStock.BLL.Cities(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); uiTextBoxName.Text = objData.Name; uiTextBoxDesc.Text = objData.Description; uiDropDownListLines.SelectedValue = objData.LineID.ToString(); uiPanelAllCities.Visible = false; uiPanelEditCities.Visible = true; CurrentCity = objData; BindCities(); } else if (e.CommandName == "DeleteCity") { try { IStock.BLL.Cities objData = new IStock.BLL.Cities(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); objData.MarkAsDeleted(); objData.Save(); CurrentCity = null; BindCities(); } catch (Exception ex) { uipanelError.Visible = true; } } }
private void BindCities() { IStock.BLL.Cities Cities = new IStock.BLL.Cities(); if(!string.IsNullOrEmpty(uiDropDownListLines.SelectedValue)) Cities.GetCitiesByLineID(Convert.ToInt32(uiDropDownListLines.SelectedValue)); Cities.Sort = "Name"; uiGridViewCities.DataSource = Cities.DefaultView; uiGridViewCities.DataBind(); }
protected void uiLinkButtonCancel_Click(object sender, EventArgs e) { ClearFields(); CurrentCity = null; uiPanelEditCities.Visible = false; uiPanelAllCities.Visible = true; }
protected void uiLinkButtonOK_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(uiDropDownListLines.SelectedValue)) { IStock.BLL.Cities City = new IStock.BLL.Cities(); if (CurrentCity == null) City.AddNew(); else City = CurrentCity; City.Name = uiTextBoxName.Text; City.Description = uiTextBoxDesc.Text; City.LineID = Convert.ToInt32(uiDropDownListLines.SelectedValue); City.Save(); ClearFields(); CurrentCity = null; uiPanelEditCities.Visible = false; uiPanelAllCities.Visible = true; uipanelError.Visible = false; BindCities(); } else { uipanelError.Visible = true; } }
private void LoadDDls() { IStock.BLL.ClientTypes clientTypes = new IStock.BLL.ClientTypes(); clientTypes.LoadAll(); clientTypes.Sort = "Name"; uiDropDownListClientTypes.DataSource = clientTypes.DefaultView; uiDropDownListClientTypes.DataTextField = "Name"; uiDropDownListClientTypes.DataValueField = "ClientTypeID"; uiDropDownListClientTypes.DataBind(); uiDropDownListClientTypes.Items.Insert(0, new ListItem("إختر التصنيف","")); IStock.BLL.Cities cities = new IStock.BLL.Cities(); cities.LoadAll(); cities.Sort = "Name"; uiDropDownListCities.DataSource = cities.DefaultView; uiDropDownListCities.DataTextField = "Name"; uiDropDownListCities.DataValueField = "CityID"; uiDropDownListCities.DataBind(); uiDropDownListCities.Items.Insert(0, new ListItem("إختر المدينة","")); }