コード例 #1
0
ファイル: default.aspx.cs プロジェクト: cmsni/skylarkarean
        protected void grdDistricts_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Edit")
            {
                int index = Convert.ToInt32(e.CommandArgument);
                string value = this.grdDistricts.DataKeys[index].Values["id"].ToString();


                Response.Redirect("edit.aspx?id=" + value.ToString());
            }


            if (e.CommandName == "DeleteDistrict")
            {
                int index = Convert.ToInt32(e.CommandArgument);
                string value = this.grdDistricts.DataKeys[index].Values["id"].ToString();


                       _district = _dal.GetDistrictsById(new Guid(value));
                       _district.isDeleted = true;
                       _district.deletedDate = DateTime.Now;
                       _dal.SkyLarkArenaEntities.SaveChanges();

                      Response.Redirect("default.aspx");

            }

        }
コード例 #2
0
ファイル: edit.aspx.cs プロジェクト: cmsni/skylarkarean
        protected void Page_Load(object sender, EventArgs e)
        {

            try
            {


                MasterPagePropertiesInterface m = Master as MasterPagePropertiesInterface;
                if (m != null) m.themeTitle = "Districts Edit";

                district _district = new district();


                if (!IsPostBack)
                {

                    string id = Request.QueryString["id"];
                    if (id != "00000000-0000-0000-0000-000000000000")
                    {
                        _guid = string.IsNullOrEmpty(id) ? new Guid() : new Guid(id);
                        _district = _dal.GetDistrictsById(_guid);



                    }





                    txtName.Text = _district.name;
                    txtPrefix.Text = Convert.ToString(_district.prefix);
                }




            }
                catch(Exception ex)
            {
 

            }

        }
コード例 #3
0
ファイル: edit.aspx.cs プロジェクト: cmsni/skylarkarean
        protected void btnSave_Click(object sender, EventArgs e)
        {

       
                district _district = new district();


                string id = Request.QueryString["id"];
                if (id != "00000000-0000-0000-0000-000000000000")
                {
                     _guid = string.IsNullOrEmpty(id) ? new Guid() : new Guid(id);

                }


                    _district = _dal.GetDistrictsById(_guid);


                    _district.name = txtName.Text;
                    _district.prefix = Convert.ToInt32(txtPrefix.Text);

                    _district.isDeleted = false;
                    if (id == "00000000-0000-0000-0000-000000000000")
                    {
                        _dal.SkyLarkArenaEntities.districts.Add(_district);
                    }


                    _dal.SkyLarkArenaEntities.SaveChanges();
            

                    Response.Redirect("default.aspx");

               
            
        }
コード例 #4
0
ファイル: SkyLarkArenaDa.cs プロジェクト: cmsni/skylarkarean
        public district GetDistrictsById(Guid _districtId)
        {
            
          try
            {
                if (_districtId == Guid.Empty)
                {
                    district _district = new district();
                    return _district;
                }
                else
                {

                    var q = SkyLarkArenaEntities.districts.Where(p => p.id == _districtId && p.isDeleted == false);

                    if (q == null)
                        throw new EntityContextException(string.Format("A district could not be found {0}!", _districtId));
                    else
                        return q.ToList()[0];
                }
            }
            catch (Exception ex)
            {
                throw new EntityContextException("GetPlayerBYID failed.", ex);
            }
        }