コード例 #1
0
        private void btnCreateLogin_Click(object sender, EventArgs e)
        {
            if (int.Parse(txtEmpDelStatus.Text) == 1)
            {
                XtraMessageBox.Show(Cons.ErrorSwitchEmployeeAlready, Cons.CaptionError,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int employeeId = int.Parse(txtEmpId.EditValue.ToString());

            using (SqlConnection connection = new SqlConnection(UtilDB.ConnectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand(MyConfig.SpKiemTraNVCoTaiKhoan, connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@manv", employeeId);
                    try
                    {
                        command.ExecuteNonQuery();
                        FlyoutAction flyoutAction = new FlyoutAction()
                        {
                            Caption = Cons.CaptionCreateLogin,
                        };
                        CustomFlyoutDialog.ShowForm(this, flyoutAction, new frmRegister(employeeId));
                    }
                    catch (Exception ex)
                    {
                        if (ex is SqlException exAsSqlEx && exAsSqlEx.Number == MyConfig.ErrorMsgNumEmployeeHaveLogin)
                        {
                            XtraMessageBox.Show(exAsSqlEx.Message, Cons.CaptionError,
                                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
コード例 #2
0
ファイル: frmMain.cs プロジェクト: MinhTran03/QLVT_DATHANG
 private void btnRegister_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (!UtilDB.CurrentGroup.Equals(MyConfig.UserGroupName))
     {
         FlyoutAction flyoutAction = new FlyoutAction()
         {
             Caption = Cons.CaptionCreateLogin,
         };
         CustomFlyoutDialog.ShowForm(this, flyoutAction, new frmRegister());
     }
     else
     {
         XtraMessageBox.Show(Cons.WarningUserCreateTK, Cons.CaptionWarning,
                             MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }