Exemple #1
0
        private void btnAddU_Click(object sender, EventArgs e)
        {
            CUsers u = new CUsers(txtIdU.Text, txtNameU.Text, txtAddressU.Text, txtPhoneU.Text, int.Parse(txtCodeKinderU.Text), int.Parse(txtPremissionU.Text), txtMail.Text);

            BUserManager.addUser(u);
            txtIdU.Text         = "";
            txtNameU.Text       = "";
            txtAddressU.Text    = "";
            txtPhoneU.Text      = "";
            txtCodeKinderU.Text = "";
            txtPremissionU.Text = "";
            txtMail.Text        = "";
        }
Exemple #2
0
        public int addUser([FromBody] CUsers user)
        {
            try
            {
                BUserManager.addUser(user);
                return(1);
            }
            catch (Exception e)
            {
                if (e.InnerException.InnerException.Message.Equals("Violation of PRIMARY KEY constraint 'PK__Users__B7C9263840CFC3C0'. Cannot insert duplicate key in object 'dbo.Users'. The duplicate key value is (319100160).\r\nThe statement has been terminated."))
                {
                    allreadyExist ex = new allreadyExist();
                    throw ex;
                }

                throw e;
            }
        }