public void GetLogHistoryDetails()
 {
     try
     {
         Log_History_Manager objLogHistory       = new Log_History_Manager();
         NandanaResult       dsgethistorydetails = objLogHistory.GetLogHistoryDetails();
         if (!dsgethistorydetails.HasError && dsgethistorydetails.resultDS.Tables[0].Rows.Count > 0)
         {
             dgvLogHistory.DataSource = dsgethistorydetails.resultDS.Tables[0];
         }
         else
         {
             dgvLogHistory.DataSource = null;
         }
     }
     catch (Exception x)
     {
         MessageBox.Show(x.Message, "Error While retriving data from GetLogHistoryDetails SP");
     }
 }
 private void btnSearch_Click(object sender, EventArgs e)
 {
     pnlError.Visible = false;
     if (dtpLogDate.Value != null && cmbType.Text != "-Select Type-" && cmbType.Text != string.Empty)
     {
         try
         {
             Log_History_Manager objLogHistory = new Log_History_Manager();
             NandanaResult       dsgethistorydetailsusingDate = objLogHistory.GetLogHistoryDetailsGO(dtpLogDate.Value.ToString("dd-MM-yyyy"));
             if (!dsgethistorydetailsusingDate.HasError && dsgethistorydetailsusingDate.resultDS.Tables[0].Rows.Count > 0)
             {
                 if (cmbType.Text != "-Select Type-" && cmbType.Text.Length != 0)
                 {
                     DataView dv = new DataView(dsgethistorydetailsusingDate.resultDS.Tables[0]);
                     dv.RowFilter = "Type='" + cmbType.Text.ToUpper() + "'";
                     if (dv.Count > 0)
                     {
                         dgvLogHistory.DataSource = dv;
                     }
                     else
                     {
                         pnlError.Visible         = true;
                         pnlError.Location        = new Point((this.Width - pnlError.ClientSize.Width) / 2, 12);
                         pnlError.BackColor       = System.Drawing.ColorTranslator.FromHtml("#f5b7b7");
                         lblErrorMsg.Text         = "No results found, try a new search.";
                         lblErrorMsg.Location     = new Point((pnlError.Width - lblErrorMsg.ClientSize.Width) / 2, (pnlError.Height - lblErrorMsg.ClientSize.Height) / 2);
                         dgvLogHistory.DataSource = null;
                     }
                 }
                 else
                 {
                     dgvLogHistory.DataSource = dsgethistorydetailsusingDate.resultDS.Tables[0];
                 }
             }
             else
             {
                 pnlError.Visible         = true;
                 pnlError.Location        = new Point((this.Width - pnlError.ClientSize.Width) / 2, 12);
                 pnlError.BackColor       = System.Drawing.ColorTranslator.FromHtml("#f5b7b7");
                 lblErrorMsg.Text         = "No results found, try a new search.";
                 lblErrorMsg.Location     = new Point((pnlError.Width - lblErrorMsg.ClientSize.Width) / 2, (pnlError.Height - lblErrorMsg.ClientSize.Height) / 2);
                 dgvLogHistory.DataSource = null;
             }
         }
         catch (Exception x)
         {
             MessageBox.Show(x.Message, "Error While retriving data from GetLogHistoryDetailsGO SP");
         }
     }
     else if (cmbType.Text == "-Select Type-" || cmbType.Text == string.Empty)
     {
         lblErrorMsg.Visible = false;
         try
         {
             Log_History_Manager objLogHistory = new Log_History_Manager();
             NandanaResult       dsgethistorydetailsusingDate = objLogHistory.GetLogHistoryDetailsGO(dtpLogDate.Value.ToString("dd-MM-yyyy"));
             if (!dsgethistorydetailsusingDate.HasError && dsgethistorydetailsusingDate.resultDS.Tables[0].Rows.Count > 0)
             {
                 dgvLogHistory.DataSource = dsgethistorydetailsusingDate.resultDS.Tables[0];
             }
             else
             {
                 pnlError.Visible         = true;
                 pnlError.Location        = new Point((this.Width - pnlError.ClientSize.Width) / 2, 12);
                 pnlError.BackColor       = System.Drawing.ColorTranslator.FromHtml("#f5b7b7");
                 lblErrorMsg.Text         = "No results found, try a new search.";
                 lblErrorMsg.Location     = new Point((pnlError.Width - lblErrorMsg.ClientSize.Width) / 2, (pnlError.Height - lblErrorMsg.ClientSize.Height) / 2);
                 dgvLogHistory.DataSource = null;
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error while Retrieving Data from GetLogHistoryDetailsGO SP");
         }
     }
 }
Exemplo n.º 3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            bool status = true;

            lblError.Visible = false;
            if (txtusername.Text == string.Empty || txtusername.Text == "Username")
            {
                //MessageBox.Show("Please Enter User Name");
                lblError.Visible = true;
                lblError.Text    = "Username is required";
                status           = false;
                txtusername.Focus();
                return;
            }
            if (txtpassword.Text == string.Empty || txtpassword.Text == "Password")
            {
                //MessageBox.Show("Please Enter Password");
                lblError.Visible = true;
                lblError.Text    = "Password is required";
                status           = false;
                txtpassword.Focus();
                return;
            }
            //if (cmbUserType.Text == string.Empty || cmbUserType.Text == " UserType ")
            //{
            //    MessageBox.Show("Please Select User Type");
            //    status = false;
            //    cmbUserType.Focus();
            //    return;
            //}
            if (!status)
            {
                MessageBox.Show("Please enter required data");
            }
            else
            {
                cmbUserType.Text = "admin";
                //bool matchFound = false;
                System.Configuration.ConfigurationSettings.AppSettings["UserName"] = txtusername.Text;

                try
                {
                    String strRoleId = string.Empty;
                    String strUserId = string.Empty;


                    //MySqlConnection con = new MySqlConnection(System.Configuration.ConfigurationSettings.AppSettings["MYSQL_ConnString"]);
                    //con.Open();
                    //MySqlCommand cmd = new MySqlCommand("sp_Users", con);
                    //cmd.CommandType = CommandType.StoredProcedure;
                    //cmd.Parameters.Add(new MySqlParameter("User_Name", txtusername.Text.Trim()));
                    //cmd.Parameters.Add(new MySqlParameter("Password", txtpassword.Text.Trim()));
                    //cmd.Parameters.Add(new MySqlParameter("Role_Name", cmbUserType.Text));

                    //MySqlDataReader dr = cmd.ExecuteReader();
                    //if (dr.Read())
                    //{
                    //    //strUserId = Convert.ToString(((((MySql.Data.MySqlClient.MySqlDataReader)(dr))).ResultSet.Values[0]).Value);
                    //    //strRoleId = Convert.ToString(((((MySql.Data.MySqlClient.MySqlDataReader)(dr))).ResultSet.Values[3]).Value);

                    //    System.Configuration.ConfigurationSettings.AppSettings["RoleID"] = strRoleId;

                    //    AssignConfigParamValues(strRoleId, strUserId);

                    //    //CheckScanDocCountValue();
                    //    //CheckLicenseExpired();

                    //    NewMenu objAdminHomePage = new NewMenu();
                    //    objAdminHomePage.Show();
                    //    this.Hide();
                    //}
                    //con.Close();

                    UserManager   objUserManager = new UserManager();
                    NandanaResult dsUserData     = objUserManager.GetUserDetailsByCredentials(txtusername.Text.Trim(), this.Encrypt(txtpassword.Text.Trim()));
                    if (!dsUserData.HasError && dsUserData.resultDS.Tables[0].Rows.Count > 0)
                    {
                        strRoleId = Convert.ToString(dsUserData.resultDS.Tables[0].Rows[0]["Role_ID"]);
                        strUserId = Convert.ToString(dsUserData.resultDS.Tables[0].Rows[0]["User_ID"]);
                        System.Configuration.ConfigurationSettings.AppSettings["RoleID"] = strRoleId;
                        System.Configuration.ConfigurationSettings.AppSettings["UserID"] = strUserId;

                        //* inserting log details in log table *//
                        string currentSystemName = Environment.MachineName;
                        string Description       = "User logged in the applicaton from " + currentSystemName + ".";
                        string PresentDateTime   = DateTime.Now.ToString("dd-MM-yyyy h:mm:ss tt");
                        string presentdate       = DateTime.Now.ToString("dd-MM-yyyy");
                        string Type = "Login";
                        Log_History_Manager objLogHistoryManager = new Log_History_Manager();
                        NandanaResult       ival = objLogHistoryManager.InsertLogHistoryDetails((DateTime.Now.ToString("dd-MM-yyyy h:mm:ss tt")), txtusername.Text.Trim(), Description.Trim(), Type.Trim(), (DateTime.Now.ToString("dd-MM-yyyy")));
                        //* End  *//

                        AssignConfigParamValues(strRoleId, strUserId);

                        CheckScanDocCountValue();
                        GetConfigValuesOfIsExpired();
                        CheckLicenseExpired();

                        NewMenu objAdminHomePage = new NewMenu();
                        objAdminHomePage.Show();
                        this.Hide();
                    }
                    else
                    {
                        lblError.Visible = true;
                        lblError.Text    = "Invalid Username or Password";
                    }
                }
                catch (Exception ex)
                {
                    //return (new (ErrorHandling.ErrorType.ERR_RETRIEVING_DATA, "Error While retrieving data from users xml.", ex));
                    MessageBox.Show(ex.Message, "Error While retriving data from Users");
                }
            }
        }