Ejemplo n.º 1
0
        //Adds an Image to Image <rDoc>  for editing and storage (Stores in memory compared to old 'void addimage' disk method.
//        void addimage2(string filename)
//        {
//
//            tempdi = Globals.tempdi;
//            fs = File.Open(filename, FileMode.Open, FileAccess.ReadWrite);
//            srcBmp = (Bitmap)Bitmap.FromStream(fs);
//            totalPages = Convert.ToInt32(srcBmp.GetFrameCount(FrameDimension.Page) - 1);
//            int i;
//            for (i = 0; i <= totalPages; i++)
//            {
//                srcBmp.SelectActiveFrame(FrameDimension.Page, i);
//
//                //resized = new Bitmap(srcBmp, srcBmp.Width, srcBmp.Height);
//                double resizefactor = 2.3;
//                resized = new Bitmap(srcBmp, Convert.ToInt32(srcBmp.Width / resizefactor), Convert.ToInt32(srcBmp.Height / resizefactor));
//                // if (srcBmp.Width > 1200)
//                // {
//                //     resized = ResizeImage(resized, new Size(Convert.ToInt32(srcBmp.Width / 2.8), Convert.ToInt32(srcBmp.Height / 3.2)), true);
//                // }
//                int num = tempdi.GetFiles().Count();
//                RedactDoc rDoc = new RedactDoc();
//                rDoc.PageNum = string.Format("Page {0}", num + 1);
//                resized.Save(Application.StartupPath + "\\temp\\temp" + num + ".png", System.Drawing.Imaging.ImageFormat.Png);
//
//                rDoc.PageNum = string.Format("Page {0}", num +1);
//                ms = new MemoryStream();
//                resized.Save(ms, ImageFormat.Jpeg);
//                rDoc.ImageStream = ms;
//                rDoc.FileName = Application.StartupPath + "\\temp\\temp" + num + ".png";
//                imgLst.Add(rDoc);
//                ms = null;
//                srcBmp.Dispose();
//              srcBmp = null;
//
//                resized.Dispose();
//            }
//            fs.Dispose();
//            ProgressBar1.PerformStep();
//
//            fs = null;
//        }

        void addimage(string filename)
        {
            fs         = File.Open(filename, FileMode.Open, FileAccess.ReadWrite);
            srcBmp     = (Bitmap)Bitmap.FromStream(fs);
            totalPages = Convert.ToInt32(srcBmp.GetFrameCount(FrameDimension.Page) - 1);
            int i;

            for (i = 0; i <= totalPages; i++)
            {
                srcBmp.SelectActiveFrame(FrameDimension.Page, i);

                //resized = new Bitmap(srcBmp, srcBmp.Width, srcBmp.Height);
                double resizefactor = 2.6;
                resized = new Bitmap(srcBmp, Convert.ToInt32(srcBmp.Width / resizefactor), Convert.ToInt32(srcBmp.Height / resizefactor));
                // if (srcBmp.Width > 1200)
                // {
                //     resized = ResizeImage(resized, new Size(Convert.ToInt32(srcBmp.Width / 2.8), Convert.ToInt32(srcBmp.Height / 3.2)), true);
                // }
                //int num = Globals.tempdi.GetFiles().Count();
                int num = _Doc.Pages.Count();
                resized.Save(Application.StartupPath + "\\temp\\temp" + num + ".png", System.Drawing.Imaging.ImageFormat.Png);
                ms = new MemoryStream();
                resized.Save(ms, ImageFormat.Png);
                _Doc.Pages.Add(new Page(num + 1, ms, Application.StartupPath + "\\temp\\temp" + (num - 1) + ".png"));
                ms = null;
                srcBmp.Dispose();
                srcBmp = null;

                resized.Dispose();
            }
            fs.Dispose();
            ProgressBar1.PerformStep();

            fs = null;
        }
Ejemplo n.º 2
0
 private void timer2_Tick(object sender, EventArgs e)
 {
     ProgressBar1.PerformStep();
     if (tt == true)
     {
         ProgressBar1.Value = ProgressBar1.Maximum;
         timer2.Enabled     = false;
     }
 }
 public void performStep()
 {
     ProgressBar1.PerformStep();
     Label1.Text = ((ProgressBar1.Value / ProgressBar1.Maximum) * 100).ToString() + "% complete";
     this.Refresh();
     Application.DoEvents();
     if (ProgressBar1.Value == ProgressBar1.Maximum)
     {
         this.Close();
     }
 }
