Ejemplo n.º 1
0
    private void GetMenuData()
    {
        SqlConnection conMyConnection = new SqlConnection(); //new SqlConnection(ConfigurationManager.AppSettings.Get("ConnectionString"));

        conMyConnection.ConnectionString = objCCWeb.ReturnConnectionString();
        conMyConnection.Open();
        DataTable table = new DataTable();
        string    sql   = "Select RollNumber menu_id,MenuCaption1 menu_name,menu_Parent_Id,MenuLinkPage menu_url from MTUserMenuMaster where ModuleID <11 and moduleid not in(4,7,8) ";
        //"select menu_id, menu_name, menu_parent_id, menu_url from menuMaster";
        SqlCommand     cmd = new SqlCommand(sql, conMyConnection);
        SqlDataAdapter da  = new SqlDataAdapter(cmd);

        da.Fill(table);
        DataView view = new DataView(table);

        view.RowFilter = "menu_parent_id is NULL";
        foreach (DataRowView row in view)
        {
            MenuItem menuItem = new MenuItem(row["menu_name"].ToString(), row["menu_id"].ToString());
            menuItem.NavigateUrl = row["menu_url"].ToString();
            NavigationMenu.Items.Add(menuItem);
            AddChildItems(table, menuItem);
        }
    }
Ejemplo n.º 2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string strResult   = "";
        int    intSchoolID = 0;

        string[] strArray = this.hidFlag.Value.Split('^');
        try
        {
            List <string> lstArray  = new List <string>();
            byte[]        fileData  = null;
            byte[]        imageData = null;

            long lnLength = 0;

            fUploadEmblem.Attributes["filename"] = hdnSImagePath.Value;
            if (fUploadEmblem.PostedFile.FileName != "")
            {
                if (fUploadEmblem.HasFile)
                {
                    try
                    {
                        Stream myStream = fUploadEmblem.PostedFile.InputStream;
                        lnLength = myStream.Length;
                        fileData = new byte[(int)myStream.Length];
                        myStream.Read(fileData, 0, (int)lnLength);
                        myStream.Close();
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            string strEmblemStatus;
            if (rbtnYes.Checked == true)
            {
                strEmblemStatus = "Y";
            }
            else
            {
                strEmblemStatus = "N";
            }
            //if (strArray[0] == "N" || strArray[0]=="E" && strArray[3].Trim().ToUpper() != txtAddress.Text.Trim().ToUpper())
            //{
            //    if (objCCWeb.ReturnNumericValue("SELECT COUNT(SchoolID) FROM MTClientCompany WHERE Address='" + txtAddress.Text.Trim().Replace("'", "''") + "'") > 0)
            //    {
            //        strResult = objCCWeb.pDisplayMessage("" + Session["Type"].ToString() + "", "5", lblAddress.Text);
            //        ClientScript.RegisterStartupScript(this.GetType(), "", "<script>" + strHideID + "alert('" + strResult + "')</script>");
            //        //ClientScript.RegisterStartupScript(this.GetType(), "", "<script>" + strHideID + "alert('Address Already Exist')</script>");
            //        hidFlag.Value = "S";
            //        return;
            //    }
            //}
            if (strArray[0] == "E")
            {
                lstArray.Add("UPDATE MTClientCompany SET SchoolName1=" + objCCWeb.fReplaceChar(txtInstitution1) + ",SchoolName2='" + txtInstitution2.Text.Trim().Replace("'", "''") + "',Address=" + objCCWeb.fReplaceChar(txtAddress) + ",ReportHeader=" + objCCWeb.fReplaceChar(txtReportHeader) +
                             ",City=" + objCCWeb.fReplaceChar(txtCity) + ",State=" + objCCWeb.fReplaceChar(txtState) + ",Pincode=" + objCCWeb.fReplaceChar(txtPincode) + ",Telephone=" + objCCWeb.fReplaceChar(txtTelephone) + "," +
                             "Fax=" + objCCWeb.fReplaceChar(txtFax) + ",Email=" + objCCWeb.fReplaceChar(txtEmail) + ",DirectorName=" + objCCWeb.fReplaceChar(txtDirector) + ",DirectorTelephone=" + objCCWeb.fReplaceChar(txtDirPhone) +
                             ",PrincipalName=" + objCCWeb.fReplaceChar(txtPrincipal) + ",PrincipalPhone=" + objCCWeb.fReplaceChar(txtPriPhone) + ",VicePrincipalName=" + objCCWeb.fReplaceChar(txtVicePrincipal) + "," +
                             "VicePrincipalPhone=" + objCCWeb.fReplaceChar(txtVicePriPhone) + ",AdministratorName=" + objCCWeb.fReplaceChar(txtAdministrator) + ",AdministratorPhone=" + objCCWeb.fReplaceChar(txtAdmPhone) + ",Affiliation=" + objCCWeb.fReplaceChar(txtAffiliation) +
                             ",Medium=" + objCCWeb.fReplaceChar(txtMedium) + ",Motto=" + objCCWeb.fReplaceChar(txtMotto) + ",EstablishedOn=" + objCCWeb.fReplaceChar(txtEstablishedOn) + ",EstablishmentCode=" + objCCWeb.fReplaceChar(txtEstablishmentCode) + "," +
                             "BankAccountNo=" + objCCWeb.fReplaceChar(txtBankACNo) + ",EmblemStatus='" + strEmblemStatus + "',UpdateUserID=" + Session["UID"].ToString() + ",UpdateDate=GETDATE(),PLPackDate=" + objCCWeb.ReturnDateorNull(txtPLPackDate.Text.Trim()) + ",PLPackdateStaff=" + objCCWeb.ReturnDateorNull(txtPLPackDateStaff.Text.Trim()) + " WHERE SchoolID=" + strArray[1] + "");

                lstArray.Add("INSERT INTO UserUpdateDetails(UID,SessionID,UpdateDate,FormName,Details) VALUES(" + Session["UID"] + ",'" + Session.SessionID + "',GETDATE(),'mnuInstitutionMaster','School " + (txtInstitution1.Text.Trim().Replace("'", "''") != "" ? txtInstitution1.Text.Trim().Replace("'", "''") : txtInstitution2.Text.Trim().Replace("'", "''")) + " Information ,Is Modified')");
            }
            else
            {
                intSchoolID = objCCWeb.ReturnNumericValue("SELECT ISNULL(MAX(SchoolID),0)+1 FROM MTClientCompany");

                lstArray.Add("INSERT INTO MTClientCompany(SchoolID,SchoolName1,SchoolName2,Address,ReportHeader,City,State,Pincode,Telephone,Fax,Email,DirectorName,DirectorTelephone,PrincipalName,PrincipalPhone,VicePrincipalName,VicePrincipalPhone,AdministratorName,AdministratorPhone," +
                             "Affiliation,Medium,Motto,EstablishedOn,EstablishmentCode,BankAccountNo,EmblemStatus,EntryUserID,EntryDate) SELECT ISNULL(MAX(SchoolID),0)+1, '" + txtInstitution1.Text.Trim().Replace("'", "''") + "','" + txtInstitution2.Text.Trim().Replace("'", "''") + "','" + txtAddress.Text.Trim().Replace("'", "''") + "','" + txtReportHeader.Text.Trim().Replace("'", "''") +
                             "','" + txtCity.Text.Trim().Replace("'", "''") + "','" + txtState.Text.Trim().Replace("'", "''") + "','" + txtPincode.Text.Trim().Replace("'", "''") + "','" + txtTelephone.Text.Trim().Replace("'", "''") + "'," +
                             "'" + txtFax.Text.Trim().Replace("'", "''") + "','" + txtEmail.Text.Trim().Replace("'", "''") + "','" + txtDirector.Text.Trim().Replace("'", "''") + "','" + txtDirPhone.Text.Trim().Replace("'", "''") +
                             "','" + txtPrincipal.Text.Trim().Replace("'", "''") + "','" + txtPriPhone.Text.Trim().Replace("'", "''") + "','" + txtVicePrincipal.Text.Trim().Replace("'", "''") + "'," +
                             "'" + txtVicePriPhone.Text.Trim().Replace("'", "''") + "','" + txtAdministrator.Text.Trim().Replace("'", "''") + "','" + txtAdmPhone.Text.Trim().Replace("'", "''") + "','" + txtAffiliation.Text.Trim().Replace("'", "''") +
                             "','" + txtMedium.Text.Trim().Replace("'", "''") + "','" + txtMotto.Text.Trim().Replace("'", "''") + "','" + txtEstablishedOn.Text.Trim().Replace("'", "''") + "','" + txtEstablishmentCode.Text.Trim().Replace("'", "''") + "'," +
                             "'" + txtBankACNo.Text.Trim().Replace("'", "''") + "','" + strEmblemStatus + "'," + Session["UID"].ToString() + ",GETDATE() FROM MTClientCompany");
            }
            strResult = objCCWeb.ExecuteQueryList(lstArray);
            if (strArray[0] == "E")
            {
                intSchoolID = Convert.ToInt32(strArray[1]);
            }

            if (hidFlag.Value == "N^")
            {
                hidFlag.Value = "N^";
            }
            else
            {
                hidFlag.Value = "E^";
            }
            if (strResult == "")
            {
                if (lnLength > 0)
                {
                    //SqlConnection conSImage = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings.Get("ConnectionString"));
                    SqlConnection conSImage = new SqlConnection(objCCWeb.ReturnConnectionString());
                    conSImage.Open();
                    SqlCommand cmdSImage = new SqlCommand("UPDATE MTClientCompany SET Emblem=@img,EmblemLength=" + lnLength.ToString() + " where SchoolID=" + intSchoolID + "", conSImage);
                    cmdSImage.CommandType = CommandType.Text;
                    cmdSImage.Parameters.Add(new SqlParameter("@img", SqlDbType.Image));
                    cmdSImage.Parameters["@img"].Value = fileData;
                    cmdSImage.ExecuteNonQuery();
                    conSImage.Close();
                    conSImage.Dispose();
                }
                if (lnLength == 0)
                {
                    if (strArray[0] == "E")
                    {
                        SqlDataReader rdrImage = objCCWeb.BindReader("SELECT ISNULL(Emblem,'') AS Emblem,CAST(ISNULL(EmblemLength,0) AS INT) AS EmblemLength FROM MTClientCompany WHERE SchoolID=" + intSchoolID + "");
                        if (rdrImage.Read())
                        {
                            int intLength = (int)rdrImage["EmblemLength"];
                            imageData = new byte[intLength];
                            imageData = (byte[])rdrImage["Emblem"];
                            if (intLength != 0)
                            {
                                lnLength = intLength;
                            }
                        }
                        rdrImage.Close();
                        rdrImage.Dispose();
                    }
                }
                if (strArray[0] == "N")
                {
                    strResult = objCCWeb.pDisplayMessage("" + Session["Type"].ToString() + "", "1", "");
                }
                else
                {
                    strResult = objCCWeb.pDisplayMessage("" + Session["Type"].ToString() + "", "2", "");
                }
                ClientScript.RegisterStartupScript(this.GetType(), "displayScriptMsg", "<script>" + strHideID + "alert('" + strResult + "')</script>");
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "displayE", "<script language=javascript>" + strHideID + "alert('" + strResult + "')</script>");
            }
            if (fUploadEmblem.PostedFile.FileName == "")
            {
                fileData = imageData;
            }
            btnCancel_Click(sender, e);
        }
        catch (Exception ex)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "displayScript", "<script language=javascript>" + strHideID + "alert('" + ex.Message + "')</script>");
        }
        BindDDL();
        btnCancel_Click(sender, e);
    }
