示例#1
0
 public void GoGoGadgetiFaith()
 {
     QuitDFU              = true;
     DFUConnected         = false;
     ResetDFUInstructions = true;
     iDetector();
     //Shutdown iTunes...
     //Shell("cmd /c taskkill /f /t /im iTunes.exe", AppWinStyle.Hide)
     //Shell("cmd /c taskkill /f /t /im iTunesHelper.exe", AppWinStyle.Hide)
     //Go...
     MDIMain.TopMost = true;
     MDIMain.Activate();
     if (iREB_mode == true)
     {
         MDIMain.TopMost = true;
         MDIMain.Activate();
         PictureBox2.Visible  = true;
         ProgressBar1.Visible = true;
         PictureBox2.BringToFront();
         ProgressBar1.BringToFront();
         BackgroundWorker2.RunWorkerAsync();
         SaveToDisk("s-irecovery.exe", temppath + "\\s-irecovery.exe");
         iRecovery_exploit();
         MDIMain.TopMost = false;
         Interaction.MsgBox("Your device is now in a PWNED DFU state (black screen)." + Strings.Chr(13) + Strings.Chr(13) + "You may now launch iTunes and do SHIFT + Restore" + Strings.Chr(13) + "to the custom *signed* IPSW located on your desktop!", MsgBoxStyle.Information);
         CleaniREB();
     }
     else
     {
         Run.MdiParent = MDIMain;
         Run.Show();
         this.Dispose();
     }
 }
示例#2
0
        // <summary>
        // set the progress to a new value
        // </summary>
        // <param name="Percent">progress in percent</param>
        // <remarks></remarks>
        private void progressUpdate(Int32 Percent)
        {
            try {
                if (ProgressBar1.InvokeRequired)
                {
                    ProgressBar1.Invoke(new del_Sub_PInt32(this.progressUpdate), Percent);
                }
                else
                {
                    ProgressBar1.Value = Percent;
                    if (Percent > 0 && Percent < 100)
                    {
                        ProgressBar1.Value = Percent - 1;
                    }

                    lblProgress.Text = string.Format("{0}%", Percent);
                    ProgressBar1.Refresh();

                    if (m_SelfDoEvents)
                    {
                        Application.DoEvents();
                    }
                }
            }
            catch (Exception ex) {
                throw new Exception("error while setting a new value", ex);
            }
        }
        private void BeginProcess(string spreadSheetPath, IProgress <double> progress)
        {
            var process = new ProcessController(spreadSheetPath);

            process.OnProgressChanged += (d) =>
            {
                progress?.Report(d);
                ProgressBar1.Invoke((Action)(() => ProgressBar1.Value = d));
                return(d);
            };
            process.OnProgressFinished += (s, e) =>
            {
                TxtFilePath.Invoke((Action)(() => TxtFilePath.IsEnabled = true));
                BtnBrowse.Invoke((Action)(() => BtnBrowse.IsEnabled = true));
                BtnStartProcess.Invoke((Action)(() => BtnStartProcess.IsEnabled = true));
                System.Windows.MessageBox.Show("Operation Done Successfully.");

                System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    var report = new OperationReport(new OperationReportContext()
                    {
                        Success = e.SuccessEmails,
                        Errors  = e.FailedEmails
                    });
                    report.ShowDialog();
                }));
            };
            process.BeginProcessing();
        }
示例#4
0
 public void UpdateProgressBar(string currentDisconnectintClientName)
 {
     //if (sections < _InternalClientList.Count - 1) {
     //    ++sections;
     //}
     //if (sections < TotalConnectedClients) {
     //    ++sections;
     //}
     if (InvokeRequired)
     {
         Invoke(new Action((delegate
         {
             ++ProgressBar1.Value;
         })));
         Invoke(new Action((delegate
         {
             LblDisconnecting.Text = @"Disconnecting " + currentDisconnectintClientName + @" " + ProgressBar1.Value + @" of " + ProgressBar1.Maximum;
         })));
         Invoke(new Action((delegate
         {
             ProgressBar1.Update();
         })));
     }
     else
     {
         ++ProgressBar1.Value;
     }
     //Thread.Sleep(250);
     //if (ProgressBar1.Value == ProgressBar1.Maximum) {
     //    Invoke(new Action(Close));
     //}
 }
