Beispiel #1
0
        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;
                }
            }
        }
Beispiel #2
0
        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;
            }
        }