Exemplo n.º 1
0
        private void addCSR(String fName, String lName, String username, String password, String dob, String salary, String sex)
        {
            User.CSR csr = new User.CSR();
            csr.firstName = fName;
            csr.lastName  = lName;
            csr.username  = username;
            csr.password  = password;
            csr.dob       = dob;
            csr.salary    = salary;
            csr.sex       = sex;

            bool success = csr.AddNewCSR(csr, this);

            if (success == true)
            {
                CustomMessageBox cm = new CustomMessageBox("Successfully Added CSR", this);
                cm.Show();
                ClearField();
            }
            //else
            //{
            //    CustomMessageBox cm = new CustomMessageBox("Failed to add new doctor", this);
            //    cm.Show();
            //}
        }
Exemplo n.º 2
0
        public bool EditCSR(CSR csr, int csrId, Form form)
        {
            bool isSuccess = false;

            SqlConnection conn = new SqlConnection(myconnstring);

            try
            {
                string query = "Update CSR Set fname = @firstName, lname = @lastName, dob = @dob, salary = @salary, username = @username, password = @password, sex = @sex WHERE csr_id = @csrId";

                SqlCommand cmd = new SqlCommand(query, conn);

                cmd.Parameters.AddWithValue("@firstName", csr.firstName);
                cmd.Parameters.AddWithValue("@lastName", csr.lastName);
                cmd.Parameters.AddWithValue("@dob", csr.dob);
                cmd.Parameters.AddWithValue("@salary", csr.salary);
                cmd.Parameters.AddWithValue("@username", csr.username);
                cmd.Parameters.AddWithValue("@password", csr.password);
                cmd.Parameters.AddWithValue("@sex", csr.sex);
                cmd.Parameters.AddWithValue("@csrId", csrId);


                conn.Open();
                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                //CustomMessageBox cm = new CustomMessageBox("Failed to add patient", form);
                //cm.Show();
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
Exemplo n.º 3
0
        public bool AddNewCSR(CSR csr, Form form)
        {
            bool isSuccess = false;

            SqlConnection conn = new SqlConnection(myconnstring);

            try
            {
                string query = "INSERT INTO CSR (csr_id, fname, lname, username, password, dob, salary, sex) VALUES (NEXT VALUE FOR csr_pk_seq ,@firstName, @lastName, @username, @password, @dob, @salary, @sex)";

                SqlCommand cmd = new SqlCommand(query, conn);

                cmd.Parameters.AddWithValue("@firstName", csr.firstName);
                cmd.Parameters.AddWithValue("@lastName", csr.lastName);
                cmd.Parameters.AddWithValue("@username", csr.username);
                cmd.Parameters.AddWithValue("@password", csr.password);
                cmd.Parameters.AddWithValue("@dob", csr.dob);
                cmd.Parameters.AddWithValue("@salary", csr.salary);
                cmd.Parameters.AddWithValue("@sex", csr.sex);

                conn.Open();
                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                CustomMessageBox cm = new CustomMessageBox("Failed to add CSR to database", form);
                cm.Show();
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }