예제 #1
0
    protected void Login1_LoggedIn(object sender, EventArgs e)
    {
        //MHOCommon.ClearCurrentSession();
        Session.Remove("Error");
        aspnet_Users user = new aspnet_Users();
        user.GetUserByName(Login1.UserName);

        // Validate User IP and Status
        // Check if the logged user is valid under his current IP
        OrgUser objOrgUser = new OrgUser();
        if (!objOrgUser.ValidateUserIPStatus(user.UserId, MHOCommon.CurrentOrgIP))
        {
            if (MHOCommon.EnableSmartLogin == 1)
            {
                FormsAuthentication.SignOut();
                Session["Error"] = true;
            }
        }

        OrgUser orgUser = new OrgUser();
        orgUser.LoadByPrimaryKey(user.UserId);

        if (orgUser.Status)
        {

            if (Roles.IsUserInRole(Login1.UserName, "SuperAdmin"))
            {
                Response.Redirect("~/Admin/AdminHomePage.aspx");
            }
            else if ( Roles.IsUserInRole(Login1.UserName, "SubAdmin"))
            {
                Response.Redirect("~/Admin/SubAdminHome.aspx");
            }
            else if (Roles.IsUserInRole(Login1.UserName, "Admin"))
            {
                Response.Redirect("~/Admin/AdminGovHome.aspx");
            }
            else
            {
                Response.Redirect("Default.aspx");
            }
        }
        else
        {
            FormsAuthentication.SignOut();
            Session["Error"] = true;

        }
    }
    private void setCurrentUserInfo()
    {
        try
        {
            OrgUser Current = new OrgUser();
            if (MHOCommon.CurrentLoggedUserID != null && MHOCommon.CurrentLoggedUserID != Guid.Empty)
            {
                Current.LoadByPrimaryKey(MHOCommon.CurrentLoggedUserID);
                uiTextBoxNotifierName.Text = Current.FirstName.Trim() + " " + Current.FatherName.Trim();

                if (Current.GovId != 0)
                {
                    uiDropDownListGov.SelectedValue = Current.GovId.ToString();
                    uiDropDownListGov.Enabled = false;
                    uiDropDownListMachineGov.SelectedValue = Current.GovId.ToString();
                    uiDropDownListMachineGov.Enabled = false;

                    /*********************/
                    if (uiDropDownListGov.SelectedIndex != 0)
                    {
                        CIVIL_OFFICE pol = new CIVIL_OFFICE();
                        pol.Where.FK_GOVCD.Value = short.Parse(uiDropDownListGov.SelectedValue);
                        pol.Where.FK_GOVCD.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
                        pol.Query.AddOrderBy(CIVIL_OFFICE.ColumnNames.DESCR, MyGeneration.dOOdads.WhereParameter.Dir.ASC);
                        pol.Query.Load();
                        uiDropDownListCivil.DataSource = pol.DefaultView;
                        uiDropDownListCivil.DataTextField = POLICE_STATION.ColumnNames.DESCR;
                        uiDropDownListCivil.DataValueField = POLICE_STATION.ColumnNames.CD;
                        uiDropDownListCivil.DataBind();
                        uiDropDownListCivil.Items.Insert(0, new ListItem("---", "0"));
                        uiDropDownListCivil.SelectedIndex = 0;
                    }

                    if (uiDropDownListMachineGov.SelectedIndex != 0)
                    {
                        CIVIL_OFFICE pol = new CIVIL_OFFICE();
                        pol.Where.FK_GOVCD.Value = short.Parse(uiDropDownListMachineGov.SelectedValue);
                        pol.Where.FK_GOVCD.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
                        pol.Query.AddOrderBy(CIVIL_OFFICE.ColumnNames.DESCR, MyGeneration.dOOdads.WhereParameter.Dir.ASC);
                        pol.Query.Load();
                        uiDropDownListMachineCivil.DataSource = pol.DefaultView;
                        uiDropDownListMachineCivil.DataTextField = POLICE_STATION.ColumnNames.DESCR;
                        uiDropDownListMachineCivil.DataValueField = POLICE_STATION.ColumnNames.CD;
                        uiDropDownListMachineCivil.DataBind();
                        uiDropDownListMachineCivil.Items.Insert(0, new ListItem("---", "0"));
                        uiDropDownListMachineCivil.SelectedIndex = 0;
                    }

                    if (Current.CivilId != 0)
                    {
                        uiDropDownListCivil.SelectedValue = Current.CivilId.ToString();
                        uiDropDownListCivil.Enabled = false;
                        uiDropDownListMachineCivil.SelectedValue = Current.CivilId.ToString();
                        uiDropDownListMachineCivil.Enabled = false;

                        if (uiDropDownListCivil.SelectedIndex != 0 && uiDropDownListGov.SelectedIndex != 0)
                        {
                            health_office obj = new health_office();
                            uiDropDownListHealthOffice.DataSource = obj.GetHealthOfficeDetails(short.Parse(uiDropDownListGov.SelectedValue), short.Parse(uiDropDownListCivil.SelectedValue)).DefaultView;
                            uiDropDownListHealthOffice.DataTextField = health_office.ColumnNames.HEALTHDESCR;
                            uiDropDownListHealthOffice.DataValueField = health_office.ColumnNames.HEALTHCD;
                            uiDropDownListHealthOffice.DataBind();
                            uiDropDownListHealthOffice.Items.Insert(0, new ListItem("---", "0"));
                            uiDropDownListHealthOffice.SelectedIndex = 0;
                        }

                        if (uiDropDownListMachineGov.SelectedIndex != 0 && uiDropDownListMachineCivil.SelectedIndex != 0)
                        {
                            health_office obj = new health_office();
                            uiDropDownListMachineHealthOffice.DataSource = obj.GetHealthOfficeDetails(short.Parse(uiDropDownListMachineGov.SelectedValue), short.Parse(uiDropDownListMachineCivil.SelectedValue)).DefaultView;
                            uiDropDownListMachineHealthOffice.DataTextField = health_office.ColumnNames.HEALTHDESCR;
                            uiDropDownListMachineHealthOffice.DataValueField = health_office.ColumnNames.HEALTHCD;
                            uiDropDownListMachineHealthOffice.DataBind();
                            uiDropDownListMachineHealthOffice.Items.Insert(0, new ListItem("---", "0"));
                            uiDropDownListMachineHealthOffice.SelectedIndex = 0;
                        }
                    }
                }
                /************************/
            }
        }
        catch (Exception)
        {
            // gives error when log out
        }
    }