示例#1
0
        private void btnNhanVien_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Form frm = this.CheckExists(typeof(FormNhanVien));

            if (frm != null)
            {
                frm.Activate();
            }
            else
            {
                FormNhanVien f = new FormNhanVien();
                f.MdiParent = this;
                f.Show();
            }
        }
示例#2
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            int    newMANV = FormNhanVien.newMANV();
            string query   = "DECLARE	@result int "+
                             "EXEC @result = SP_NewChuyenCN @p1, @p2 " +
                             "SELECT 'result' = @result";
            SqlCommand sqlCommand = new SqlCommand(query, Program.connection);

            sqlCommand.Parameters.AddWithValue("@p1", Program.maNVChuyenCN);
            sqlCommand.Parameters.AddWithValue("@p2", newMANV);
            SqlDataReader dataReader = null;

            try
            {
                dataReader = sqlCommand.ExecuteReader();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi khi thực thi Database!\n" + ex.Message, "Notification",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                dataReader.Close();
                return;
            }
            dataReader.Read();
            int result = int.Parse(dataReader.GetValue(0).ToString());

            dataReader.Close();
            if (result == -1)       //Trường hợp thất bại
            {
                MessageBox.Show("Chuyển Chi nhánh thất bại! Dữ liệu đã được Roolback!", "Notification",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                dataReader.Close();
            }
            else if (result == 0)   //Trường hợp thành công khi bên Chi nhánh kia nhân viên chưa từng chuyển chi nhánh
            {
                MessageBox.Show("Chuyển chi nhánh thành công. Với Mã Nhân Viên mới là: " + newMANV, "Notification",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                xoaLogin();         //Đồng thời xóa Login(nếu có)
                this.Close();
            }
        }