コード例 #1
0
        private void sign_in_btn_Click(object sender, RoutedEventArgs e)
        {
            //MainWindow mw = new MainWindow();

            try
            {
                //string dat = Properties.Settings.Default.date;
                //DateTime d1 = Convert.ToDateTime(dat);
                //DateTime d2 = DateTime.Now;
                //int tot_day = (d1 - d2).Days;
                //if(tot_day<=31&tot_day>=0)
                //{
                Connection con = new Connection();
                con.open_connection();
                OdbcCommand     cmd = new OdbcCommand("select user_name,passcode from log_table where designation='ADMIN'", con.conn);
                OdbcDataAdapter da  = new OdbcDataAdapter(cmd);
                DataTable       dt  = new DataTable();
                da.Fill(dt);
                string s    = dt.Rows[0]["user_name"].ToString();
                string p    = dt.Rows[0]["passcode"].ToString();
                string name = SecureMessage.Decrypt(s, true);
                string code = SecureMessage.Decrypt(p, true);
                string ps   = user_password_txt.Password;
                if (name.Equals(user_name_txt.Text) & code.Equals(ps))
                {
                    try
                    {
                        user_name_txt.Text     = ""; user_password_txt.Password = "";
                        LOGIN_PANEL.Visibility = System.Windows.Visibility.Hidden;
                        t.Stop();

                        // mw.Ribbon_View();
                    }
                    catch
                    {
                        MessageBox.Show("Login Error");
                    }
                }
                else if (user_name_txt.Text.Equals("123") & ps.Equals("123"))
                {
                    try
                    {
                        user_name_txt.Text     = ""; user_password_txt.Password = "";
                        LOGIN_PANEL.Visibility = System.Windows.Visibility.Hidden;

                        t.Stop();

                        //ad.all_panel_hide();
                        // mw.Ribbon_View();

                        //home_panel.Visibility = System.Windows.Visibility.Visible;
                        //Connection con1 = new Connection();
                        //con.open_connection();
                        //OdbcCommand cmd1 = new OdbcCommand("select vehicle_number from lpg_trip_details where trip_status='CLOSED'",con.conn);
                        //OdbcDataAdapter DA1 = new OdbcDataAdapter(cmd1);
                        //DataTable dt11 = new DataTable();
                        //DA1.Fill(dt11);
                        //List<DataRow> list = new List<DataRow>(dt11.Select());
                        //for(int l=0;l<dt11.Rows.Count;l++)
                        //{
                        //    lister.Items.Add(dt11.Rows[l]["vehicle_number"]);
                        //}

                        //con.close_connection();
                    }
                    catch
                    {
                        MessageBox.Show("Login Error");
                    }
                }
                else
                {
                    error_lbl.Content = "Incorrect User Name & Passcode";
                }
                //string s2 = "ADMIN";
                //string s1 = "ADMIN@123";
                //string text = textBox1.Text.Trim();
                //string name1 = SecureMessage.Encrupt(s2, true);
                //string code1 = SecureMessage.Encrupt(s1, true);
                //OdbcCommand cmd = new OdbcCommand("UPDATE log_table set user_name='" + name + "',passcode='" + code + "' where designation='ADMIN'", con.conn);
                //cmd.ExecuteNonQuery();
                con.close_connection();
                //}
                //else
                //{
                //    expiry_panel.Visibility = System.Windows.Visibility.Visible;
                //}
            }
            catch
            {
                MessageBox.Show("Login Error");
            }
        }
コード例 #2
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            string user = Properties.Settings.Default.User;

            if (user == "ADMIN")
            {
                if (!String.IsNullOrEmpty(text.Text) && !String.IsNullOrEmpty(passtext.Password) && !String.IsNullOrEmpty(passtext1.Password))
                {
                    int i = passtext.Password.Length;
                    int j = passtext1.Password.Length;
                    if (i > 7 && j > 7)
                    {
                        if (passtext1.Password == passtext.Password)
                        {
                            if (combo.Text != "SELECT")
                            {
                                try
                                {
                                    Connection con = new Connection();
                                    con.open_connection();
                                    string      s2   = text.Text;
                                    string      s1   = passtext.Password;
                                    string      name = SecureMessage.Encrupt(s2, true);
                                    string      code = SecureMessage.Encrupt(s1, true);
                                    OdbcCommand cmd  = new OdbcCommand("insert into log_table (user_name,passcode,designation) values('" + name + "','" + code + "','" + combo.Text + "')", con.conn);
                                    cmd.ExecuteNonQuery();
                                    select();
                                    text.Text          = "";
                                    passtext.Password  = "";
                                    passtext1.Password = "";
                                    String s = combo.Items.GetItemAt(0).ToString();
                                    combo.Text = s.Substring(s.Length - 6, 6);
                                    con.close_connection();
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(ex.ToString());
                                }
                            }
                            else
                            {
                                MessageBox.Show("please choose the designation");
                            }
                        }
                        else
                        {
                            MessageBox.Show("confirm password not matching with  passsword");
                        }
                    }
                    else
                    {
                        MessageBox.Show("password should contain atleast 7 character");
                    }
                }
                else
                {
                    MessageBox.Show("please enter the details");
                }
            }
            else
            {
                MessageBox.Show("Permission Denied");
            }
        }