示例#5
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;
        }
示例#6
0
        private void Wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (ct)
            {
                var links = wb.Document.GetElementsByTagName("a");
                foreach (HtmlElement link in links)
                {
                    if (link.GetAttribute("className") == "btn dark medium")
                    {
                        pagelink = link.GetAttribute("href");
                        break;
                    }
                }
                ProgressBar1.Increment(20);     //  Incremented 20

                if (pagelink == "")
                {
                    ProgressBar1.Value = 0;
                    MessageBox.Show("Sorry the entered code was not found.", "Please try another id");
                    button1.Enabled  = true;
                    textBox1.Enabled = true;
                    wb.Dispose();
                    return;
                }
                wb2.ScriptErrorsSuppressed = true;
                wb2.Navigate(pagelink.Trim());

                wb2.DocumentCompleted += Wb2_DocumentCompleted;
                wb.Dispose();
            }
        }
示例#7
0
 private async void ResetProgressBar()
 {
     ProgressBar1.Visible = false;
     ProgressBar1.Value   = 0;
     ProgressBar1.Update();
     UseWaitCursor = false;
 }
示例#8
0
 private void timer2_Tick(object sender, EventArgs e)
 {
     ProgressBar1.PerformStep();
     if (tt == true)
     {
         ProgressBar1.Value = ProgressBar1.Maximum;
         timer2.Enabled     = false;
     }
 }
示例#9
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     ProgressBar1.Increment(1);
     if (ProgressBar1.Value == 100)
     {
         Label4.Show();
         timer1.Stop();
     }
     Label3.Text = ProgressBar1.Value + (" %");
 }
示例#10
0
        private void DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {
            string str = serialPort.ReadLine();

            if (str != string.Empty)
            {
                proximity = System.Convert.ToInt32(str);
                ProgressBar1.BeginInvoke(new myDelegate(updateControl));
                Console.WriteLine(proximity);
            }
        }
 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();
     }
 }
示例#12
0
 private void Timer1_Tick(object sender, EventArgs e)
 {
     ProgressBar1.Increment(1);
     if (ProgressBar1.Value == ProgressBar1.Maximum)
     {
         frmLogin oFrmLogin = new frmLogin(oLogin);
         oFrmLogin.Show();
         this.Hide();
         Timer1.Stop();
     }
 }
