Exemplo n.º 1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (this.Page.IsValid && this.ViewState["UserID"] != null)
        {
            byte selectedRoleId = byte.Parse(this.drpRoles.SelectedValue);
            ListItem item = null;
            db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
            Ajancy.User user = db.Users.First<Ajancy.User>(u => u.UserID == Public.ToInt(this.ViewState["UserID"]));
            Ajancy.UsersInRole userRole = new Ajancy.UsersInRole { RoleID = selectedRoleId, MembershipDate = DateTime.Now }; ;
            user.UsersInRoles.Add(userRole);

            switch ((Public.Role)selectedRoleId)
            {
                case Public.Role.AjancyManager:
                case Public.Role.AjancySupervisor:
                case Public.Role.AjancySecretary:
                case Public.Role.AjancyPartner:
                    Ajancy.AjancyPartner partner = new Ajancy.AjancyPartner { SubmitDate = DateTime.Now };
                    userRole.AjancyPartners.Add(partner);
                    db.SubmitChanges();
                    item = new ListItem(string.Format("{0} {1}", Public.GetRoleName(userRole.RoleID), "---"), string.Format("{0}|{1}", userRole.UserRoleID, partner.AjancyPartnerID));
                    break;

                case Public.Role.ProvinceManager:
                case Public.Role.AcademyProvince:
                    db.SubmitChanges();
                    item = new ListItem(string.Format("{0} {1}", Public.GetRoleName(selectedRoleId), user.City.Province.Name), string.Format("{0}|0", userRole.UserRoleID));
                    break;

                case Public.Role.CityManager:
                case Public.Role.AcademyCity:
                    db.SubmitChanges();
                    item = new ListItem(string.Format("{0} {1}", Public.GetRoleName(selectedRoleId), user.City.Name), string.Format("{0}|0", userRole.UserRoleID));
                    break;

                default:
                    db.SubmitChanges();
                    item = new ListItem(Public.GetRoleName(selectedRoleId), string.Format("{0}|0", userRole.UserRoleID));
                    break;
            }

            item.Selected = true;
            this.lstRoles.Items.Add(item);
            this.drpRoles.Items.Remove(this.drpRoles.SelectedItem);
            this.lblMessage.Text = "ثبت سمت انجام گردید";
        }
    }
Exemplo n.º 2
0
 partial void DeleteAjancyPartner(AjancyPartner instance);
Exemplo n.º 3
0
 partial void UpdateAjancyPartner(AjancyPartner instance);
Exemplo n.º 4
0
 partial void InsertAjancyPartner(AjancyPartner instance);
Exemplo n.º 5
0
		private void detach_AjancyPartners(AjancyPartner entity)
		{
			this.SendPropertyChanging();
			entity.Ajancy = null;
		}
Exemplo n.º 6
0
		private void attach_AjancyPartners(AjancyPartner entity)
		{
			this.SendPropertyChanging();
			entity.Ajancy = this;
		}