Exemplo n.º 1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (this.Page.IsValid)
        {
            int schCode = Public.ToInt(this.txtSchoolCode.Text);
            int areaCode = Public.ToInt(this.txtAreaCode.Text);

            if (schCode > areaCode + 1000 || schCode <= areaCode)
            {
                this.lblMessage.Text = string.Format("کد آموزشگاه باید بین {0} و {1} باشد", areaCode + 1000, areaCode);
                return;
            }

            SupplySystem.School school = new SupplySystem.School();
            school.SchoolCode = schCode;
            school.SchoolName = this.txtSchoolName.Text.Trim();
            school.SchoolKindID = Public.ToByte(this.drpSchoolKind.SelectedValue);
            school.Gender = (byte)this.drpGender.SelectedIndex;
            school.AreaCode = Public.ToInt(this.txtAreaCode.Text);
            school.CityID = Public.ToShort(this.txtCityCode.Text);
            school.Village = this.txtVillage.Text.Trim();
            school.Street = this.txtStreet.Text.Trim();
            school.Line = this.txtAlly.Text.Trim();
            school.Pelak = this.txtPelak.Text.Trim();
            school.PostalCode = this.txtPostCode.Text.Trim();
            school.Phone = this.txtPhone.Text.Trim();
            school.EmployeesCount_Fixed = Public.ToByte(this.txtFixed.Text);
            school.EmployeesCount_Changable = Public.ToByte(this.txtChangable.Text);
            school.ManagerID = this.txtManagerName.Text.Trim();
            school.AssistanceID = this.txtAssistanceName.Text.Trim();

            SupplySystem.SchoolLevel slv = new SupplySystem.SchoolLevel { LevelID = Public.ToShort(this.drpSchoolLevel.SelectedValue), SubmitDate = DateTime.Now };
            for (int i = 0; i < this.grdSubLevels.Rows.Count; i++)
            {
                slv.SchoolSubLevels.Add(new SupplySystem.SchoolSubLevel
                {
                    SubLevelID = Public.ToShort(this.grdSubLevels.DataKeys[i].Value)
                  ,
                    BoysCount = Public.ToShort(((TextBox)this.grdSubLevels.Rows[i].FindControl("txtBoysCount")).Text)
                  ,
                    GirlsCount = Public.ToShort(((TextBox)this.grdSubLevels.Rows[i].FindControl("txtGirlsCount")).Text)
                });
            }
            slv.SchoolSubLevels.Add(new SupplySystem.SchoolSubLevel { SubLevelID = Public.ToShort(this.ViewState["EmplSLID"]) });
            school.SchoolLevels.Add(slv);

            SupplySystem.User user = new SupplySystem.User
            {
                UserName = this.txtSchoolCode.Text.Trim(),
                PassWord = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile((Public.ToInt(this.txtSchoolCode.Text.Trim()) * 2).ToString(), "SHA1"),
                FirstName = this.txtManagerName.Text.Trim(),
                LastName = string.Empty,
                Gender = (byte)this.drpGender.SelectedIndex,
                Phone = this.txtPhone.Text.Trim()
            };
            user.UsersInRoles.Add(new SupplySystem.UsersInRole { RoleID = (short)Public.Role.SchoolManager, School = school, SubmitDate = DateTime.Now });
            db.Schools.InsertOnSubmit(school);

            int disIntegId = 0;
            if (Request.QueryString["dtg"] != null && int.TryParse(TamperProofString.QueryStringDecode(Request.QueryString["dtg"]), out disIntegId))
            {
                SupplySystem.Integration dtg = db.Integrations.First<SupplySystem.Integration>(tg => tg.IntegrationID == disIntegId && tg.IntegrationMode == (byte)Public.IntegrationMode.DisIntegration);
                dtg.IntegratedSchools.Add(new SupplySystem.IntegratedSchool { School = school });
                db.SubmitChanges();
                Response.Redirect("~/School/DisIntegration.aspx");
            }

            db.SubmitChanges();
            this.lblMessage.Text = Public.SUCCESSMESSAGE;
        }
    }
Exemplo n.º 2
0
		private void detach_Schools(School entity)
		{
			this.SendPropertyChanging();
			entity.SchoolKind = null;
		}
Exemplo n.º 3
0
		private void attach_Schools(School entity)
		{
			this.SendPropertyChanging();
			entity.SchoolKind = this;
		}
Exemplo n.º 4
0
 partial void DeleteSchool(School instance);
Exemplo n.º 5
0
 partial void UpdateSchool(School instance);
Exemplo n.º 6
0
 partial void InsertSchool(School instance);