Exemple #1
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         try
         {
             SupplySystem.User user = new SupplySystem.User
             {
                 UserName = this.txtUserName.Text,
                 PassWord = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtPassword.Text, "SHA1"),
                 FirstName = this.txtName.Text,
                 LastName = this.txtFamily.Text,
                 Gender = (byte)this.drpGender.SelectedIndex,
                 Phone = this.txtPhone.Text
             };
             user.UsersInRoles.Add(new SupplySystem.UsersInRole { RoleID = Public.ToShort(this.drpRoles.SelectedValue), SubmitDate = DateTime.Now });
             SupplySystem.SupplySystem db = new SupplySystem.SupplySystem(Public.ConnectionString);
             db.Users.InsertOnSubmit(user);
             db.SubmitChanges();
             Response.Redirect("~/Default.aspx");
         }
         catch (Exception ex)
         {
             if (ex.Message.Contains("IX_Users"))
             {
                 this.lblMessage.Text = "نام کاربری تکراری میباشد!";
             }
         }
     }
 }
Exemple #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;
        }
    }
Exemple #3
0
 partial void UpdateUser(User instance);
Exemple #4
0
 partial void DeleteUser(User instance);
Exemple #5
0
 partial void InsertUser(User instance);