示例#13
0
//#7------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        private void Threadhandler()
        {
            try
            {
                BenchTimer.Start();
                ProgressBar1.Invoke(new Action <int>(s => { ProgressBar1.Minimum = s; }), 0);
                ProgressBar1.Invoke(new Action <int>(s => { ProgressBar1.Maximum = s; }), 1);
                ProgressBar1.Invoke(new Action <int>(s => { ProgressBar1.Value = s; }), 0);
                AllFilesToConvert.Clear();
                AllActionMessages.Clear();
                if (FilePath.Length > 0)
                {
                    ConvertString(FilePath);
                    ProgressBar1.Invoke(new Action <int>(s => { ProgressBar1.Value = s; }), 1);
                }
                if (FolderPath.Length > 0)
                {
                    CheckSubFolders(FolderPath);
                    ProgressBar1.Invoke(new Action <int>(s => { ProgressBar1.Maximum = s; }), AllFilesToConvert.Count - 1);
                    for (int i = 0; i < AllFilesToConvert.Count; i++)
                    {
                        ConvertString(AllFilesToConvert[i]);
                        ProgressBar1.Invoke(new Action <int>(s => { ProgressBar1.Value = s; }), i);
                    }
                }
                MethodInvoker AddItems = delegate
                {
                    for (int i = 0; i < AllActionMessages.Count; i++)
                    {
                        ActionBox.Items.Add(AllActionMessages[i]);
                    }
                };
                ActionBox.BeginInvoke(AddItems);
                BenchTimer.Stop();
                MessageBox.Show(string.Format(FinalMessage, ChangeCount, ChangedFileCount, BenchTimer.ElapsedMilliseconds.ToString()));
                BenchTimer.Reset();
                FileBrowse.Invoke(new Action <bool>(s => { FileBrowse.Enabled = s; }), true);
                FolderBrowse.Invoke(new Action <bool>(s => { FolderBrowse.Enabled = s; }), true);
                ConvertButton.Invoke(new Action <bool>(s => { ConvertButton.Enabled = s; }), true);
                OldStringTextBox.Invoke(new Action <bool>(s => { OldStringTextBox.Enabled = s; }), true);
                NewStringTextBox.Invoke(new Action <bool>(s => { NewStringTextBox.Enabled = s; }), true);
                CaseSensitiveCheckBox.Invoke(new Action <bool>(s => { CaseSensitiveCheckBox.Enabled = s; }), true);
                WholeWordCheckBox.Invoke(new Action <bool>(s => { WholeWordCheckBox.Enabled = s; }), true);
                if (!SourceFilePathBox.Text.Equals(TempPath))
                {
                    SourceBrowse.Invoke(new Action <bool>(s => { SourceBrowse.Enabled = s; }), true);
                    DownloadSourceButton.Invoke(new Action <bool>(s => { DownloadSourceButton.Enabled = s; }), true);
                }
            }
            catch
            {
            }
        }