Ejemplo n.º 4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (cmbUsertype.Text == "")
            {
                MessageBox.Show("Please select user type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cmbUsertype.Focus();
                return;
            }
            if (UserID.Text == "")
            {
                MessageBox.Show("Please enter user ID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                UserID.Focus();
                return;
            }
            if (Password.Text == "")
            {
                MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Password.Focus();
                return;
            }
            try
            {
                con = new SqlConnection(cs.DBcon);
                con.Open();
                cmd             = con.CreateCommand();
                cmd.CommandText = "SELECT RTRIM(UserID),RTRIM(Password) FROM User_Registration where UserID = @d1 and Password=@d2";
                cmd.Parameters.AddWithValue("@d1", UserID.Text);
                cmd.Parameters.AddWithValue("@d2", Password.Text);
                rdr = cmd.ExecuteReader();
                if (rdr.Read())
                {
                    con = new SqlConnection(cs.DBcon);
                    con.Open();
                    cmd             = con.CreateCommand();
                    cmd.CommandText = "SELECT usertype FROM User_Registration where UserID=@d3 and Password=@d4";
                    cmd.Parameters.AddWithValue("@d3", UserID.Text);
                    cmd.Parameters.AddWithValue("@d4", Password.Text);
                    rdr = cmd.ExecuteReader();
                    if (rdr.Read())
                    {
                        cmbUsertype.Text = rdr.GetValue(0).ToString().Trim();
                    }
                    if ((rdr != null))
                    {
                        rdr.Close();
                    }
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }


                    if (cmbUsertype.Text == "Librarian")
                    {
                        this.Hide();
                        Librarian_Window frm = new Librarian_Window();
                        frm.User.Text     = UserID.Text;
                        frm.UserType.Text = cmbUsertype.Text;
                        frm.Show();

                        ProgressBar1.Visible = true;
                        ProgressBar1.Maximum = 5000;
                        ProgressBar1.Minimum = 0;
                        ProgressBar1.Value   = 4;
                        ProgressBar1.Step    = 1;
                        for (int i = 0; i <= 5000; i++)
                        {
                            ProgressBar1.PerformStep();
                        }
                    }
                    if (cmbUsertype.Text == "Account Officer")
                    {
                        this.Hide();
                        Account_Officer_Window frm = new Account_Officer_Window();
                        frm.User.Text     = UserID.Text;
                        frm.UserType.Text = cmbUsertype.Text;
                        frm.Show();

                        ProgressBar1.Visible = true;
                        ProgressBar1.Maximum = 5000;
                        ProgressBar1.Minimum = 0;
                        ProgressBar1.Value   = 4;
                        ProgressBar1.Step    = 1;
                        for (int i = 0; i <= 5000; i++)
                        {
                            ProgressBar1.PerformStep();
                        }

                        /*st1 = UserID.Text;
                         * st2 = "Successfully logged in";
                         * cf.LogFunc(st1, System.DateTime.Now, st2);
                         * this.Hide();
                         * frm.Show();*/
                    }


                    if (cmbUsertype.Text == "Admin")
                    {
                        this.Hide();
                        frm_Main_Menu frm = new frm_Main_Menu();
                        //frm.User.Text = txtUserName.Text;
                        frm.User.Text     = UserID.Text;
                        frm.UserType.Text = cmbUsertype.Text;
                        frm.Show();
                        // frm.registrationToolStripMenuItem2.Enabled = true;
                        frm.studentDetailsToolStripMenuItem.Enabled = true;

                        frm.hostelersToolStripMenuItem.Enabled  = true;
                        frm.busHoldersToolStripMenuItem.Enabled = true;


                        frm.Master_entryMenu.Enabled             = true;
                        frm.usersToolStripMenuItem.Enabled       = true;
                        frm.studentToolStripMenuItem.Enabled     = true;
                        frm.employeeToolStripMenuItem.Enabled    = true;
                        frm.transactionToolStripMenuItem.Enabled = true;
                        frm.searchToolStripMenuItem.Enabled      = true;
                        frm.reportToolStripMenuItem.Enabled      = true;


                        frm.busFeePaymentToolStripMenuItem2.Enabled     = true;
                        frm.feePaymentToolStripMenuItem.Enabled         = true;
                        frm.employeeSalaryToolStripMenuItem.Enabled     = true;
                        frm.hostelFeesPaymentToolStripMenuItem.Enabled  = true;
                        frm.scholarshipPaymentToolStripMenuItem.Enabled = true;
                        ProgressBar1.Visible = true;
                        ProgressBar1.Maximum = 5000;
                        ProgressBar1.Minimum = 0;
                        ProgressBar1.Value   = 4;
                        ProgressBar1.Step    = 1;
                        for (int i = 0; i <= 5000; i++)
                        {
                            ProgressBar1.PerformStep();
                        }
                        st1 = UserID.Text;
                        st2 = "Successfully logged in";
                        cf.LogFunc(st1, System.DateTime.Now, st2);
                        this.Hide();
                        frm.Show();
                    }
                }
                else
                {
                    MessageBox.Show("Login Failed...Try again !", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    UserID.Clear();
                    Password.Clear();
                    UserID.Focus();
                }
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("Please enter Username...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox1.Focus();
                return;
            }
            if (textBox2.Text == "")
            {
                MessageBox.Show("Please enter Password...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox2.Focus();
                return;
            }

            try
            {
                SqlConnection myConnection = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename='D:\MCS\SEM - II\CS - 204 Project\MD Bricks Supplier\MD Brief Supplier\dBMaheshBricksSupplier.mdf';Integrated Security=True;Connect Timeout=30");
                // myConnection = new SqlConnection(cs.DBConn);


                SqlCommand myCommand = default(SqlCommand);

                myCommand = new SqlCommand("SELECT username FROM tblRoasterOwner WHERE username = @username AND password = @password ", myConnection);

                SqlParameter username = new SqlParameter("@username", SqlDbType.VarChar);

                SqlParameter password = new SqlParameter("@password", SqlDbType.VarChar);

                username.Value = textBox1.Text;
                password.Value = textBox2.Text;

                myCommand.Parameters.Add(username);
                myCommand.Parameters.Add(password);

                myCommand.Connection.Open();

                SqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

                if (myReader.Read() == true)
                {
                    int i;
                    ProgressBar1.Visible = true;
                    ProgressBar1.Maximum = 5000;
                    ProgressBar1.Minimum = 0;
                    ProgressBar1.Value   = 4;
                    ProgressBar1.Step    = 1;

                    for (i = 0; i <= 5000; i++)
                    {
                        ProgressBar1.PerformStep();
                    }

                    this.Hide();
                    mdi.Show();
                }
                else
                {
                    MessageBox.Show("Login Failed...Try again !", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    reset();
                    textBox1.Focus();
                }
                if (myConnection.State == ConnectionState.Open)
                {
                    myConnection.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 6
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (cmbUsertype.Text == "")
            {
                MessageBox.Show("Please select user type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cmbUsertype.Focus();
                return;
            }
            if (txtUserName.Text == "")
            {
                MessageBox.Show("Please enter user name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUserName.Focus();
                return;
            }
            if (txtPassword.Text == "")
            {
                MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Focus();
                return;
            }
            try
            {
                SqlConnection myConnection = default(SqlConnection);
                myConnection = new SqlConnection(cs);

                SqlCommand myCommand = default(SqlCommand);

                myCommand = new SqlCommand("SELECT UserType,Username,password FROM Users WHERE UserType = @usertype AND Username = @username AND password = @UserPassword", myConnection);
                SqlParameter uType = new SqlParameter("@usertype", SqlDbType.NChar);

                SqlParameter uName = new SqlParameter("@username", SqlDbType.NChar);

                SqlParameter uPassword = new SqlParameter("@UserPassword", SqlDbType.NChar);

                uType.Value     = cmbUsertype.Text;
                uName.Value     = txtUserName.Text;
                uPassword.Value = txtPassword.Text;

                myCommand.Parameters.Add(uType);
                myCommand.Parameters.Add(uName);
                myCommand.Parameters.Add(uPassword);

                myCommand.Connection.Open();

                SqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

                if (myReader.Read() == true)
                {
                    int i;
                    ProgressBar1.Visible = true;
                    ProgressBar1.Maximum = 5000;
                    ProgressBar1.Minimum = 0;
                    ProgressBar1.Value   = 4;
                    ProgressBar1.Step    = 1;

                    for (i = 0; i <= 5000; i++)
                    {
                        ProgressBar1.PerformStep();
                    }
                    if (cmbUsertype.Text == "Lecturer")
                    {
                        this.Hide();
                        frmMainMenu frm = new frmMainMenu();
                        frm.User.Text     = txtUserName.Text;
                        frm.UserType.Text = cmbUsertype.Text;
                        frm.Show();
                        frm.registrationToolStripMenuItem2.Enabled      = false;
                        frm.studentDetailsToolStripMenuItem.Enabled     = false;
                        frm.internalMarksEntryToolStripMenuItem.Enabled = false;
                        frm.hostelersToolStripMenuItem.Enabled          = false;
                        frm.busHoldersToolStripMenuItem.Enabled         = false;
                        frm.attendanceToolStripMenuItem.Enabled         = false;
                        frm.registrationFormToolStripMenuItem.Enabled   = false;
                        frm.databaseToolStripMenuItem.Enabled           = false;
                        frm.Master_entryMenu.Enabled                     = false;
                        frm.usersToolStripMenuItem.Enabled               = false;
                        frm.studentToolStripMenuItem.Enabled             = false;
                        frm.employeeToolStripMenuItem.Enabled            = false;
                        frm.transactionToolStripMenuItem.Enabled         = false;
                        frm.searchToolStripMenuItem.Enabled              = false;
                        frm.reportToolStripMenuItem.Enabled              = false;
                        frm.userRegistrationToolStripMenuItem.Enabled    = false;
                        frm.studentToolStripMenuItem1.Enabled            = false;
                        frm.attendanceToolStripMenuItem1.Enabled         = true;
                        frm.internalMarksEntryToolStripMenuItem1.Enabled = true;
                        frm.employeeToolStripMenuItem1.Enabled           = false;
                        frm.salaryPaymentToolStripMenuItem.Enabled       = false;
                        frm.feePaymentToolStripMenuItem1.Enabled         = false;
                        frm.busFeePaymentToolStripMenuItem2.Enabled      = false;
                        frm.feePaymentToolStripMenuItem.Enabled          = false;
                        frm.employeeSalaryToolStripMenuItem.Enabled      = false;
                        frm.hostelFeesPaymentToolStripMenuItem.Enabled   = false;
                        frm.scholarshipPaymentToolStripMenuItem.Enabled  = false;
                        frm.othersTransactionToolStripMenuItem.Enabled   = false;
                    }

                    if (cmbUsertype.Text == "Admin")
                    {
                        this.Hide();
                        frmMainMenu frm = new frmMainMenu();
                        frm.User.Text     = txtUserName.Text;
                        frm.UserType.Text = cmbUsertype.Text;
                        frm.Show();
                        frm.registrationToolStripMenuItem2.Enabled      = true;
                        frm.studentDetailsToolStripMenuItem.Enabled     = true;
                        frm.internalMarksEntryToolStripMenuItem.Enabled = true;
                        frm.hostelersToolStripMenuItem.Enabled          = true;
                        frm.busHoldersToolStripMenuItem.Enabled         = true;
                        frm.attendanceToolStripMenuItem.Enabled         = true;
                        frm.registrationFormToolStripMenuItem.Enabled   = true;
                        frm.Master_entryMenu.Enabled                           = true;
                        frm.usersToolStripMenuItem.Enabled                     = true;
                        frm.studentToolStripMenuItem.Enabled                   = true;
                        frm.employeeToolStripMenuItem.Enabled                  = true;
                        frm.transactionToolStripMenuItem.Enabled               = true;
                        frm.searchToolStripMenuItem.Enabled                    = true;
                        frm.reportToolStripMenuItem.Enabled                    = true;
                        frm.userRegistrationToolStripMenuItem.Enabled          = true;
                        frm.studentToolStripMenuItem1.Enabled                  = true;
                        frm.attendanceToolStripMenuItem1.Enabled               = true;
                        frm.databaseToolStripMenuItem.Enabled                  = true;
                        frm.internalMarksEntryToolStripMenuItem1.Enabled       = true;
                        frm.employeeToolStripMenuItem1.Enabled                 = true;
                        frm.salaryPaymentToolStripMenuItem.Enabled             = true;
                        frm.feePaymentToolStripMenuItem1.Enabled               = true;
                        frm.busFeePaymentToolStripMenuItem2.Enabled            = true;
                        frm.feePaymentToolStripMenuItem.Enabled                = true;
                        frm.employeeSalaryToolStripMenuItem.Enabled            = true;
                        frm.hostelFeesPaymentToolStripMenuItem.Enabled         = true;
                        frm.scholarshipPaymentToolStripMenuItem.Enabled        = true;
                        frm.othersTransactionToolStripMenuItem.Enabled         = true;
                        frm.studentsRegistrationToolStripMenuItem.Enabled      = true;
                        frm.studentsToolStripMenuItem.Enabled                  = true;
                        frm.hostlersToolStripMenuItem.Enabled                  = true;
                        frm.busHoldersToolStripMenuItem2.Enabled               = true;
                        frm.studentProfileToolStripMenuItem.Enabled            = true;
                        frm.attendanceToolStripMenuItem2.Enabled               = true;
                        frm.feesDetailsToolStripMenuItem1.Enabled              = true;
                        frm.internalMarksToolStripMenuItem.Enabled             = true;
                        frm.employeeToolStripMenuItem2.Enabled                 = true;
                        frm.salaryPaymentToolStripMenuItem1.Enabled            = true;
                        frm.salarySlipToolStripMenuItem.Enabled                = true;
                        frm.feePaymentToolStripMenuItem2.Enabled               = true;
                        frm.feeReceiptToolStripMenuItem.Enabled                = true;
                        frm.scholarshipPaymentToolStripMenuItem1.Enabled       = true;
                        frm.hostelFeePaymentToolStripMenuItem.Enabled          = true;
                        frm.othersTransactionToolStripMenuItem1.Enabled        = true;
                        frm.busFeePaymentToolStripMenuItem.Enabled             = true;
                        frm.scholarshipPaymentReceiptToolStripMenuItem.Enabled = true;
                        frm.busFeePaymentReceiptToolStripMenuItem.Enabled      = true;
                        frm.hostelFeePaymentReceiptToolStripMenuItem.Enabled   = true;
                        frm.registrationToolStripMenuItem1.Enabled             = true;
                        frm.transportationChargesToolStripMenuItem.Enabled     = true;
                        frm.subjectInfoToolStripMenuItem1.Enabled              = true;
                        frm.EventtoolStripMenuItem1.Enabled                    = true;
                    }

                    if (cmbUsertype.Text == "Admissions Officer")
                    {
                        this.Hide();
                        frmMainMenu frm = new frmMainMenu();
                        frm.User.Text     = txtUserName.Text;
                        frm.UserType.Text = cmbUsertype.Text;
                        frm.Show();
                        frm.registrationToolStripMenuItem2.Enabled      = true;
                        frm.studentDetailsToolStripMenuItem.Enabled     = true;
                        frm.internalMarksEntryToolStripMenuItem.Enabled = false;
                        frm.hostelersToolStripMenuItem.Enabled          = false;
                        frm.busHoldersToolStripMenuItem.Enabled         = false;
                        frm.attendanceToolStripMenuItem.Enabled         = false;
                        frm.registrationFormToolStripMenuItem.Enabled   = true;
                        frm.Master_entryMenu.Enabled                     = false;
                        frm.usersToolStripMenuItem.Enabled               = false;
                        frm.databaseToolStripMenuItem.Enabled            = false;
                        frm.studentToolStripMenuItem.Enabled             = true;
                        frm.employeeToolStripMenuItem.Enabled            = false;
                        frm.transactionToolStripMenuItem.Enabled         = false;
                        frm.searchToolStripMenuItem.Enabled              = false;
                        frm.reportToolStripMenuItem.Enabled              = false;
                        frm.userRegistrationToolStripMenuItem.Enabled    = false;
                        frm.studentToolStripMenuItem1.Enabled            = true;
                        frm.attendanceToolStripMenuItem1.Enabled         = false;
                        frm.internalMarksEntryToolStripMenuItem1.Enabled = false;
                        frm.employeeToolStripMenuItem1.Enabled           = false;
                        frm.salaryPaymentToolStripMenuItem.Enabled       = false;
                        frm.feePaymentToolStripMenuItem1.Enabled         = false;
                        frm.busFeePaymentToolStripMenuItem2.Enabled      = false;
                        frm.feePaymentToolStripMenuItem.Enabled          = false;
                        frm.employeeSalaryToolStripMenuItem.Enabled      = false;
                        frm.hostelFeesPaymentToolStripMenuItem.Enabled   = false;
                        frm.scholarshipPaymentToolStripMenuItem.Enabled  = false;
                        frm.othersTransactionToolStripMenuItem.Enabled   = false;
                    }
                    if (cmbUsertype.Text == "Accounts Officer")
                    {
                        this.Hide();
                        frmMainMenu frm = new frmMainMenu();
                        frm.User.Text     = txtUserName.Text;
                        frm.UserType.Text = cmbUsertype.Text;
                        frm.Show();
                        frm.registrationToolStripMenuItem2.Enabled      = false;
                        frm.studentDetailsToolStripMenuItem.Enabled     = false;
                        frm.internalMarksEntryToolStripMenuItem.Enabled = false;
                        frm.hostelersToolStripMenuItem.Enabled          = false;
                        frm.busHoldersToolStripMenuItem.Enabled         = false;
                        frm.attendanceToolStripMenuItem.Enabled         = false;
                        frm.databaseToolStripMenuItem.Enabled           = false;
                        frm.registrationFormToolStripMenuItem.Enabled   = false;
                        frm.Master_entryMenu.Enabled                     = false;
                        frm.usersToolStripMenuItem.Enabled               = false;
                        frm.studentToolStripMenuItem.Enabled             = false;
                        frm.employeeToolStripMenuItem.Enabled            = false;
                        frm.transactionToolStripMenuItem.Enabled         = true;
                        frm.searchToolStripMenuItem.Enabled              = false;
                        frm.reportToolStripMenuItem.Enabled              = false;
                        frm.userRegistrationToolStripMenuItem.Enabled    = false;
                        frm.studentToolStripMenuItem1.Enabled            = false;
                        frm.attendanceToolStripMenuItem1.Enabled         = false;
                        frm.internalMarksEntryToolStripMenuItem1.Enabled = false;
                        frm.employeeToolStripMenuItem1.Enabled           = false;
                        frm.salaryPaymentToolStripMenuItem.Enabled       = true;
                        frm.feePaymentToolStripMenuItem1.Enabled         = true;
                        frm.busFeePaymentToolStripMenuItem2.Enabled      = true;
                        frm.feePaymentToolStripMenuItem.Enabled          = true;
                        frm.employeeSalaryToolStripMenuItem.Enabled      = true;
                        frm.hostelFeesPaymentToolStripMenuItem.Enabled   = true;
                        frm.scholarshipPaymentToolStripMenuItem.Enabled  = true;
                        frm.othersTransactionToolStripMenuItem.Enabled   = true;
                    }
                    if (cmbUsertype.Text == "Student")
                    {
                        this.Hide();
                        frmMainMenu frm = new frmMainMenu();
                        frm.User.Text     = txtUserName.Text;
                        frm.UserType.Text = cmbUsertype.Text;
                        frm.Show();
                        frm.registrationToolStripMenuItem2.Enabled      = false;
                        frm.studentDetailsToolStripMenuItem.Enabled     = false;
                        frm.internalMarksEntryToolStripMenuItem.Enabled = false;
                        frm.hostelersToolStripMenuItem.Enabled          = false;
                        frm.busHoldersToolStripMenuItem.Enabled         = false;
                        frm.attendanceToolStripMenuItem.Enabled         = false;
                        frm.registrationFormToolStripMenuItem.Enabled   = false;
                        frm.Master_entryMenu.Enabled                           = false;
                        frm.usersToolStripMenuItem.Enabled                     = false;
                        frm.studentToolStripMenuItem.Enabled                   = false;
                        frm.employeeToolStripMenuItem.Enabled                  = false;
                        frm.transactionToolStripMenuItem.Enabled               = false;
                        frm.searchToolStripMenuItem.Enabled                    = false;
                        frm.reportToolStripMenuItem.Enabled                    = true;
                        frm.userRegistrationToolStripMenuItem.Enabled          = false;
                        frm.studentToolStripMenuItem1.Enabled                  = false;
                        frm.attendanceToolStripMenuItem1.Enabled               = false;
                        frm.databaseToolStripMenuItem.Enabled                  = false;
                        frm.internalMarksEntryToolStripMenuItem1.Enabled       = false;
                        frm.employeeToolStripMenuItem1.Enabled                 = false;
                        frm.salaryPaymentToolStripMenuItem.Enabled             = false;
                        frm.feePaymentToolStripMenuItem1.Enabled               = false;
                        frm.busFeePaymentToolStripMenuItem2.Enabled            = false;
                        frm.feePaymentToolStripMenuItem.Enabled                = false;
                        frm.employeeSalaryToolStripMenuItem.Enabled            = false;
                        frm.hostelFeesPaymentToolStripMenuItem.Enabled         = false;
                        frm.scholarshipPaymentToolStripMenuItem.Enabled        = false;
                        frm.othersTransactionToolStripMenuItem.Enabled         = false;
                        frm.studentsRegistrationToolStripMenuItem.Enabled      = false;
                        frm.studentsToolStripMenuItem.Enabled                  = false;
                        frm.hostlersToolStripMenuItem.Enabled                  = false;
                        frm.busHoldersToolStripMenuItem2.Enabled               = false;
                        frm.studentProfileToolStripMenuItem.Enabled            = false;
                        frm.attendanceToolStripMenuItem2.Enabled               = true;
                        frm.feesDetailsToolStripMenuItem1.Enabled              = true;
                        frm.internalMarksToolStripMenuItem.Enabled             = true;
                        frm.employeeToolStripMenuItem2.Enabled                 = false;
                        frm.salaryPaymentToolStripMenuItem1.Enabled            = false;
                        frm.salarySlipToolStripMenuItem.Enabled                = false;
                        frm.feePaymentToolStripMenuItem2.Enabled               = false;
                        frm.feeReceiptToolStripMenuItem.Enabled                = false;
                        frm.scholarshipPaymentToolStripMenuItem1.Enabled       = false;
                        frm.hostelFeePaymentToolStripMenuItem.Enabled          = false;
                        frm.othersTransactionToolStripMenuItem1.Enabled        = false;
                        frm.busFeePaymentToolStripMenuItem.Enabled             = false;
                        frm.scholarshipPaymentReceiptToolStripMenuItem.Enabled = false;
                        frm.busFeePaymentReceiptToolStripMenuItem.Enabled      = false;
                        frm.hostelFeePaymentReceiptToolStripMenuItem.Enabled   = false;
                        frm.registrationToolStripMenuItem1.Enabled             = false;
                        frm.transportationChargesToolStripMenuItem.Enabled     = false;
                        frm.subjectInfoToolStripMenuItem1.Enabled              = true;
                        frm.EventtoolStripMenuItem1.Enabled                    = true;
                    }
                }


                else
                {
                    MessageBox.Show("Login Failed...Try again !", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    txtUserName.Clear();
                    txtPassword.Clear();
                    txtUserName.Focus();
                }
                if (myConnection.State == ConnectionState.Open)
                {
                    myConnection.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (UserID.Text == "")
            {
                MessageBox.Show("Please enter user id", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                UserID.Focus();
                return;
            }
            if (Password.Text == "")
            {
                MessageBox.Show("Please enter password", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Password.Focus();
                return;
            }
            try
            {
                cc.con = new SqlConnection(cs.DBConn);
                cc.con.Open();
                cc.cmd             = cc.con.CreateCommand();
                cc.cmd.CommandText = "SELECT RTRIM(UserID),RTRIM(Password) FROM Registration where UserID = @d1 and Password=@d2";
                cc.cmd.Parameters.AddWithValue("@d1", UserID.Text);
                cc.cmd.Parameters.AddWithValue("@d2", Password.Text);
                cc.rdr = cc.cmd.ExecuteReader();
                if (cc.rdr.Read())
                {
                    cc.con = new SqlConnection(cs.DBConn);
                    cc.con.Open();
                    cc.cmd             = cc.con.CreateCommand();
                    cc.cmd.CommandText = "SELECT usertype FROM Registration where UserID=@d3 and Password=@d4";
                    cc.cmd.Parameters.AddWithValue("@d3", UserID.Text);
                    cc.cmd.Parameters.AddWithValue("@d4", Password.Text);
                    cc.rdr = cc.cmd.ExecuteReader();
                    if (cc.rdr.Read())
                    {
                        UserType.Text = cc.rdr.GetValue(0).ToString().Trim();
                    }
                    if ((cc.rdr != null))
                    {
                        cc.rdr.Close();
                    }
                    if (cc.con.State == ConnectionState.Open)
                    {
                        cc.con.Close();
                    }
                    if ((UserType.Text == "Admin"))
                    {
                        frm.masterEntryToolStripMenuItem.Enabled = true;
                        frm.usersToolStripMenuItem.Enabled       = true;
                        frm.databaseToolStripMenuItem.Enabled    = true;



                        frm.lblUser.Text     = UserID.Text;
                        frm.lblUserType.Text = UserType.Text;
                        ProgressBar1.Visible = true;
                        ProgressBar1.Maximum = 5000;
                        ProgressBar1.Minimum = 0;
                        ProgressBar1.Value   = 4;
                        ProgressBar1.Step    = 1;
                        for (int i = 0; i <= 5000; i++)
                        {
                            ProgressBar1.PerformStep();
                        }
                        st1 = UserID.Text;
                        st2 = "Successfully logged in";
                        cf.LogFunc(st1, System.DateTime.Now, st2);
                        this.Hide();
                        frm.Show();
                    }
                    if ((UserType.Text == "Operator"))
                    {
                        frm.masterEntryToolStripMenuItem.Enabled = false;
                        frm.usersToolStripMenuItem.Enabled       = false;
                        frm.databaseToolStripMenuItem.Enabled    = false;



                        frm.lblUser.Text     = UserID.Text;
                        frm.lblUserType.Text = UserType.Text;
                        ProgressBar1.Visible = true;
                        ProgressBar1.Maximum = 5000;
                        ProgressBar1.Minimum = 0;
                        ProgressBar1.Value   = 4;
                        ProgressBar1.Step    = 1;
                        for (int i = 0; i <= 5000; i++)
                        {
                            ProgressBar1.PerformStep();
                        }
                        st1 = UserID.Text;
                        st2 = "Successfully logged in";
                        cf.LogFunc(st1, System.DateTime.Now, st2);
                        this.Hide();
                        frm.Show();
                    }
                }
                else
                {
                    MessageBox.Show("Login is Failed...Try again !", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    UserID.Text   = "";
                    Password.Text = "";
                    UserID.Focus();
                }
                cc.cmd.Dispose();
                cc.con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 8
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text == "")
            {
                MessageBox.Show("Please enter user name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUserName.Focus();
                return;
            }
            if (txtPassword.Text == "")
            {
                MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Focus();
                return;
            }
            try
            {
                SqlConnection myConnection = default(SqlConnection);
                myConnection = new SqlConnection(cs.DBConn);

                SqlCommand myCommand = default(SqlCommand);

                myCommand = new SqlCommand("SELECT Username,password FROM Registration WHERE Username = @username AND password = @UserPassword", myConnection);
                SqlParameter uName     = new SqlParameter("@username", SqlDbType.VarChar);
                SqlParameter uPassword = new SqlParameter("@UserPassword", SqlDbType.VarChar);
                uName.Value     = txtUserName.Text;
                uPassword.Value = txtPassword.Text;
                myCommand.Parameters.Add(uName);
                myCommand.Parameters.Add(uPassword);

                myCommand.Connection.Open();

                SqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

                if (myReader.Read() == true)
                {
                    int i;
                    ProgressBar1.Visible = true;
                    ProgressBar1.Maximum = 5000;
                    ProgressBar1.Minimum = 0;
                    ProgressBar1.Value   = 4;
                    ProgressBar1.Step    = 1;

                    for (i = 0; i <= 5000; i++)
                    {
                        ProgressBar1.PerformStep();
                    }
                    con = new SqlConnection(cs.DBConn);
                    con.Open();
                    string ct = "select usertype from Registration where Username='******' and Password='******'";
                    cmd            = new SqlCommand(ct);
                    cmd.Connection = con;
                    rdr            = cmd.ExecuteReader();
                    if (rdr.Read())
                    {
                        txtUserType.Text = (rdr.GetString(0));
                    }
                    if ((rdr != null))
                    {
                        rdr.Close();
                    }

                    if (txtUserType.Text.Trim() == "Admin")
                    {
                        this.Hide();
                        frmMainMenu frm = new frmMainMenu();
                        frm.Show();
                        frm.lblUser.Text = txtUserName.Text;
                    }
                    if (txtUserType.Text.Trim() == "Cashier")
                    {
                        this.Hide();
                        frmMainMenu frm = new frmMainMenu();
                        frm.Show();
                        frm.lblUser.Text = txtUserName.Text;
                    }
                    if (txtUserType.Text.Trim() == "Customer")
                    {
                        this.Hide();
                        frmCustomerMainMenu frm1 = new frmCustomerMainMenu();
                        frm1.Show();
                        frm1.lblUser.Text = txtUserName.Text;
                    }
                }


                else
                {
                    MessageBox.Show("Login is Failed...Try again !", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    txtUserName.Clear();
                    txtPassword.Clear();
                    txtUserName.Focus();
                }
                if (myConnection.State == ConnectionState.Open)
                {
                    myConnection.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 9
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text == "")
            {
                MessageBox.Show("Please enter user name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUserName.Focus();
                return;
            }
            if (txtPassword.Text == "")
            {
                MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Focus();
                return;
            }
            try
            {
                MySqlConnection myConnection = default(MySqlConnection);
                myConnection = new MySqlConnection(connString());

                MySqlCommand myCommand = default(MySqlCommand);

                myCommand = new MySqlCommand("SELECT Username,Password FROM registration WHERE Username = @username AND Password = @UserPassword", myConnection);
                MySqlParameter uName     = new MySqlParameter("@username", MySqlDbType.VarChar);
                MySqlParameter uPassword = new MySqlParameter("@UserPassword", MySqlDbType.VarChar);
                uName.Value     = txtUserName.Text;
                uPassword.Value = txtPassword.Text;
                myCommand.Parameters.Add(uName);
                myCommand.Parameters.Add(uPassword);

                myCommand.Connection.Open();

                MySqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

                if (myReader.Read() == true)
                {
                    int i;
                    ProgressBar1.Visible = true;
                    ProgressBar1.Maximum = 5000;
                    ProgressBar1.Minimum = 0;
                    ProgressBar1.Value   = 4;
                    ProgressBar1.Step    = 1;

                    for (i = 0; i <= 5000; i++)
                    {
                        ProgressBar1.PerformStep();
                    }
                    this.Hide();
                    frmMainMenu frm = new frmMainMenu();
                    frm.Show();
                    frm.lblUser.Text = txtUserName.Text;
                }


                else
                {
                    MessageBox.Show("Login is Failed...Try again !", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    txtUserName.Clear();
                    txtPassword.Clear();
                    txtUserName.Focus();
                }
                if (myConnection.State == ConnectionState.Open)
                {
                    myConnection.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 10
0
        private void Timer1_Tick_1(object sender, EventArgs e)
        {
            ProgressBar1.PerformStep();
            if (ProgressBar1.Value == 3)
            {
                lblloading.Text = "Loading.";
            }

            if (ProgressBar1.Value == 6)
            {
                lblloading.Text = "Loading..";
            }

            if (ProgressBar1.Value == 9)
            {
                lblloading.Text = "Loading...";
            }

            if (ProgressBar1.Value == 12)
            {
                lblloading.Text = "Loading....";
            }

            if (ProgressBar1.Value == 15)
            {
                lblloading.Text = "Loading.....";
            }

            if (ProgressBar1.Value == 18)
            {
                lblloading.Text = "Loading......";
            }

            if (ProgressBar1.Value == 21)
            {
                lblloading.Text = "Loading.......";
            }

            if (ProgressBar1.Value == 24)
            {
                lblloading.Text = "Loading........";
            }

            if (ProgressBar1.Value == 27)
            {
                lblloading.Text = "Loading.........";
            }

            if (ProgressBar1.Value == 30)
            {
                lblloading.Text = "Loading..........";
            }

            if (ProgressBar1.Value == 39)
            {
                lblloading.Text = "Preparing Instalation...";
            }

            if (ProgressBar1.Value == 48)
            {
                lblloading.Text = "Connecting Database...";
            }

            if (ProgressBar1.Value == 57)
            {
                lblloading.Text = "Collecting Data...";
            }

            if (ProgressBar1.Value == 66)
            {
                lblloading.Text = "Collecting Data...";
            }

            if (ProgressBar1.Value == 75)
            {
                lblloading.Text = "Loading Forms...";
            }

            if (ProgressBar1.Value == 84)
            {
                lblloading.Text = "Loading Images...";
            }

            if (ProgressBar1.Value == 96)
            {
                lblloading.Text = "  Welcome Click Here!!!";
            }

            if (ProgressBar1.Value >= ProgressBar1.Maximum)
            {
                Timer1.Enabled = false;
                this.Hide();
                Login l = new Login();
                l.Show();
            }
        }
Ejemplo n.º 11
0
        public void Ingresar()
        {
            if (cbRol.Text == "")
            {
                MessageBox.Show("Por favor seleccione un Rol", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cbRol.Focus();
                return;
            }


            if (txtUsuario.Text == "")
            {
                MessageBox.Show("Please enter user name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUsuario.Focus();
                return;
            }
            if (txtContraseña.Text == "")
            {
                MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtContraseña.Focus();
                return;
            }


            try
            {
                MySqlConnection myConnection = default(MySqlConnection);
                myConnection = new MySqlConnection(cs);

                MySqlCommand myCommand = default(MySqlCommand);

                myCommand = new MySqlCommand("SELECT Role, Usuario,Contrasena FROM RegistroUsuario WHERE Role = @Role AND Usuario = @Usuario AND Contrasena = @Contrasena", myConnection);
                MySqlParameter uRole     = new MySqlParameter("@Role", MySqlDbType.VarChar);
                MySqlParameter uName     = new MySqlParameter("@Usuario", MySqlDbType.VarChar);
                MySqlParameter uPassword = new MySqlParameter("@Contrasena", MySqlDbType.VarChar);

                uRole.Value     = cbRol.Text;
                uName.Value     = txtUsuario.Text;
                uPassword.Value = txtContraseña.Text;
                myCommand.Parameters.Add(uRole);
                myCommand.Parameters.Add(uName);
                myCommand.Parameters.Add(uPassword);


                myCommand.Connection.Open();

                MySqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);


                #region
                if (myReader.Read() == true)
                {
                    int i;

                    ProgressBar1.Visible = true;
                    ProgressBar1.Maximum = 800;
                    ProgressBar1.Minimum = 0;
                    ProgressBar1.Value   = 4;
                    ProgressBar1.Step    = 1;

                    for (i = 0; i <= 5000; i++)
                    {
                        ProgressBar1.PerformStep();
                    }

                    this.Hide();
                    FrmFacturacion frm = new FrmFacturacion();
                    //Logged in as (Role)
                    frm.Show();
                    frm.lbluser.Text         = cbRol.Text;
                    frm.txtFacturadoPor.Text = cbRol.Text;

                    if (cbRol.SelectedItem == "Empleado")
                    {
                        frm.usuariosToolStripMenuItem.Visible = false;
                    }
                }



                #endregion


                else
                {
                    MessageBox.Show("El inicio de sesion fallo, por favor verifique los datos correctamente!", "Inicio de sesion fallido", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    txtUsuario.Clear();
                    txtContraseña.Clear();

                    cbRol.Enabled = true;
                    cbRol.Focus();
                }
                if (myConnection.State == ConnectionState.Open)
                {
                    myConnection.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 12
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text == string.Empty)
            {
                MessageBox.Show("กรุณาใส่ชื่อผู้ใช้", "ล้มเหลว", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUserName.Focus();
                return;
            }
            if (txtPassword.Text == string.Empty)
            {
                MessageBox.Show("กรุณาใส่รหัสผ่าน", "ล้มเหลว", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Focus();
                return;
            }
            try
            {
                var myConnection = default(OleDbConnection);
                myConnection = new OleDbConnection(cs);

                var myCommand = default(OleDbCommand);

                myCommand = new OleDbCommand("SELECT Username,User_password FROM Users WHERE Username = @username AND User_password = @UserPassword", myConnection);
                var uName     = new OleDbParameter("@username", OleDbType.VarChar);
                var uPassword = new OleDbParameter("@UserPassword", OleDbType.VarChar);
                uName.Value     = txtUserName.Text;
                uPassword.Value = txtPassword.Text;
                myCommand.Parameters.Add(uName);
                myCommand.Parameters.Add(uPassword);

                myCommand.Connection.Open();

                var myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

                if (myReader.Read() == true)
                {
                    int i;
                    ProgressBar1.Visible = true;
                    ProgressBar1.Maximum = 5000;
                    ProgressBar1.Minimum = 0;
                    ProgressBar1.Value   = 4;
                    ProgressBar1.Step    = 1;

                    for (i = 0; i <= 5000; i++)
                    {
                        ProgressBar1.PerformStep();
                    }
                    Hide();
                    var frm = new frmMainMenu();
                    frm.Show();
                    frm.lblUser.Text = txtUserName.Text;
                }


                else
                {
                    MessageBox.Show("เข้าสู่ระบบล้มเหลว...ลองใหม่อีกครั้ง !", "เข้าสู่ระบบล้มเหลว", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    txtUserName.Clear();
                    txtPassword.Clear();
                    txtUserName.Focus();
                }
                if (myConnection.State == ConnectionState.Open)
                {
                    myConnection.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ล้มเหลว", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 13
0
 private void btnLogar_Click(object sender, EventArgs e)
 {
     //Válida os campos
     if (txtUser.Text == "")
     {
         MessageBox.Show("Informe o ID do usuário", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtUser.Focus();
         return;
     }
     if (txtSenha.Text == "")
     {
         MessageBox.Show("Informe a senha", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtSenha.Focus();
         return;
     }
     try
     {
         cc.con = new SqlConnection(cs.DBConn);
         cc.con.Open();
         cc.cmd             = cc.con.CreateCommand();
         cc.cmd.CommandText = "SELECT RTRIM(UserID),RTRIM(UserSenha) FROM Registration WHERE UserID = @d1 and UserSenha=@d2";
         cc.cmd.Parameters.AddWithValue("@d1", txtUser.Text);
         cc.cmd.Parameters.AddWithValue("@d2", txtSenha.Text);
         cc.rdr = cc.cmd.ExecuteReader();
         if (cc.rdr.Read())
         {
             cc.con = new SqlConnection(cs.DBConn);
             cc.con.Open();
             cc.cmd             = cc.con.CreateCommand();
             cc.cmd.CommandText = "SELECT UserTipo, UserID FROM Registration WHERE UserID=@d3 and UserSenha=@d4";
             cc.cmd.Parameters.AddWithValue("@d3", txtUser.Text);
             cc.cmd.Parameters.AddWithValue("@d4", txtSenha.Text);
             cc.rdr = cc.cmd.ExecuteReader();
             if (cc.rdr.Read())
             {
                 UserType.Text = cc.rdr.GetValue(0).ToString().Trim();
                 UserID.Text   = cc.rdr.GetValue(1).ToString().Trim();
             }
             if ((cc.rdr != null))
             {
                 cc.rdr.Close();
             }
             if (cc.con.State == ConnectionState.Open)
             {
                 cc.con.Close();
             }
             if ((UserType.Text == "ADM"))
             {
                 frm.usersToolStripMenuItem.Enabled     = true;
                 frm.databaseToolStripMenuItem.Enabled  = true;
                 frm.staffToolStripMenuItem.Enabled     = true;
                 frm.patientToolStripMenuItem.Enabled   = true;
                 frm.procedureToolStripMenuItem.Enabled = true;
                 frm.lblUser.Text     = txtUser.Text;
                 frm.lblUserType.Text = UserType.Text;
                 ProgressBar1.Visible = true;
                 ProgressBar1.Maximum = 5000;
                 ProgressBar1.Minimum = 0;
                 ProgressBar1.Value   = 4;
                 ProgressBar1.Step    = 1;
                 for (int i = 0; i <= 5000; i++)
                 {
                     ProgressBar1.PerformStep();
                 }
                 st1 = UserID.Text;
                 st2 = "Logado com sucesso";
                 cf.LogFunc(st1, System.DateTime.Now, st2);
                 this.Hide();
                 frm.Show();
             }
             if ((UserType.Text == "GERENTE"))
             {
                 frm.usersToolStripMenuItem.Enabled     = false;
                 frm.databaseToolStripMenuItem.Enabled  = false;
                 frm.staffToolStripMenuItem.Enabled     = true;
                 frm.patientToolStripMenuItem.Enabled   = true;
                 frm.procedureToolStripMenuItem.Enabled = false;
                 frm.lblUser.Text     = txtUser.Text;
                 frm.lblUserType.Text = UserType.Text;
                 ProgressBar1.Visible = true;
                 ProgressBar1.Maximum = 5000;
                 ProgressBar1.Minimum = 0;
                 ProgressBar1.Value   = 4;
                 ProgressBar1.Step    = 1;
                 for (int i = 0; i <= 5000; i++)
                 {
                     ProgressBar1.PerformStep();
                 }
                 st1 = UserID.Text;
                 st2 = "Logado com sucesso";
                 cf.LogFunc(st1, System.DateTime.Now, st2);
                 this.Hide();
                 frm.Show();
             }
             if ((UserType.Text == "MEDICO"))
             {
                 frm.usersToolStripMenuItem.Enabled     = false;
                 frm.databaseToolStripMenuItem.Enabled  = false;
                 frm.staffToolStripMenuItem.Enabled     = false;
                 frm.patientToolStripMenuItem.Enabled   = true;
                 frm.procedureToolStripMenuItem.Enabled = true;
                 frm.lblUser.Text     = txtUser.Text;
                 frm.lblUserType.Text = UserType.Text;
                 ProgressBar1.Visible = true;
                 ProgressBar1.Maximum = 5000;
                 ProgressBar1.Minimum = 0;
                 ProgressBar1.Value   = 4;
                 ProgressBar1.Step    = 1;
                 for (int i = 0; i <= 5000; i++)
                 {
                     ProgressBar1.PerformStep();
                 }
                 st1 = UserID.Text;
                 st2 = "Logado com sucesso";
                 cf.LogFunc(st1, System.DateTime.Now, st2);
                 this.Hide();
                 frm.Show();
             }
             if ((UserType.Text == "FUNCIONARIO"))
             {
                 frm.usersToolStripMenuItem.Enabled     = false;
                 frm.databaseToolStripMenuItem.Enabled  = false;
                 frm.staffToolStripMenuItem.Enabled     = false;
                 frm.patientToolStripMenuItem.Enabled   = true;
                 frm.procedureToolStripMenuItem.Enabled = false;
                 frm.lblUser.Text     = txtUser.Text;
                 frm.lblUserType.Text = UserType.Text;
                 ProgressBar1.Visible = true;
                 ProgressBar1.Maximum = 5000;
                 ProgressBar1.Minimum = 0;
                 ProgressBar1.Value   = 4;
                 ProgressBar1.Step    = 1;
                 for (int i = 0; i <= 5000; i++)
                 {
                     ProgressBar1.PerformStep();
                 }
                 st1 = UserID.Text;
                 st2 = "Logado com sucesso";
                 cf.LogFunc(st1, System.DateTime.Now, st2);
                 this.Hide();
                 frm.Show();
             }
         }
         else
         {
             MessageBox.Show("Login falhou... tente novamente !", "Login Falhou", MessageBoxButtons.OK, MessageBoxIcon.Error);
             txtUser.Text  = "";
             txtSenha.Text = "";
             txtUser.Focus();
         }
         cc.cmd.Dispose();
         cc.con.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 14
0
        private void Button1_Click(System.Object sender, System.EventArgs e)
        {
            if (Strings.Len(Strings.Trim(cmbUserType.Text)) == 0)
            {
                MessageBox.Show("Please select user type", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cmbUserType.Focus();
                return;
            }
            if (Strings.Len(Strings.Trim(txtUsername.Text)) == 0)
            {
                MessageBox.Show("Please enter user name", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUsername.Focus();
                return;
            }
            if (Strings.Len(Strings.Trim(txtPassword.Text)) == 0)
            {
                MessageBox.Show("Please enter password", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Focus();
                return;
            }
            try {
                OleDbConnection myConnection = null;
                myConnection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\\LMS_DB.accdb;Persist Security Info=False;");
                OleDbCommand myCommand = null;
                myCommand = new OleDbCommand("SELECT users.username,User_password FROM Users,Registration where Registration.Username=users.username and Users.Username = @Username and user_password = @UserPassword", myConnection);

                OleDbParameter uName     = new OleDbParameter("@Username", SqlDbType.VarChar);
                OleDbParameter uPassword = new OleDbParameter("@UserPassword", SqlDbType.VarChar);
                uName.Value     = txtUsername.Text;
                uPassword.Value = txtPassword.Text;
                myCommand.Parameters.Add(uName);

                myCommand.Parameters.Add(uPassword);

                myCommand.Connection.Open();

                OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

                object Login = 0;


                if (myReader.HasRows)
                {
                    myReader.Read();

                    Login = myReader[Login];
                }


                if (Login == null)
                {
                    Interaction.MsgBox("Login is Failed...Try again !", MsgBoxStyle.Critical, "Login Denied");
                    txtUsername.Clear();
                    txtPassword.Clear();
                    txtUsername.Focus();
                }
                else
                {
                    ProgressBar1.Visible = true;
                    ProgressBar1.Maximum = 5000;
                    ProgressBar1.Minimum = 0;
                    ProgressBar1.Value   = 4;
                    ProgressBar1.Step    = 1;

                    for (i = 0; i <= 5000; i++)
                    {
                        ProgressBar1.PerformStep();
                    }
                    this.Hide();
                    My.MyProject.Forms.frmMain.lblUser.Text = txtUsername.Text;
                    My.MyProject.Forms.frmMain.Show();
                }
                myCommand.Dispose();
                myConnection.Close();
            } catch (Exception ex) {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 15
0
 public void SetProgress()
 {
     ProgressBar1.PerformStep();
 }
Ejemplo n.º 16
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtNumeUtilizator.Text == "")
            {
                MessageBox.Show("Introduce utilizatorul", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtNumeUtilizator.Focus();
                return;
            }
            if (txtParola.Text == "")
            {
                MessageBox.Show("Introduce parola", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtParola.Focus();
                return;
            }


            try
            {
                SqlConnection myConnection = default(SqlConnection);
                myConnection = new SqlConnection(cs.DBConn);

                SqlCommand myCommand = default(SqlCommand);

                //
                // inregistrare = InregistrareOperations.Get(null, null);
                //

                myCommand = new SqlCommand("SELECT Nume_utilizator,Parola FROM Inregistrare WHERE Nume_utilizator = @Nume_utilizator AND parola = @Parola", myConnection);
                SqlParameter uName     = new SqlParameter("@Nume_utilizator", SqlDbType.VarChar);
                SqlParameter uPassword = new SqlParameter("@Parola", SqlDbType.VarChar);
                uName.Value     = txtNumeUtilizator.Text;
                uPassword.Value = txtParola.Text;
                myCommand.Parameters.Add(uName);
                myCommand.Parameters.Add(uPassword);

                myCommand.Connection.Open();

                SqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

                if (myReader.Read() == true)
                {
                    int i;
                    ProgressBar1.Visible = true;
                    ProgressBar1.Maximum = 5000;
                    ProgressBar1.Minimum = 0;
                    ProgressBar1.Value   = 4;
                    ProgressBar1.Step    = 1;

                    for (i = 0; i <= 5000; i++)
                    {
                        ProgressBar1.PerformStep();
                    }

                    this.Hide();
                    MeniuPrincipal frm = new MeniuPrincipal();
                    frm.Show();
                    frm.lblUser.Text = txtNumeUtilizator.Text;
                }


                else
                {
                    MessageBox.Show("Login is Failed...Try again !", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    txtNumeUtilizator.Clear();
                    txtParola.Clear();
                    txtNumeUtilizator.Focus();
                }
                if (myConnection.State == ConnectionState.Open)
                {
                    myConnection.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }