Exemple #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (CheckValidity())
     {
         Save?.Invoke(EditEntity, Original);
         UpdateList?.Invoke();
         if (EditStatus == EditStatus.Alter)
         {
             this.Close();
         }
     }
 }
Exemple #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (CheckValidity())
            {
                EditEntity.Account       = null;
                EditEntity.InOutCategory = null;
                EditEntity.Project       = null;
                EditEntity.Unit          = null;

                Save?.Invoke(EditEntity, Original);
                UpdateList?.Invoke();
                if (EditStatus == EditStatus.Alter)
                {
                    this.Close();
                }
            }
        }
Exemple #3
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     UpdateList?.Invoke();
     this.Close();
 }
Exemple #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (CheckValidity())
            {
                #region generate sroles by checked item
                string[] roles = new string[clbRoles.CheckedItems.Count];
                int      i     = 0;
                foreach (var item in clbRoles.CheckedItems)
                {
                    roles[i] = item.ToString(); i++;
                }
                List <Role> sroles = null;
                if (roles.Length > 0)
                {
                    sroles = new List <Role>();
                    foreach (var role in roles)
                    {
                        var srole = repo.GetAll <sysContext, Role>().First(r => r.Name == role);
                        if (srole != null)
                        {
                            sroles.Add(srole);
                        }
                    }
                }
                #endregion

                #region to assemble a user instance from editdialog interaction
                //var user = LoadByRight.Register(EditEntity.Name, EditEntity.Account, EditEntity.Password, sroles);
                //EditEntity.SRoles = user.SRoles;
                EditEntity.Salt = withSecure.GenerateSalt();
                EditEntity.SaltedHashedPassword = withSecure.GenerateSaltedHashedPassword(EditEntity.Salt, txtPassword.Text.Trim());
                EditEntity.Partners             = sroles;
                #endregion
                //int result = 0;
                //if (EditStatus == EditStatus.Add)
                //{
                //    //result = Repo<sysContext>.AddUserWithRole(EditEntity);
                //    result = Repo<sysContext>.m2mAdd<User, Role>(EditEntity);
                //    if (result > 0)
                //    {
                //        var logger = new sqlLogger();
                //        logger.Write(new ting.model.syst.Log()
                //        {
                //            UserAcount = null,
                //            Action = "Add",
                //            Date = DateTime.Now,
                //            Entity = EditEntity.GetType().FullName,
                //            Content = EditEntity.DisplayValue,
                //            Original = null,
                //        });
                //    }
                //}
                //else if (EditStatus == EditStatus.Alter)
                //{
                //    //result = Repo<sysContext>.AlterUserWithRole(EditEntity);
                //    result = Repo<sysContext>.M2MAlter<User, Role>(EditEntity);
                //    if (result > 0)
                //    {
                //        var logger = new sqlLogger();
                //        logger.Write(new ting.model.syst.Log()
                //        {
                //            UserAcount = null,
                //            Action = "Add",
                //            Date = DateTime.Now,
                //            Entity = EditEntity.GetType().FullName,
                //            Content = EditEntity.DisplayValue,
                //            Original = Original.DisplayValue,
                //        });
                //    }

                //}

                Save?.Invoke(EditEntity, Original);
                UpdateList?.Invoke();
                if (EditStatus == EditStatus.Alter)
                {
                    this.Close();
                }
            }
        }