示例#1
0
        protected void btnEditCitizen_Click(object sender, EventArgs e)
        {
            //Get the button that raised the event
            Button btn = (Button)sender;

            //Get the row that contains this button
            GridViewRow gvr = (GridViewRow)btn.NamingContainer;

            if (gvr.Cells.Count <= 1)
            {
                return;
            }

            CitizenInfo _CitizenInfo = new CitizenInfo();

            _CitizenInfo.FirstName            = gvr.Cells[1].Text;
            _CitizenInfo.LastName             = gvr.Cells[2].Text;
            _CitizenInfo.FatherNationalNumber = gvr.Cells[3].Text.Replace("&nbsp;", string.Empty);
            _CitizenInfo.MotherNationalNumber = gvr.Cells[4].Text.Replace("&nbsp;", string.Empty);
            _CitizenInfo.NationalNumber       = gvr.Cells[5].Text;
            _CitizenInfo.Birthday             = gvr.Cells[6].Text;
            _CitizenInfo.BirthPlace           = gvr.Cells[7].Text;
            _CitizenInfo.KiedPlace            = gvr.Cells[8].Text;
            _CitizenInfo.KiedNumber           = gvr.Cells[9].Text;
            _CitizenInfo.Gender       = gvr.Cells[10].Text;
            _CitizenInfo.SocialStatus = gvr.Cells[11].Text;
            _CitizenInfo.Religion     = gvr.Cells[12].Text;

            Session["CitizenInfo"] = _CitizenInfo;

            Response.Redirect("/Administration/Citizen/AddCitizen");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            tblRole role = (tblRole)Session["Role"];

            if (role == null || !role.AddCitizen)
            {
                Response.Redirect("/403");
            }


            _CitizenInfo = (CitizenInfo)Session["CitizenInfo"];
            if (_CitizenInfo != null)
            {
                EditPage = true;
                NationalNumber.Disabled    = true;
                FirstName.Value            = _CitizenInfo.FirstName;
                LastName.Value             = _CitizenInfo.LastName;
                FatherNationalNumber.Value = _CitizenInfo.FatherNationalNumber;
                MotherNationalNumber.Value = _CitizenInfo.MotherNationalNumber;
                NationalNumber.Value       = _CitizenInfo.NationalNumber;
                Birthday.Value             = DateTime.Parse(_CitizenInfo.Birthday).ToString("yyyy-MM-dd");
                BirthPlace.Value           = _CitizenInfo.BirthPlace;
                KiedPlace.Value            = _CitizenInfo.KiedPlace;
                KiedNumber.Value           = _CitizenInfo.KiedNumber;
                Religion.Value             = _CitizenInfo.Religion;

                switch (_CitizenInfo.Gender)
                {
                case "ذكر":
                    male.Checked = true;
                    break;

                case "أنثى":
                    female.Checked = true;
                    break;
                }


                switch (_CitizenInfo.SocialStatus)
                {
                case "عازب":
                    ss1.Checked = true;
                    break;

                case "متأهل":
                    ss2.Checked = true;
                    break;

                case "أرمل":
                    ss3.Checked = true;
                    break;

                case "مطلق":
                    ss4.Checked = true;
                    break;
                }


                if (Directory.Exists(Server.MapPath("~/Images/" + _CitizenInfo.NationalNumber + "/")))
                {
                    foreach (string item in Directory.GetFiles(Server.MapPath("~/Images/" + _CitizenInfo.NationalNumber + "/")))
                    {
                        if (Path.GetFileName(item).Contains("Profile"))
                        {
                            Image1.ImageUrl = "~/Images/" + _CitizenInfo.NationalNumber + "/" + Path.GetFileName(item);
                            break;
                        }
                    }
                }

                btnAdd.Text = "حفظ التعديلات";

                Session["CitizenInfo"] = null;
            }
        }