示例#14
0
        private void btnSave_Image_Click(object sender, RoutedEventArgs e)
        {
            TimeSpan        scaleDuration     = new TimeSpan(0, 0, 0, 0, 1000);
            DoubleAnimation ProgressAnimation = new DoubleAnimation(0, 100, scaleDuration, FillBehavior.Stop);

            ProgressBar1.BeginAnimation(ProgressBar.ValueProperty, ProgressAnimation);


            DataTable dataTable = ds.Tables[0];

            foreach (DataRow row in dataTable.Rows)
            {
                if (row[0].ToString() == lvPictureResult.SelectedItem.ToString())
                {
                    //Store binary data read from the database in a byte array
                    byte[]       blob   = (byte[])row[1];
                    MemoryStream stream = new MemoryStream();
                    stream.Write(blob, 0, blob.Length);
                    stream.Position = 0;

                    System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
                    BitmapImage          bi  = new BitmapImage();
                    bi.BeginInit();

                    MemoryStream ms = new MemoryStream();
                    img.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
                    ms.Seek(0, SeekOrigin.Begin);
                    bi.StreamSource = ms;
                    bi.EndInit();
                    image2.Source = bi;
                    //save file image to directory
                    try
                    {
                        if (img != null)
                        {
                            img.Save("..\\..\\PhotosSaved\\" + lvPictureResult.SelectedItem.ToString());
                            MessageBox.Show("Image saved successfully.");
                            Window1.Editor.ClearPhotoList();
                            Window1.Editor.Photos.Update();
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("There was a problem saving the file." +
                                        "Check the file permissions.");
                    }
                }
            }
        }
示例#15
0
 private void Timer1_Tick(object sender, EventArgs e)
 {
     ProgressBar1.Increment(1);
     if (ProgressBar1.Value == ProgressBar1.Maximum)
     {
         Timer1.Stop();
         this.labelthanhcong.Text = "Cơ sở dữ liệu đã được Backup thành công";
         this.labelform.Text      = "";
         ProgressBar1.Visible     = false;
         btnThucHien.Visible      = false;
         btnHoanThanh.Visible     = true;
         this.btnHoanThanh.Focus();
         Log_BUS.ThemNhatKy("Dữ liệu", "Sao lưu dữ liệu");
     }
 }
示例#16
0
 public void Timer1_Tick(object sender, EventArgs e)
 {
     ProgressBar1.Increment(1);
     if (ProgressBar1.Value == ProgressBar1.Maximum)
     {
         timer1.Stop();
         this.labelthanhcong.Text = "Phục hồi thành công!";
         this.labelform.Text      = "";
         ProgressBar1.Visible     = false;
         btnThucHien.Visible      = false;
         btnHoanThanh.Visible     = true;
         this.btnHoanThanh.Focus();
         Log_BUS.ThemNhatKy("Dữ liệu", "Phục hồi dữ liệu");
     }
 }
示例#17
0
 public void Dispose()
 {
     if (_controlType == AccountType.Customer)
     {
         ProgressBar1.Dispose();
         ProgressBar2.Dispose();
         ProgressBar5.Dispose();
         ProgressBar10.Dispose();
         CoinsViewModel model = DataContext as CoinsViewModel;
         //if (model != null)
         //{
         model.DisposeRequest -= Dispose;
         //}
     }
 }
示例#18
0
 void updatepercent(long per)
 {
     if (InvokeRequired)
     {
         Invoke(new LongDelegate(updatepercent), new object[] { per });
     }
     else
     {
         try
         {
             ProgressBar1.Value = (int)per;
             ProgressBar1.Invalidate();
         }
         catch (Exception) { }
     }
 }
示例#19
0
 public void BackgroundWorker2_DoWork(System.Object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     try {
         while (!(ProgressBar1.Value == 99))
         {
             if (OhNoesShutDOWN == true)
             {
                 return;
             }
             ProgressBar1.Invoke((MethodInvoker)Increase);
             Sleep(45);
         }
         ProgressBar1.Invoke((MethodInvoker)one00Percent);
     } catch (Exception ex) {
     }
 }
示例#20
0
        private void button1_Click(object sender, EventArgs e)
        {
            wb  = new WebBrowser();
            wb2 = new WebBrowser();
            ProgressBar1.Increment(10);         //  Incremented 20
            label1.Visible = false;
            saveToolStripMenuItem.Enabled = false;
            ct                        = true;
            label1.Text               = "";
            textBox1.Enabled          = false;
            button1.Enabled           = false;
            wb.ScriptErrorsSuppressed = true;
            string temp = "https://vitspot.com/?s=" + textBox1.Text;

            wb.Navigate(temp);
            ProgressBar1.Increment(20);         //  Incremented 20
            wb.DocumentCompleted += Wb_DocumentCompleted;
        }
示例#21
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Esconde elemnetos de la interfaz
            pb_iniciar.Hide();
            ProgressBar1.Hide();
            lb_iniciar.Hide();

            // setea la fecha actual en un label
            Label2.Text = "© " + DateTime.Today.Year.ToString() + " - Todos los derechos reservados";


            //  metodo lee las configuraciones del sistema principalmente si el usuario se guardo en las configuraciones del sistema
            StreamReader busqueda = new StreamReader("configuracion.cfg");

            string cadena;

            while ((cadena = busqueda.ReadLine()) != null)
            {
                string[] campos = cadena.Split(':');

                if (campos[0].Equals("guardarusuario") & campos.Length > 2)
                {
                    DataSet ds;
                    ds = conexion.sqlconsulta("Select usuario from tbl_usuarios where id_usuario='" + campos[2] + "'");
                    if (ds.Tables.Count > 0)
                    {
                        tb_usuario.Text = ds.Tables[0].Rows[0].ItemArray[0].ToString();
                    }
                }
                else if (campos[0].Equals("guardarpass") & campos.Length > 2)
                {
                    DataSet ds;
                    ds = conexion.sqlconsulta("Select pass from tbl_usuarios where id_usuario='" + campos[2] + "'");
                    if (ds.Tables.Count > 0)
                    {
                        tb_password.Text = ds.Tables[0].Rows[0].ItemArray[0].ToString();
                    }
                }
            }


            busqueda.Close();
        }
        private void Timer1_Tick(object sender, EventArgs e)
        {
            ProgressBar1.Increment(1);

            switch (ProgressBar1.Value)
            {
            case 1:
                loaderLabel.Text = "Loading....";
                break;

            case 20:
                loaderLabel.Text = "Setting Up Pages....";
                break;

            case 40:
                loaderLabel.Text = "Loading Forms....";
                break;

            case 60:
                loaderLabel.Text = "Loading Doctors....";
                break;

            case 80:
                loaderLabel.Text = "Loading Patients....";
                break;

            case 99:
                loaderLabel.Text = "Welcome...";
                LoginPage loginPage = new LoginPage();
                loginPage.Show();
                this.Hide();
                break;

            default:
                break;
            }

            percentageLabel.Text = ProgressBar1.Value + " %";
        }