Ejemplo n.º 3
0
    protected void Authenticate(AuthenticateEventArgs e)
    {
        SqlConnection conExecute = new SqlConnection(objCCWeb.ReturnConnectionString().ToString());

        try
        {
            string strUserName, strPwd;
            strUserName = Login1.UserName;
            strPwd      = ((TextBox)Login1.FindControl("Password")).Text;

            /* Authenticating the User Through Procedure */
            SqlCommand cmdExecute = new SqlCommand("sp_AuthenticateUser", conExecute);
            cmdExecute.CommandType = CommandType.StoredProcedure;
            SqlParameter param1 = new SqlParameter();
            param1.ParameterName = "@varUserID";
            param1.SqlDbType     = SqlDbType.VarChar;
            param1.Size          = 30;
            param1.Direction     = ParameterDirection.Input;
            param1.Value         = Login1.UserName.Replace("'", "''");

            cmdExecute.Parameters.Add(param1);

            SqlParameter param2 = new SqlParameter();
            param2.ParameterName = "@varUserPwd";
            param2.SqlDbType     = SqlDbType.VarChar;
            param2.Size          = 60;
            param2.Direction     = ParameterDirection.Input;
            param2.Value         = strPwd;

            cmdExecute.Parameters.Add(param2);

            SqlParameter param3 = new SqlParameter();
            param3.ParameterName = "@varUserSalt";
            param3.SqlDbType     = SqlDbType.VarChar;
            param3.Size          = 10;
            param3.Direction     = ParameterDirection.Input;
            param3.Value         = hid.Value;

            cmdExecute.Parameters.Add(param3);
            conExecute.Open();

            SqlDataReader sdrLogin = cmdExecute.ExecuteReader();

            /* THIS READERS RETURNS THESE VALUES
             *  ValidUser,
             *  UID,
             *  UserID,
             *  UserName,
             *  UserTypeID,
             *  EmployeeIDStudentID
             */
            //((MSCaptcha.CaptchaControl)Login1.FindControl("ccJoin")).ValidateCaptcha(((TextBox)Login1.FindControl("txtCapText")).Text);
            //Login1.FailureText = "Incorrect Code";

            //  if (!((MSCaptcha.CaptchaControl)Login1.FindControl("ccJoin")).UserValidated)
            //  {
            Login1.FailureText = "Invalid User Name or Password";

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


                if (sdrLogin.GetValue(sdrLogin.GetOrdinal("ValidUser")).ToString() == "1")
                {
                    Session["UserID"]          = sdrLogin.GetValue(sdrLogin.GetOrdinal("UserID"));
                    Session["UID"]             = sdrLogin.GetValue(sdrLogin.GetOrdinal("UID"));
                    Session["UserName"]        = sdrLogin.GetValue(sdrLogin.GetOrdinal("UserName"));
                    Session["AcaStart"]        = ((DropDownList)Login1.FindControl("ddlAcademicYear")).SelectedValue;
                    Session["AcademicSession"] = ((DropDownList)Login1.FindControl("ddlAcademicYear")).SelectedValue + "-" + Convert.ToInt32(Convert.ToInt32(((DropDownList)Login1.FindControl("ddlAcademicYear")).SelectedValue) + 1);
                    Session["Type"]            = "1";

                    if (Session["SchoolID"] == null)
                    {
                        //if (objCCWeb.ReturnNumericValue("SELECT Count(SchoolID) FROM MTUserInstitutionMaster WHERE UID=" + Session["UID"] + "") > 1)
                        //{
                        //    Login1.DestinationPageUrl = "~/MTChangeSchool.aspx";
                        //}
                        //else
                        //{
                        if (sdrLogin.GetValue(sdrLogin.GetOrdinal("UserTypeID")).ToString() == "3" && hdnFlag.Value == "3")
                        {
                            Session["ParentID"] = sdrLogin.GetValue(sdrLogin.GetOrdinal("EmployeeIDStudentID")).ToString();
                            if (objCCWeb.ReturnNumericValue("Select count(SYD.StudentID)  from Sistudentmaster SM inner join sistudentyearwisedetails SYD on SM.StudentID=SYD.StudentID where ParentID='" + Session["ParentID"] + "' AND StudentStatus='S' AND AcaStart=" + Session["AcaStart"] + " ") > 0)
                            {
                                Login1.DestinationPageUrl = "~/PlParentLoginForm.aspx";
                                //  Login1.DestinationPageUrl = "~/SchoolOnline/Default.aspx";
                            }
                            else
                            {
                                //  Login1.DestinationPageUrl = "~/SchoolOnline/Default.aspx";
                                Login1.DestinationPageUrl = "~/PlParentLoginForm.aspx";
                                ClientScript.RegisterStartupScript(this.GetType(), "displayScript", "<script>alert('Student  does not exist in this Session');</script>");
                                return;
                            }
                            Session["SchoolID"]   = objCCWeb.ReturnNumericValue("Select SchoolID from SIStudentMaster Where ParentID IN (Select employeeIDStudentID from MTUserMaster Where UID=" + Session["UID"] + ")");
                            Session["SchoolName"] = objCCWeb.ReturnSingleValue("SELECT ISNULL(MAX(SchoolName1),'CampusCare') FROM MTClientCompany WHERE SchoolID=" + Session["SchoolID"] + "") + " :: " + Session["AcademicSession"];
                        }
                        else if (sdrLogin.GetValue(sdrLogin.GetOrdinal("UserTypeID")).ToString() == "2" && hdnFlag.Value == "2")
                        {
                            Session["StudentID"] = sdrLogin.GetValue(sdrLogin.GetOrdinal("EmployeeIDStudentID")).ToString();
                            if (objCCWeb.ReturnNumericValue("Select count(SYD.StudentID)  from Sistudentmaster SM inner join sistudentyearwisedetails SYD on SM.StudentID=SYD.StudentID where SM.StudentID='" + Session["StudentID"] + "' AND StudentStatus='S' AND AcaStart=" + Session["AcaStart"] + " ") > 0)
                            {
                                Login1.DestinationPageUrl = "~/PlParentLoginForm.aspx";
                            }
                            else
                            {
                                Login1.DestinationPageUrl = "~/PlParentLoginForm.aspx";
                                ClientScript.RegisterStartupScript(this.GetType(), "displayScript", "<script>alert('Student  does not exist in this Session');</script>");
                                return;
                            }
                            Session["SchoolID"]   = objCCWeb.ReturnNumericValue("Select SchoolID from SIStudentMaster Where StudentID IN (Select employeeIDStudentID from MTUserMaster Where UID=" + Session["UID"] + ")");
                            Session["SchoolName"] = objCCWeb.ReturnSingleValue("SELECT ISNULL(MAX(SchoolName1),'Campus Care') FROM MTClientCompany WHERE SchoolID=" + Session["SchoolID"] + "") + " :: " + Session["AcademicSession"];
                        }
                        else if (sdrLogin.GetValue(sdrLogin.GetOrdinal("UserTypeID")).ToString() == "1" && hdnFlag.Value == "1")
                        {
                            Session["EmployeeID"]     = sdrLogin.GetValue(sdrLogin.GetOrdinal("EmployeeIDStudentID")).ToString();
                            Login1.DestinationPageUrl = "~/EmployeeLogin.aspx";
                            Session["UserType"]       = "1";
                            Session["SchoolID"]       = objCCWeb.ReturnNumericValue("Select SchoolID from PRLEmployeeMaster Where PRLEmployeeID IN (Select employeeIDStudentID from MTUserMaster Where UID=" + Session["UID"] + ")");
                            Session["SchoolName"]     = objCCWeb.ReturnSingleValue("SELECT ISNULL(MAX(SchoolName1),'Campus Care') FROM MTClientCompany WHERE SchoolID=" + Session["SchoolID"] + "") + " :: " + Session["AcademicSession"];
                        }
                        else if (sdrLogin.GetValue(sdrLogin.GetOrdinal("UserTypeID")).ToString() == "4" && hdnFlag.Value == "1")
                        {
                            Login1.DestinationPageUrl = "~/PlManagementLogin.aspx";
                            Session["SchoolID"]       = "1";
                            Session["SchoolName"]     = objCCWeb.ReturnSingleValue("SELECT ISNULL(MAX(SchoolName1),'Campus Care') FROM MTClientCompany WHERE SchoolID=" + Session["SchoolID"] + "") + " :: " + Session["AcademicSession"];
                        }
                        else if (sdrLogin.GetValue(sdrLogin.GetOrdinal("UserTypeID")).ToString() == "6" && hdnFlag.Value == "6")
                        {
                            Session["PID"] = objCCWeb.ReturnNumericValue("Select EmployeeIDStudentID from MTUserMaster Where UserID='" + Login1.UserName.Replace("'", "''") + "'  AND UserTypeID=6");
                            string UserID = objCCWeb.ReturnSingleValue("Select Case when UserId like 'SE%' then 'SE' else 'SR' end as UserID  from MTUserMaster Where UserID='" + Login1.UserName.Replace("'", "''") + "'  AND UserTypeID=6");

                            if (UserID == "SE")
                            {
                                Login1.DestinationPageUrl = "~/SRStudentonlineRegistration11.aspx";
                            }
                            else
                            {
                                Login1.DestinationPageUrl = "~/SRStudentonlineRegistration.aspx";
                            }
                            Session["SchoolID"]   = objCCWeb.ReturnNumericValue("Select SchoolID from MTClientCompany");
                            Session["AcaStart"]   = objCCWeb.ReturnNumericValue("Select MAX(AcaStart)from MTAcademicsessionmaster");
                            Session["SchoolName"] = objCCWeb.ReturnSingleValue("SELECT ISNULL(MAX(SchoolName1),'CampusCare') FROM MTClientCompany WHERE SchoolID=" + Session["SchoolID"] + "") + "";    // :: " + Session["AcademicSession"];
                        }
                        else if (sdrLogin.GetValue(sdrLogin.GetOrdinal("UserTypeID")).ToString() == "0" && hdnFlag.Value == "0")
                        {
                            Login1.DestinationPageUrl = "~/Default.aspx";
                            Session["SchoolID"]       = objCCWeb.ReturnNumericValue("SELECT ISNULL(MAX(SchoolID),1) FROM MTUserInstitutionMaster WHERE UId=" + Session["UID"] + "");
                            Session["SchoolName"]     = objCCWeb.ReturnSingleValue("SELECT ISNULL(MAX(SchoolName1),'CampusCare') FROM MTClientCompany WHERE SchoolID=" + Session["SchoolID"] + "") + "";      //:: " + Session["AcademicSession"];
                        }
                        else
                        {
                            Session["UserLogin"] = Session.SessionID;
                            string strUserID = objCCWeb.ReturnSingleValue("SELECT UID FROM MTUsermaster where UserID='" + strUserName + "'");
                            if (strUserID != "")
                            {
                                objCCWeb.ExecuteQuery("INSERT INTO MDUserLoginDetails(UID,IPAddress,LoginTime,SessionDetails,UserAgent,Referrer,URL,LoggedOutTime,LoginSuccessStatus) VALUES ('" + strUserID + "','" +
                                                      Request.ServerVariables.Get("remote_addr").ToString() + "',GETDATE(),'" + Session.SessionID.ToString() + "','" + hidBrsr.Value.Trim().ToString() + "','" + Request.UrlReferrer.ToString() + "','" + Request.Url.ToString() + "',null,'N')");//"+Process.GetCurrentProcess().Id.ToString()+"
                            }
                            else
                            {
                                objCCWeb.ExecuteQuery("INSERT INTO MDUserLoginDetails(UID,IPAddress,LoginTime,SessionDetails,UserAgent,Referrer,URL,LoggedOutTime,LoginSuccessStatus) VALUES (0,'" +
                                                      Request.ServerVariables.Get("remote_addr").ToString() + "',GETDATE(),'" + Session.SessionID.ToString() + "','" + hidBrsr.Value.Trim().ToString() + "','" + Request.UrlReferrer.ToString() + "','" + Request.Url.ToString() + "',null,'N')");//"+Process.GetCurrentProcess().Id.ToString()+"
                            }
                            e.Authenticated = false;
                            Session.Clear();
                            hdnFlag.Value = hdnFlag.Value + "^N";
                            return;
                        }
                        //}
                    }
                    Session["UserLogin"] = Session.SessionID;
                    objCCWeb.ExecuteQuery("INSERT INTO MDUserLoginDetails(UID,IPAddress,LoginTime,SessionDetails,UserAgent,Referrer,URL,LoggedOutTime,LoginSuccessStatus) VALUES (" + sdrLogin.GetValue(sdrLogin.GetOrdinal("UID")) +
                                          ",'" + Request.ServerVariables.Get("remote_addr").ToString() + "',GETDATE(),'" + Session.SessionID.ToString() + "','" + hidBrsr.Value.Trim().ToString() + "','" + Request.UrlReferrer.ToString() + "','" + Request.Url.ToString() + "',null,'Y')");//"+Process.GetCurrentProcess().Id.ToString()+"
                    Session["LoginID"] = objCCWeb.ReturnSingleValue("SELECT MAX(LoginID) FROM MDUSerLoginDetails WHERE UID=" + Session["UID"] + " AND LoginSuccessStatus='Y' ");

                    Session.Timeout = 30;
                    e.Authenticated = true;
                }
                else
                {
                    Session["UserLogin"] = Session.SessionID;
                    objCCWeb.ExecuteQuery("INSERT INTO MDUserLoginDetails(UID,IPAddress,LoginTime,SessionDetails,UserAgent,Referrer,URL,LoggedOutTime,LoginSuccessStatus) VALUES (" + sdrLogin.GetValue(sdrLogin.GetOrdinal("UID")) +
                                          ",'" + Request.ServerVariables.Get("remote_addr").ToString() + "',GETDATE(),'" + Session.SessionID.ToString() + "','" + hidBrsr.Value.Trim().ToString() + "','" + Request.UrlReferrer.ToString() + "','" + Request.Url.ToString() + "',null,'N')");//"+Process.GetCurrentProcess().Id.ToString()+"
                    e.Authenticated = false;
                }
            }
            else
            {
                Session["UserLogin"] = Session.SessionID;
                objCCWeb.ExecuteQuery("INSERT INTO MDUserLoginDetails(UID,IPAddress,LoginTime,SessionDetails,UserAgent,Referrer,URL,LoggedOutTime,LoginSuccessStatus) VALUES (0,'" +
                                      Request.ServerVariables.Get("remote_addr").ToString() + "',GETDATE(),'" + Session.SessionID.ToString() + "','" + hidBrsr.Value.Trim().ToString() + "','" + Request.UrlReferrer.ToString() + "','" + Request.Url.ToString() + "',null,'N')");//"+Process.GetCurrentProcess().Id.ToString()+"
                e.Authenticated = false;
            }
            //}
            //else
            //{
            //    Session["UserLogin"] = Session.SessionID;
            //    string strUserID = objCCWeb.ReturnSingleValue("SELECT UID FROM MTUsermaster where UserID='" + strUserName + "'");
            //    if (strUserID != "")
            //    {
            //        objCCWeb.ExecuteQuery("INSERT INTO MDUserLoginDetails(UID,IPAddress,LoginTime,SessionDetails,UserAgent,Referrer,URL,LoggedOutTime,LoginSuccessStatus) VALUES ('" + strUserID + "','" +
            //         Request.ServerVariables.Get("remote_addr").ToString() + "',GETDATE(),'" + Session.SessionID.ToString() + "','" + hidBrsr.Value.Trim().ToString() + "','" + Request.UrlReferrer.ToString() + "','" + Request.Url.ToString() + "',null,'N')");//"+Process.GetCurrentProcess().Id.ToString()+"
            //    }
            //    else
            //    {
            //        objCCWeb.ExecuteQuery("INSERT INTO MDUserLoginDetails(UID,IPAddress,LoginTime,SessionDetails,UserAgent,Referrer,URL,LoggedOutTime,LoginSuccessStatus) VALUES (0,'" +
            //                   Request.ServerVariables.Get("remote_addr").ToString() + "',GETDATE(),'" + Session.SessionID.ToString() + "','" + hidBrsr.Value.Trim().ToString() + "','" + Request.UrlReferrer.ToString() + "','" + Request.Url.ToString() + "',null,'N')");//"+Process.GetCurrentProcess().Id.ToString()+"
            //    }
            //    e.Authenticated = false;
            //}
            sdrLogin.Close();
            sdrLogin.Dispose();
        }
        catch (Exception ex)
        {
        }
        finally
        {
            conExecute.Close();
            conExecute.Dispose();
        }
        //  Login1.FailureText = "Invalid User Name or Password Or Check Correct Login Type";
        hdnFlag.Value = hdnFlag.Value + "^N";
        ClientScript.RegisterStartupScript(this.GetType(), "displ", "<script language='javascript'> document.getElementById('" + txtPosition.Text.Trim() + "').click();</script>");
    }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UID"] == null)
        {
            Response.Write("<script>window.close();window.open('Logon.aspx','_parent');</script>");
            return;
        }
        if (!IsPostBack)
        {
            //SqlConnection conMyConnection = new SqlConnection(ConfigurationManager.AppSettings.Get("ConnectionString"));
            //conMyConnection.Open();
            SqlConnection conMyConnection = new SqlConnection(); //new SqlConnection(ConfigurationManager.AppSettings.Get("ConnectionString"));
            conMyConnection.ConnectionString = objCCWeb.ReturnConnectionString();
            conMyConnection.Open();
            SqlCommand    cmdMyCommand = new SqlCommand("SELECT MM.ModuleName,UM.MenuCaption,LEN(UM.MenuLevel) AS MenuLevel,UM.MenuLinkPage,UM.MenuName FROM MTUserMenuMaster UM INNER JOIN MTUserModuleMaster MM ON MM.ModuleID=UM.ModuleID INNER JOIN MTUserLimitMaster LM ON UM.MenuName = LM.MenuName AND LM.ModuleID=UM.ModuleID AND LM.VisibleOption='Y' AND LM.UID=" + Session["UID"] + " Where UM.MenuName Not in  ('mnuStaffPayInfo', 'mnuStaffOtherInfo')   ORDER BY MM.Priority,MM.ModuleID,RollNumber ", conMyConnection);
            SqlDataReader rdrMyReader = cmdMyCommand.ExecuteReader();
            TreeNode      objRootNode, objtreenode, objchildnode1, objchildnode2, objchildnode3;
            objRootNode   = new TreeNode("");
            objtreenode   = new TreeNode("");
            objchildnode1 = new TreeNode("");
            objchildnode2 = new TreeNode("");
            while (rdrMyReader.Read())
            {
                int intLevel;
                intLevel = Convert.ToInt32(rdrMyReader.GetValue(2).ToString());
                if (intLevel == 0)
                {
                    objRootNode = new TreeNode(rdrMyReader.GetValue(0).ToString(), "", "", "MainForm.aspx", "MainFrame");

                    trvMenu.Nodes.Add(objRootNode);
                }
                if (intLevel == 1)
                {
                    if (rdrMyReader.GetValue(3).ToString() != "")
                    {
                        objtreenode = new TreeNode(rdrMyReader.GetValue(1).ToString(), "", "", rdrMyReader.GetValue(3).ToString().Trim() + "?MenuName=" + rdrMyReader.GetValue(4).ToString().Trim(), "MainFrame");
                    }
                    else
                    {
                        objtreenode = new TreeNode(rdrMyReader.GetValue(1).ToString());
                    }
                    objRootNode.ChildNodes.Add(objtreenode);
                }
                else if (intLevel == 2)
                {
                    if (rdrMyReader.GetValue(3).ToString() != "")
                    {
                        objchildnode1 = new TreeNode(rdrMyReader.GetValue(1).ToString(), "", "", rdrMyReader.GetValue(3).ToString().Trim() + "?MenuName=" + rdrMyReader.GetValue(4).ToString().Trim(), "MainFrame");
                    }
                    else
                    {
                        objchildnode1 = new TreeNode(rdrMyReader.GetValue(1).ToString());
                    }
                    objtreenode.ChildNodes.Add(objchildnode1);
                }
                else if (intLevel == 3)
                {
                    if (rdrMyReader.GetValue(3).ToString() != "")
                    {
                        objchildnode2 = new TreeNode(rdrMyReader.GetValue(1).ToString(), "", "", rdrMyReader.GetValue(3).ToString().Trim() + "?MenuName=" + rdrMyReader.GetValue(4).ToString().Trim(), "MainFrame");
                    }

                    else
                    {
                        objchildnode2 = new TreeNode(rdrMyReader.GetValue(1).ToString());
                    }
                    objchildnode1.ChildNodes.Add(objchildnode2);
                }
                else if (intLevel == 4)
                {
                    if (rdrMyReader.GetValue(3).ToString() != "")
                    {
                        objchildnode3 = new TreeNode(rdrMyReader.GetValue(1).ToString(), "", "", rdrMyReader.GetValue(3).ToString().Trim() + "?MenuName=" + rdrMyReader.GetValue(4).ToString().Trim(), "MainFrame");
                    }
                    else
                    {
                        objchildnode3 = new TreeNode(rdrMyReader.GetValue(1).ToString());
                    }
                    objchildnode2.ChildNodes.Add(objchildnode3);
                }

                if (objRootNode.ChildNodes.Count >= 1)
                {
                    objRootNode.SelectAction = TreeNodeSelectAction.Expand;
                }
                if (objtreenode.ChildNodes.Count >= 1)
                {
                    objtreenode.SelectAction = TreeNodeSelectAction.Expand;
                }
                if (objchildnode1.ChildNodes.Count >= 1)
                {
                    objchildnode1.SelectAction = TreeNodeSelectAction.Expand;
                }
                if (objchildnode2.ChildNodes.Count >= 1)
                {
                    objchildnode2.SelectAction = TreeNodeSelectAction.Expand;
                }
            }
            //GetMenuData();
            cmdMyCommand.Dispose();
            rdrMyReader.Close();
            rdrMyReader.Dispose();
            conMyConnection.Close();
            conMyConnection.Dispose();
        }
    }