コード例 #3
0
        private void sign_in_btn_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                try
                {
                    //string dat = Properties.Settings.Default.date;
                    //DateTime d1 = Convert.ToDateTime(dat);
                    //DateTime d2 = DateTime.Now;
                    //int tot_day = (d1 - d2).Days;
                    //if(tot_day<=31&tot_day>=0)
                    //{

                    if (!string.IsNullOrWhiteSpace(user_name_txt.Text) & !string.IsNullOrWhiteSpace(user_password_txt.Password))
                    {
                        Connection con = new Connection();
                        con.open_connection();
                        OdbcCommand     cmd = new OdbcCommand("select user_name,passcode,designation from log_table WHERE DESIGNATION like '" + user_name_txt.Text + "' ", con.conn);
                        OdbcDataAdapter da  = new OdbcDataAdapter(cmd);
                        DataTable       dt  = new DataTable();
                        da.Fill(dt);
                        if (dt.Rows.Count > 0)
                        {
                            string s    = dt.Rows[0]["user_name"].ToString();
                            string p    = dt.Rows[0]["passcode"].ToString();
                            string name = SecureMessage.Decrypt(s, true);
                            string code = SecureMessage.Decrypt(p, true);
                            string ps   = user_password_txt.Password;
                            if (name.Equals(user_name_txt.Text) && ps.Equals(code))
                            {
                                Properties.Settings.Default.User = dt.Rows[0]["designation"].ToString();
                                Properties.Settings.Default.Save();
                                int    i  = Properties.Settings.Default.Counts;
                                string st = dt.Rows[0]["designation"].ToString();
                                user_name_txt.Text     = ""; user_password_txt.Password = "";
                                LOGIN_PANEL.Visibility = System.Windows.Visibility.Hidden;
                                t.Stop();
                                ribbon.Visibility    = Visibility.Visible;
                                home.Visibility      = Visibility.Visible;
                                User_Name.Content    = st;
                                dashboard.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                MessageBox.Show("Incorrect UserName & Password");
                                user_name_txt.Text = ""; user_password_txt.Password = "";
                            }
                        }
                        else
                        {
                            MessageBox.Show("User Details Not Exist");
                            user_name_txt.Text = ""; user_password_txt.Password = "";
                        }

                        con.close_connection();
                    }
                    else
                    {
                        error_lbl.Content  = "Please Enter User Name & Passcode";
                        user_name_txt.Text = ""; user_password_txt.Password = "";
                    }


                    //}
                    //else
                    //{
                    //    expiry_panel.Visibility = System.Windows.Visibility.Visible;
                    //}
                }
                catch
                {
                    MessageBox.Show("Login Error");
                }
            }
        }
コード例 #4
0
        private void ToggleButton_Click(object sender, RoutedEventArgs e)
        {
            string user = Properties.Settings.Default.User;

            if (user == "ADMIN")
            {
                if ((sender as ToggleButton).IsChecked ?? false)
                {
                    if (!string.IsNullOrWhiteSpace(text.Text))
                    {
                        Connection con = new Connection();
                        con.open_connection();
                        string          usr  = SecureMessage.Encrupt(text.Text, true);
                        OdbcCommand     cmd2 = new OdbcCommand("select designation from log_table where user_name='" + usr + "'", con.conn);
                        OdbcDataAdapter da   = new OdbcDataAdapter(cmd2);
                        DataTable       dt   = new DataTable();
                        da.Fill(dt);
                        if (dt.Rows.Count > 0)
                        {
                            combo.Text = dt.Rows[0]["designation"].ToString();
                        }
                        else
                        {
                            MessageBox.Show("User Detail Not Exist");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Enter User Name");
                        togglebtn.IsChecked = false;
                    }

                    //select();
                }
                else
                {
                    if (!String.IsNullOrEmpty(text.Text) && !String.IsNullOrEmpty(passtext.Password) && !String.IsNullOrEmpty(passtext1.Password))
                    {
                        int i = passtext.Password.Length;
                        int j = passtext1.Password.Length;
                        if (i > 7 && j > 7)
                        {
                            if (passtext1.Password == passtext.Password)
                            {
                                if (combo.Text != "SELECT")
                                {
                                    try
                                    {
                                        Connection con = new Connection();
                                        con.open_connection();
                                        OdbcCommand cmd2 = new OdbcCommand("update log_table set passcode='" + passtext.Password + "' where user_name='" + text.Text + "' AND designation='" + combo.Text + "'", con.conn);
                                        cmd2.ExecuteNonQuery();
                                        select();
                                        text.Text          = "";
                                        passtext.Password  = "";
                                        passtext1.Password = "";
                                        String s = combo.Items.GetItemAt(0).ToString();
                                        combo.Text = s.Substring(s.Length - 6, 6);
                                    }
                                    catch (Exception ex)
                                    {
                                        MessageBox.Show(ex.ToString());
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("please select the designation");
                                    togglebtn.IsChecked = true;
                                }
                            }
                            else
                            {
                                MessageBox.Show("password not matching");
                                togglebtn.IsChecked = true;
                            }
                        }
                        else
                        {
                            MessageBox.Show("password should contain atleast 7 character");
                            togglebtn.IsChecked = true;
                        }
                    }
                    else
                    {
                        MessageBox.Show("please enter the details");
                        togglebtn.IsChecked = true;
                    }
                }
            }
            else
            {
                MessageBox.Show("Permission Denied");
            }
        }