示例#23
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 Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     DataGrid1.ItemsSource = list;
     //ProgressBar1.Visibility = Visibility.Hidden;
     ProgressBar1.Stop();
 }
示例#25
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);
            }
        }
示例#26
0
    private void Prog_In_Timer_Tick(object sender, EventArgs e)
    {
        //Inrement by +1 in progressbar #1 (get it started)
        ProgressBar1.Increment(+1);


        //Add percent towards the central label
        Label2.Text = "Loading... " + ProgressBar1.Value.ToString + "%";
        IO.StreamReader r = default(IO.StreamReader);


        //Self-setup and checkup

        if (ProgressBar1.Value == "1")
        {
            if (My.Computer.FileSystem.DirectoryExists("C:\\CoderRevolt\\WebBrowser\\V1"))
            {
                //Check if returning user
            }
            else
            {
                //If user is new, then create core directory folder
                My.Computer.FileSystem.CreateDirectory("C:\\CoderRevolt\\WebBrowser\\V1");
            }
        }

        //Make sure History and Bookmarks panels are loaded up for next ProgressCheck @ Value '10'
        if (ProgressBar1.Value == "5")
        {
            Hist.Show();
            Hist.Hide();

            Bookmarks.Show();
            Bookmarks.Hide();
        }

        //Bookmark Self-Check and Setup
        if (ProgressBar1.Value == "10")
        {
            if (My.Computer.FileSystem.FileExists("C:\\CoderRevolt\\WebBrowser\\V1\\Bookmarks.gwbb"))
            {
                r = new IO.StreamReader("C:\\CoderRevolt\\WebBrowser\\V1\\Bookmarks.gwbb");
                while ((r.Peek() > -1))
                {
                    Bookmarks.ListBox1.Items.Add(r.ReadLine);
                }
                r.Close();
            }
            else
            {
            }
            if (My.Computer.FileSystem.FileExists("C:\\CoderRevolt\\WebBrowser\\V1\\Bookmarks2.gwbb"))
            {
                r = new IO.StreamReader("C:\\CoderRevolt\\WebBrowser\\V1\\Bookmarks2.gwbb");
                while ((r.Peek() > -1))
                {
                    Bookmarks.ListBox2.Items.Add(r.ReadLine);
                }
                r.Close();
            }
            else
            {
            }
        }

        //History Self-Check and Setup
        if (ProgressBar1.Value == "20")
        {
            if (My.Computer.FileSystem.FileExists("C:\\CoderRevolt\\WebBrowser\\V1\\History1.gwbb"))
            {
                r = new IO.StreamReader("C:\\CoderRevolt\\WebBrowser\\V1\\History1.gwbb");
                while ((r.Peek() > -1))
                {
                    Hist.ListBox1.Items.Add(r.ReadLine);
                }
                r.Close();
            }
            else
            {
            }
            if (My.Computer.FileSystem.FileExists("C:\\CoderRevolt\\WebBrowser\\V1\\History2.gwbb"))
            {
                r = new IO.StreamReader("C:\\CoderRevolt\\WebBrowser\\V1\\History2.gwbb");
                while ((r.Peek() > -1))
                {
                    Hist.ListBox2.Items.Add(r.ReadLine);
                }
                r.Close();
            }
            else
            {
            }
        }
        if (ProgressBar1.Value == "100")
        {
            Prog_In_Timer.Stop();
            this.Hide();

            Main.Show();
        }
    }
