예제 #1
0
        private void cmnu_DeactiveUser_Click(object sender, EventArgs e)
        {
            int    index    = gridView1.FocusedRowHandle;
            string userName = gridView1.GetRowCellValue(index, "userName").ToString();

            string resultStr = RunCmd.deactiveUser(userName);

            MessageBox.Show(resultStr, "Thông báo");
        }
예제 #2
0
        private void btnDeactiveUser_ItemClick(object sender, ItemClickEventArgs e)
        {
            string name = "";
            string result = "";
            int    min, max;

            if (!barEditItemUserMin.EditValue.ToString().Equals("") && !barEditItemUserMax.EditValue.ToString().Equals(""))
            {
                if (!Regex.IsMatch(barEditItemUserMin.EditValue.ToString(), @"^\d+$") || !Regex.IsMatch(barEditItemUserMax.EditValue.ToString(), @"^\d+$"))
                {
                    MessageBox.Show("Bạn đã nhập sai định dạng min, max.\n\rChỉ được nhập số tự nhiên", "Thông báo");
                    return;
                }
                min = Int32.Parse(barEditItemUserMin.EditValue.ToString());
                max = Int32.Parse(barEditItemUserMax.EditValue.ToString());
            }
            else
            {
                min = 0;
                max = 0;
            }

            if (min == 0 && max == 0)
            {
                try
                {
                    name   = barEditItemUsername.EditValue.ToString();
                    result = RunCmd.deactiveUser(name);
                }
                catch
                {
                    MessageBox.Show("Vui lòng nhập tên User muốn xóa!!", "Thông báo");
                    return;
                }
            }
            else
            {
                for (int i = min; i <= max; i++)
                {
                    try
                    {
                        name    = barEditItemUsername.EditValue.ToString();
                        result += RunCmd.deactiveUser(name + i);
                    }
                    catch (Exception)
                    {
                        result += RunCmd.deactiveUser(i.ToString());
                    }
                }
            }

            MessageBox.Show(result);
        }
예제 #3
0
        private void cmnu_DeactiveUser_Click(object sender, EventArgs e)
        {
            int    index    = gridView1.FocusedRowHandle;
            string userName = gridView1.GetRowCellValue(index, "userName").ToString();

            if (RunCmd.deactiveUser(userName))
            {
                ShowNotification("Thành công", false);
            }
            else
            {
                ShowNotification("Thất bại", true);
            }
        }
예제 #4
0
        private void btnDeactiveUser_ItemClick(object sender, ItemClickEventArgs e)
        {
            string name = "";
            int    min, max, numError = 0;

            if (!barEditItemUserMin.EditValue.ToString().Equals("") || !barEditItemUserMax.EditValue.ToString().Equals(""))
            {
                if (!Regex.IsMatch(barEditItemUserMin.EditValue.ToString(), @"^\d+$") || !Regex.IsMatch(barEditItemUserMax.EditValue.ToString(), @"^\d+$"))
                {
                    ShowNotification("Bạn đã nhập sai định dạng min, max. Chỉ được nhập số tự nhiên", true);
                    return;
                }
                min = Int32.Parse(barEditItemUserMin.EditValue.ToString());
                max = Int32.Parse(barEditItemUserMax.EditValue.ToString());
            }
            else
            {
                min = 0;
                max = 0;
            }

            if (min == 0 && max == 0)
            {
                try
                {
                    name = barEditItemUsername.EditValue.ToString();
                    if (RunCmd.deactiveUser(name) == true)
                    {
                        ShowNotification("Thành công", false);
                    }
                    else
                    {
                        ShowNotification("Thất bại", true);
                    }
                }
                catch
                {
                    ShowNotification("Vui lòng nhập tên User muốn hủy kích hoạt", true);
                    return;
                }
            }
            else
            {
                for (int i = min; i <= max; i++)
                {
                    try
                    {
                        name = barEditItemUsername.EditValue.ToString();
                        if (RunCmd.deactiveUser(name + i) == false)
                        {
                            numError++;
                        }
                    }
                    catch (Exception)
                    {
                        ShowNotification("Vui lòng nhập tên User muốn hủy kích hoạt", true);
                        break;
                    }
                    if (i >= max)
                    {
                        if (numError != 0)
                        {
                            ShowNotification("Thất bại " + numError + " User", true);
                        }
                        else
                        {
                            ShowNotification("Thành công", false);
                        }
                    }
                }
            }
        }