示例#1
0
 protected void btnSaveLevel_Click(object sender, EventArgs e)
 {
     int schoolId = 0;
     if (int.TryParse(this.hdnSchoolId.Value, out schoolId))
     {
         db.SchoolLevels.Single<SupplySystem.SchoolLevel>(lv => lv.SchoolID == schoolId && lv.LockOutDate == null).LockOutDate = DateTime.Now;
         SupplySystem.SchoolLevel slv = new SupplySystem.SchoolLevel { LevelID = Public.ToShort(this.drpSchoolLevel.SelectedValue), SchoolID = schoolId, 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"]) });
         db.SchoolLevels.InsertOnSubmit(slv);
         db.SubmitChanges();
         this.hdnSchoolId.Value = null;
         this.drpSchoolLevel.Enabled = false;
         this.btnSaveLevel.Enabled = false;
         this.ViewState.Clear();
         this.lblMessage.Text = Public.SUCCESSMESSAGE;
     }
 }
示例#2
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;
        }
    }
示例#3
0
		private void detach_SchoolLevels(SchoolLevel entity)
		{
			this.SendPropertyChanging();
			entity.School = null;
		}
示例#4
0
		private void attach_SchoolLevels(SchoolLevel entity)
		{
			this.SendPropertyChanging();
			entity.School = this;
		}
示例#5
0
 partial void DeleteSchoolLevel(SchoolLevel instance);
示例#6
0
 partial void UpdateSchoolLevel(SchoolLevel instance);
示例#7
0
 partial void InsertSchoolLevel(SchoolLevel instance);