示例#27
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);
            }
        }
        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);
            }
        }
        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);
            }
        }
示例#30
0
        // metodo implementa en el timer un progressbar para que cada momento va cambiando una imagen de posicion
        private void timer1_Tick(object sender, EventArgs e)
        {
            ProgressBar1.Increment(2);

            if (ProgressBar1.Value == 0)
            {
                cambiar("imagenes/image (1).png");

                lb_iniciar.Text = ".";
            }
            else if (ProgressBar1.Value == 8)
            {
                cambiar("imagenes/image (2).png");
                lb_iniciar.Text = "..";
            }
            else if (ProgressBar1.Value == 16)
            {
                cambiar("imagenes/image (3).png");
                lb_iniciar.Text = "...";
            }
            else if (ProgressBar1.Value == 24)
            {
                cambiar("imagenes/image (4).png");
                lb_iniciar.Text = ".";
            }
            else if (ProgressBar1.Value == 32)
            {
                cambiar("imagenes/image (5).png");
                lb_iniciar.Text = "..";
            }
            else if (ProgressBar1.Value == 40)
            {
                cambiar("imagenes/image (6).png");
                lb_iniciar.Text = "...";
            }
            else if (ProgressBar1.Value == 48)
            {
                cambiar("imagenes/image (7).png");
                lb_iniciar.Text = ".";
            }
            else if (ProgressBar1.Value == 56)
            {
                cambiar("imagenes/image (8).png");
                lb_iniciar.Text = "..";
            }
            else if (ProgressBar1.Value == 64)
            {
                cambiar("imagenes/image (9).png");
                lb_iniciar.Text = "...";
            }
            else if (ProgressBar1.Value == 72)
            {
                cambiar("imagenes/image (10).png");
                lb_iniciar.Text = ".";
            }
            else if (ProgressBar1.Value == 80)
            {
                cambiar("imagenes/image (11).png");
                lb_iniciar.Text = "..";
            }
            else if (ProgressBar1.Value == 88)
            {
                cambiar("imagenes/image (12).png");
                lb_iniciar.Text = "...";
            }
            else if (ProgressBar1.Value == 96)
            {
                cambiar("imagenes/image (2).png");
                lb_iniciar.Text = ".";
            }
            else if (ProgressBar1.Value == 100)
            {
                // cuando el progressbar llega al final se procede a iniciar sesion  por medio de una consulta sql verificando si el usuario y contraseña ingresados sean correctos
                lb_iniciar.Text = "Iniciando...";
                pb_iniciar.Hide();
                btn_iniciar.Show();
                ProgressBar1.Value = 0;

                lb_iniciar.Hide();

                DataSet ds;
                ds = conexion.sqlconsulta("Select id_usuario,tipo from tbl_usuarios where usuario='" + tb_usuario.Text + "' and pass='******' ");
                try
                {
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        timer1.Stop();
                        MessageBox.Show("Su nombre o contraseña son incorrectos");
                        tb_password.Enabled = true;
                        tb_usuario.Enabled  = true;
                    }
                    else
                    {
                        var tipo = ds.Tables[0].Rows[0].ItemArray[1].ToString();
                        int ID   = int.Parse(ds.Tables[0].Rows[0].ItemArray[0].ToString());
                        // verifica el tipo de usuario que corresponde para los permisos necesarios
                        if (tipo.Trim() == "ADMINISTRADOR")
                        {
                            frm_inicio.conexion = this.conexion;
                            frm_inicio.ID       = ID;
                            frm_inicio.Show();
                        }
                        else if (tipo.Trim() == "USUARIO")
                        {
                            frm_inicio.ID           = ID;
                            frm_inicio.conexion     = this.conexion;
                            frm_inicio.tipo_usuario = "USUARIO";
                            frm_inicio.Show();
                        }
                    }
                }
                catch (Exception ex)
                {
                }



                timer1.Stop();
            }
        }