예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (LoginSession.IsLogin())
                {
                    if (!LoginSession.IsAdmin())
                    {
                        if (!LoginSession.IsView("MN-00031"))
                        {
                            Response.Redirect("NoPermitsion.aspx");
                        }
                    }
                }
                else
                {
                    Response.Redirect("/Account/Login.aspx?Url=" + Request.Url.PathAndQuery);
                }

                string PublishDocument = Request.QueryString["PublishDocument"];
                if (String.IsNullOrEmpty(PublishDocument))
                {
                    txtPublishDocument.Text    = string.Empty;
                    txtPublishDocument.Enabled = true;
                }
                else
                {
                    txtPublishDocument.Text    = PublishDocument;
                    txtPublishDocument.Enabled = false;
                }

                UsersMN aUsersMN = new UsersMN();
                ddlPerson.Items.Clear();
                ddlPerson.DataSource     = aUsersMN.ListUsers(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, "0");
                ddlPerson.DataValueField = "TenDangNhap";
                ddlPerson.DataTextField  = "Search";
                ddlPerson.DataBind();
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (LoginSession.IsLogin())
                {
                    if (!LoginSession.IsAdmin())
                    {
                        if (!LoginSession.IsView("MN-00026") && !LoginSession.IsView("MN-00027"))
                        {
                            Response.Redirect("NoPermitsion.aspx");
                        }
                    }
                }
                else
                {
                    Response.Redirect("/Account/Login.aspx?Url=" + Request.Url.PathAndQuery);
                }
                hidUserName.Value = LoginSession.UserName();

                #region
                CategorysMN aCategorysMN = new CategorysMN();
                ListItem    aListItem    = new ListItem();
                string      CatTypeCode  = string.Empty;
                CatTypeCode = "CT-00003"; //Application Site
                ddlApplicationSite.Items.Clear();
                ddlApplicationSite.DataSource     = aCategorysMN.ListCategorys(string.Empty, string.Empty, CatTypeCode);
                ddlApplicationSite.DataValueField = "CatCode";
                ddlApplicationSite.DataTextField  = "CatName";
                ddlApplicationSite.DataBind();

                CatTypeCode = "CT-00004"; //Doc Type
                ddlDocType.Items.Clear();
                ddlDocType.DataSource     = aCategorysMN.ListCategorys(string.Empty, string.Empty, CatTypeCode);
                ddlDocType.DataValueField = "CatCode";
                ddlDocType.DataTextField  = "CatName";
                ddlDocType.DataBind();

                CatTypeCode = "CT-00002"; //Department
                ddlCurrentDepartment.Items.Clear();
                ddlCurrentDepartment.DataSource     = aCategorysMN.ListCategorys(string.Empty, string.Empty, CatTypeCode);
                ddlCurrentDepartment.DataValueField = "CatCode";
                ddlCurrentDepartment.DataTextField  = "CatName";
                ddlCurrentDepartment.DataBind();
                ddlCurrentDepartment.Items.Insert(0, new ListItem("ALL", "ALL"));

                #endregion

                #region
                string DocumentNo = Convert.ToString(Request.QueryString["DocumentNo"]);
                string CodeCheck  = Convert.ToString(Request.QueryString["CodeCheck"]);

                if (!String.IsNullOrEmpty(DocumentNo))
                {
                    #region
                    CheckingNoticeMN   aCheckingNoticeMN   = new CheckingNoticeMN();
                    UserInDepartmentMN aUserInDepartmentMN = new UserInDepartmentMN();
                    txtApplicationName.Text = LoginSession.FullName();

                    DataTable aTemp = aUserInDepartmentMN.ListDepartmentByUserName(LoginSession.UserName());
                    if (aTemp.Rows.Count > 0)
                    {
                        txtDepartment.Text = Convert.ToString(aTemp.Rows[0]["NameDepartment"]);
                    }
                    else
                    {
                        txtDepartment.Text = string.Empty;
                    }
                    txtApplicationNO.Text   = string.Empty;
                    txtApplicationDate.Text = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                    DataTable aData = aCheckingNoticeMN.ListRegisterCheckingNotice(string.Empty, string.Empty, DocumentNo,
                                                                                   Convert.ToDateTime("1900-01-01"), Convert.ToDateTime("1900-01-01"));
                    if (aData.Rows.Count > 0)
                    {
                        hidPublishDocument.Value = Convert.ToString(aData.Rows[0]["PublishDocument"]);

                        txtDocNO.Text   = Convert.ToString(aData.Rows[0]["DocumentNo"]);
                        txtDocName.Text = Convert.ToString(aData.Rows[0]["DocumentName"]);
                        txtREV.Text     = Convert.ToString(aData.Rows[0]["Rev"]);
                        ddlApplicationSite.SelectedValue = Convert.ToString(aData.Rows[0]["ApplicationSite"]);
                        ddlDocType.SelectedValue         = Convert.ToString(aData.Rows[0]["DocumentType"]);
                        hidApplicableSite.Value          = Convert.ToString(aData.Rows[0]["ApplicableSite"]);
                        hidApplicableBU.Value            = Convert.ToString(aData.Rows[0]["ApplicableBU"]);

                        txtOriginalResponsible.Text = Convert.ToString(aData.Rows[0]["Original"]);
                        txtRemark.Text = Convert.ToString(aData.Rows[0]["Remark"]);
                    }

                    #endregion
                }
                else
                {
                    if (!String.IsNullOrEmpty(CodeCheck))
                    {
                        #region
                        CheckingNoticeMN aCheckingNoticeMN = new CheckingNoticeMN();
                        DataTable        aData             = aCheckingNoticeMN.ListCheckingNotice(CodeCheck, string.Empty, string.Empty, string.Empty, string.Empty,
                                                                                                  Convert.ToDateTime("1900-01-01"), Convert.ToDateTime("1900-01-01"));
                        if (aData.Rows.Count > 0)
                        {
                            txtDepartment.Text       = Convert.ToString(aData.Rows[0]["Department_Name"]);
                            txtApplicationNO.Text    = Convert.ToString(aData.Rows[0]["CodeCheck"]);
                            txtApplicationName.Text  = Convert.ToString(aData.Rows[0]["HoTen"]);
                            txtApplicationDate.Text  = Convert.ToDateTime(aData.Rows[0]["ApplicationDate"]).ToString("yyyy/MM/dd HH:mm:ss");
                            hidPublishDocument.Value = Convert.ToString(aData.Rows[0]["PublishDocument"]);

                            txtDocNO.Text   = Convert.ToString(aData.Rows[0]["DocumentNo"]);
                            txtDocName.Text = Convert.ToString(aData.Rows[0]["DocumentName"]);
                            txtREV.Text     = Convert.ToString(aData.Rows[0]["Rev"]);
                            ddlApplicationSite.SelectedValue = Convert.ToString(aData.Rows[0]["ApplicationSite"]);
                            ddlDocType.SelectedValue         = Convert.ToString(aData.Rows[0]["DocumentType"]);

                            txtOriginalResponsible.Text        = Convert.ToString(aData.Rows[0]["Original"]);
                            ddlCurrentDepartment.SelectedValue = Convert.ToString(aData.Rows[0]["Department"]);
                            hidCurrentDirector.Value           = Convert.ToString(aData.Rows[0]["Director"]);
                            txtCurrentDirector.Text            = Convert.ToString(aData.Rows[0]["Director_Name"]);
                            txtRemark.Text = Convert.ToString(aData.Rows[0]["Remark"]);

                            hidCodeCheck.Value      = Convert.ToString(aData.Rows[0]["CodeCheck"]);
                            hidID.Value             = Convert.ToString(aData.Rows[0]["ID"]);
                            hidStates.Value         = Convert.ToString(aData.Rows[0]["States"]);
                            hidApplicableSite.Value = Convert.ToString(aData.Rows[0]["ApplicableSite"]);
                            hidApplicableBU.Value   = Convert.ToString(aData.Rows[0]["ApplicableBU"]);



                            if (hidStates.Value.Equals("F05"))
                            {
                                UsersMN aUsersMN = new UsersMN();
                                ddlPerson.Items.Clear();
                                ddlPerson.DataSource     = aUsersMN.ListDetailUserByDepartment(Convert.ToString(aData.Rows[0]["Department"]), string.Empty);
                                ddlPerson.DataValueField = "TenDangNhap";
                                ddlPerson.DataTextField  = "HoTen";
                                ddlPerson.DataBind();
                            }
                        }
                        #endregion
                    }
                }
                #endregion
            }
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (LoginSession.IsLogin())
                {
                    if (!LoginSession.IsAdmin())
                    {
                        if (!LoginSession.IsView("MN-00028"))
                        {
                            Response.Redirect("NoPermitsion.aspx");
                        }
                    }
                }
                else
                {
                    Response.Redirect("/Account/Login.aspx?Url=" + Request.Url.PathAndQuery);
                }
                hidUserName.Value = LoginSession.UserName();

                #region
                UserInDepartmentMN aUserInDepartmentMN = new UserInDepartmentMN();
                RenewalsDocumentMN aRenewalsDocumentMN = new RenewalsDocumentMN();
                CategorysMN        aCategorysMN        = new CategorysMN();
                ListItem           aListItem           = new ListItem();
                string             CatTypeCode         = string.Empty;
                CatTypeCode = "CT-00003"; //Application Site
                ddlApplicationSite.Items.Clear();
                ddlApplicationSite.DataSource     = aCategorysMN.ListCategorys(string.Empty, string.Empty, CatTypeCode);
                ddlApplicationSite.DataValueField = "CatCode";
                ddlApplicationSite.DataTextField  = "CatName";
                ddlApplicationSite.DataBind();
                #endregion

                #region
                string Code        = Convert.ToString(Request.QueryString["Code"]);
                string DCC         = Convert.ToString(Request.QueryString["DCC"]);
                string RenewalCode = Convert.ToString(Request.QueryString["RenewalCode"]);

                if (!String.IsNullOrEmpty(Code) && !String.IsNullOrEmpty(DCC))
                {
                    #region
                    ddlDepartment.Items.Clear();
                    ddlDepartment.DataSource     = aUserInDepartmentMN.ListDepartmentByUserName(LoginSession.UserName());
                    ddlDepartment.DataValueField = "Department";
                    ddlDepartment.DataTextField  = "NameDepartment";
                    ddlDepartment.DataBind();

                    hidType.Value           = Convert.ToString(Request.QueryString["Type"]);
                    txtApplicationName.Text = LoginSession.FullName();
                    txtApplicationNO.Text   = string.Empty;
                    txtApplicationDate.Text = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                    DataTable aData = aRenewalsDocumentMN.ListRegisterRenewalDocument(Code, DCC, string.Empty);
                    if (aData.Rows.Count > 0)
                    {
                        aListItem = ddlApplicationSite.Items.FindByValue(Convert.ToString(aData.Rows[0]["ApplicationSite"]));
                        if (aListItem != null)
                        {
                            ddlApplicationSite.SelectedValue = Convert.ToString(aData.Rows[0]["ApplicationSite"]);
                        }
                        aListItem = ddlType.Items.FindByValue(Convert.ToString(aData.Rows[0]["Type"]));
                        if (aListItem != null)
                        {
                            ddlType.SelectedValue = Convert.ToString(aData.Rows[0]["Type"]);
                        }
                        txtApplicationCode.Text = Convert.ToString(aData.Rows[0]["Code"]);
                        txtDocNO.Text           = Convert.ToString(aData.Rows[0]["DCC"]);
                        txtRevised.Text         = Convert.ToString(aData.Rows[0]["Revised"]);
                        txtRevisor.Text         = Convert.ToString(aData.Rows[0]["Revisor"]);
                        txtCloseDate.Text       = Convert.ToString(aData.Rows[0]["CloseDate"]);
                    }

                    #endregion
                }
                else
                {
                    if (!String.IsNullOrEmpty(RenewalCode))
                    {
                        #region
                        ddlDepartment.Items.Clear();
                        ddlDepartment.DataSource     = aUserInDepartmentMN.ListDepartmentByUserName(LoginSession.UserName());
                        ddlDepartment.DataValueField = "Department";
                        ddlDepartment.DataTextField  = "NameDepartment";
                        ddlDepartment.DataBind();

                        DataTable aData = aRenewalsDocumentMN.ListRenewalsDocument(RenewalCode, string.Empty, string.Empty, string.Empty, string.Empty,
                                                                                   Convert.ToDateTime("1900-01-01"), Convert.ToDateTime("1900-01-01"));
                        if (aData.Rows.Count > 0)
                        {
                            hidID.Value          = Convert.ToString(aData.Rows[0]["ID"]);
                            hidStates.Value      = Convert.ToString(aData.Rows[0]["States"]);
                            hidRenewalCode.Value = Convert.ToString(aData.Rows[0]["RenewalCode"]);

                            txtApplicationName.Text = Convert.ToString(aData.Rows[0]["HoTen"]);
                            txtApplicationNO.Text   = Convert.ToString(aData.Rows[0]["RenewalCode"]);
                            txtApplicationDate.Text = Convert.ToDateTime(aData.Rows[0]["ApplicationDate"]).ToString("yyyy/MM/dd HH:mm:ss");

                            aListItem = ddlApplicationSite.Items.FindByValue(Convert.ToString(aData.Rows[0]["ApplicationSite"]));
                            if (aListItem != null)
                            {
                                ddlApplicationSite.SelectedValue = Convert.ToString(aData.Rows[0]["ApplicationSite"]);
                            }
                            aListItem = ddlType.Items.FindByValue(Convert.ToString(aData.Rows[0]["TypeRenewal"]));
                            if (aListItem != null)
                            {
                                ddlType.SelectedValue = Convert.ToString(aData.Rows[0]["TypeRenewal"]);
                            }
                            aListItem = ddlDepartment.Items.FindByValue(Convert.ToString(aData.Rows[0]["Department"]));
                            if (aListItem != null)
                            {
                                ddlDepartment.SelectedValue = Convert.ToString(aData.Rows[0]["Department"]);
                            }

                            txtApplicationCode.Text = Convert.ToString(aData.Rows[0]["DocumentNo"]);
                            txtDocNO.Text           = Convert.ToString(aData.Rows[0]["DCC_NO"]);
                            txtRevised.Text         = Convert.ToString(aData.Rows[0]["BeforRevised"]);
                            txtRevisor.Text         = Convert.ToString(aData.Rows[0]["BeforRevisor"]);
                            txtCloseDate.Text       = Convert.ToString(aData.Rows[0]["BeforCloseDate"]);

                            txtEffectiveDate.Text  = Convert.ToDateTime(aData.Rows[0]["EffectiveDate"]).Year > 1900 ? Convert.ToDateTime(aData.Rows[0]["EffectiveDate"]).ToString("yyyy/MM/dd") : string.Empty;
                            txtReason.Text         = Convert.ToString(aData.Rows[0]["Reason"]);
                            txtAfterRevisor.Text   = Convert.ToString(aData.Rows[0]["Revisor"]);
                            txtAfterCloseDate.Text = Convert.ToDateTime(aData.Rows[0]["CloseDate"]).Year > 1900 ? Convert.ToDateTime(aData.Rows[0]["CloseDate"]).ToString("yyyy/MM/dd") : string.Empty;


                            if (hidStates.Value.Equals("H05") || hidStates.Value.Equals("H10"))
                            {
                                UsersMN aUsersMN = new UsersMN();
                                ddlDirecter.Items.Clear();
                                ddlDirecter.DataSource     = aUsersMN.ListDetailUserByDepartment(string.Empty, "C-00004");
                                ddlDirecter.DataValueField = "TenDangNhap";
                                ddlDirecter.DataTextField  = "HoTen";
                                ddlDirecter.DataBind();
                                ddlDirecter.Items.Insert(0, new ListItem("ALL", "ALL"));
                                if (hidStates.Value.Equals("H10"))
                                {
                                    ddlDirecter.SelectedIndex = 1;
                                }
                            }
                        }
                        #endregion
                    }
                }
                #endregion
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (LoginSession.IsLogin())
                {
                    if (!LoginSession.IsAdmin())
                    {
                        if (!LoginSession.IsView("MN-00016"))
                        {
                            Response.Redirect("NoPermitsion.aspx");
                        }
                    }
                }
                else
                {
                    Response.Redirect("/Account/Login.aspx?Url=" + Request.Url.PathAndQuery);
                }
                hidUserName.Value = LoginSession.UserName();

                #region
                UsersMN     aUsersMN     = new UsersMN();
                CategorysMN aCategorysMN = new CategorysMN();
                ListItem    aListItem    = new ListItem();
                string      CatTypeCode  = string.Empty;
                CatTypeCode = "CT-00003"; //Application Site
                ddlApplicationSite.DataSource     = aCategorysMN.ListCategorys(string.Empty, string.Empty, CatTypeCode);
                ddlApplicationSite.DataValueField = "CatCode";
                ddlApplicationSite.DataTextField  = "CatName";
                ddlApplicationSite.DataBind();

                //CatTypeCode = "CT-00004"; //Doc Type
                //ddlDocType.DataSource = aCategorysMN.ListCategorys(string.Empty, string.Empty, CatTypeCode);
                //ddlDocType.DataValueField = "CatCode";
                //ddlDocType.DataTextField = "CatName";
                //ddlDocType.DataBind();

                #endregion

                #region
                string PublishDocument   = Convert.ToString(Request.QueryString["PublishDocument"]);
                string ObsoletedDocument = Convert.ToString(Request.QueryString["ObsoletedDocument"]);

                if (!String.IsNullOrEmpty(PublishDocument))
                {
                    #region
                    RegisterPublishDocumentMN aRegisterPublishDocumentMN = new RegisterPublishDocumentMN();
                    txtApplicationName.Text  = LoginSession.FullName();
                    txtApplicationNO.Text    = string.Empty;
                    txtApplicationDate.Text  = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                    hidPublishDocument.Value = PublishDocument;

                    DataTable aData = aRegisterPublishDocumentMN.ListRegisterPublishDocument(PublishDocument, string.Empty, "C26", string.Empty,
                                                                                             string.Empty, string.Empty, string.Empty, string.Empty, Convert.ToDateTime("1900-01-01"), Convert.ToDateTime("1900-01-01"));
                    if (aData.Rows.Count > 0)
                    {
                        ddlApplicationSite.Text = Convert.ToString(aData.Rows[0]["ApplicationSite"]);
                        //hidApplicableSite.Value = Convert.ToString(aData.Rows[0]["ApplicableSite"]);
                        txtDocNO.Text   = Convert.ToString(aData.Rows[0]["DocumentNo"]);
                        txtREV.Text     = Convert.ToString(aData.Rows[0]["Rev"]);
                        txtDocName.Text = Convert.ToString(aData.Rows[0]["DocumentName"]);

                        txtReleaseDate.Text = Convert.ToString(aData.Rows[0]["EffectiveDate_Text"]);
                        //ddlDocType.Text = Convert.ToString(aData.Rows[0]["DocumentType"]);
                        //hidApplicableBU.Value = Convert.ToString(aData.Rows[0]["ApplicableBU"]);
                        //hidDepartmentCheck.Value = Convert.ToString(aData.Rows[0]["DepartmentCheck"]);

                        DataTable aTemp = new DataTable();
                        aTemp = aCategorysMN.ListCategorys(Convert.ToString(aData.Rows[0]["Department"]), string.Empty, string.Empty);
                        txtApplicationDep.Text = aTemp.Rows.Count > 0 ? Convert.ToString(aTemp.Rows[0]["CatName"]) : string.Empty;
                        txtDepartment.Text     = aTemp.Rows.Count > 0 ? Convert.ToString(aTemp.Rows[0]["CatName"]) : string.Empty;
                        aTemp           = aUsersMN.GetManagerCurrent();
                        txtManager.Text = aTemp.Rows.Count > 0 ? Convert.ToString(aTemp.Rows[0]["HoTen"]) : string.Empty;
                    }

                    #endregion
                }
                else
                {
                    if (!String.IsNullOrEmpty(ObsoletedDocument))
                    {
                        #region

                        ApplicationObsoletedDocumentMN aApplicationObsoletedDocumentMN = new ApplicationObsoletedDocumentMN();
                        DataTable aData = aApplicationObsoletedDocumentMN.ListApplicationObsoletedDocument(ObsoletedDocument, string.Empty, string.Empty,
                                                                                                           string.Empty, string.Empty, string.Empty, string.Empty, Convert.ToDateTime("1900-01-01"), Convert.ToDateTime("1900-01-01"));
                        if (aData.Rows.Count > 0)
                        {
                            txtApplicationName.Text    = Convert.ToString(aData.Rows[0]["HoTen"]);
                            hidID.Value                = Convert.ToString(aData.Rows[0]["ID"]);
                            hidObsoletedDocument.Value = ObsoletedDocument;
                            hidStates.Value            = Convert.ToString(aData.Rows[0]["States"]);
                            txtApplicationNO.Text      = Convert.ToString(aData.Rows[0]["ObsoletedDocument"]);
                            hidPublishDocument.Value   = Convert.ToString(aData.Rows[0]["PublishDocument"]);
                            txtEffectiveDate.Text      = Convert.ToDateTime(aData.Rows[0]["EffectiveDate"]).Year > 1900 ? Convert.ToDateTime(aData.Rows[0]["EffectiveDate"]).ToString("yyyy/MM/dd") : string.Empty;
                            txtApplicationDate.Text    = Convert.ToString(aData.Rows[0]["ApplicationDate_Text"]);

                            ddlApplicationSite.Text = Convert.ToString(aData.Rows[0]["ApplicationSite"]);
                            //hidApplicableSite.Value = Convert.ToString(aData.Rows[0]["ApplicableSite"]);
                            txtDocNO.Text   = Convert.ToString(aData.Rows[0]["DocumentNo"]);
                            txtREV.Text     = Convert.ToString(aData.Rows[0]["Rev"]);
                            txtDocName.Text = Convert.ToString(aData.Rows[0]["DocumentName"]);

                            txtReleaseDate.Text = Convert.ToString(aData.Rows[0]["EffectiveDate_Text"]);
                            //ddlDocType.Text = Convert.ToString(aData.Rows[0]["DocumentType"]);
                            //hidApplicableBU.Value = Convert.ToString(aData.Rows[0]["ApplicableBU"]);
                            //hidDepartmentCheck.Value = Convert.ToString(aData.Rows[0]["DepartmentCheck"]);

                            DataTable aTemp = new DataTable();
                            aTemp = aCategorysMN.ListCategorys(Convert.ToString(aData.Rows[0]["Department"]), string.Empty, string.Empty);
                            txtApplicationDep.Text = aTemp.Rows.Count > 0 ? Convert.ToString(aTemp.Rows[0]["CatName"]) : string.Empty;
                            txtDepartment.Text     = aTemp.Rows.Count > 0 ? Convert.ToString(aTemp.Rows[0]["CatName"]) : string.Empty;
                            aTemp           = aUsersMN.GetManagerCurrent();
                            txtManager.Text = aTemp.Rows.Count > 0 ? Convert.ToString(aTemp.Rows[0]["HoTen"]) : string.Empty;

                            txtReasonObsoleted.Text = Convert.ToString(aData.Rows[0]["ReasonObsoleted"]);
                        }

                        #endregion
                    }
                }
                #endregion
            }
        }
예제 #5
0
        public static void Login(string UserName)
        {
            try
            {
                string Quyen   = string.Empty;
                string Xem     = string.Empty;
                string ThemMoi = string.Empty;
                string Sua     = string.Empty;

                string Xoa       = string.Empty;
                string BaoCao    = string.Empty;
                string TimKiem   = string.Empty;
                string ResetPass = string.Empty;

                string HoTen = string.Empty;
                string ViTri = string.Empty;

                UsersMN   aUsersMN = new UsersMN();
                DataTable aData    = new DataTable();
                aData = aUsersMN.ListPermitsionByUserName(UserName);

                #region
                if (aData.Rows.Count > 0)
                {
                    Quyen = Convert.ToString(aData.Rows[0]["Quyen"]);
                    HoTen = Convert.ToString(aData.Rows[0]["HoTen"]);
                    ViTri = Convert.ToBoolean(aData.Rows[0]["DCC"]) ? "1" : string.Empty;
                }
                else
                {
                    Quyen = string.Empty;
                    HoTen = string.Empty;
                    ViTri = string.Empty;
                }

                UserInPositionMN aUserInPositionMN = new UserInPositionMN();
                DataTable        aPosition         = aUserInPositionMN.CheckPosition(UserName);
                if (aPosition.Rows.Count > 0)
                {
                    ViTri = "1";
                }

                #endregion

                #region
                for (int i = 0; i < aData.Rows.Count; i++)
                {
                    if (Convert.ToBoolean(aData.Rows[i]["Xem"]))
                    {
                        Xem = Xem + Convert.ToString(aData.Rows[i]["Code"]) + "|";
                    }

                    if (Convert.ToBoolean(aData.Rows[i]["ThemMoi"]))
                    {
                        ThemMoi = ThemMoi + Convert.ToString(aData.Rows[i]["Code"]) + "|";
                    }

                    if (Convert.ToBoolean(aData.Rows[i]["Sua"]))
                    {
                        Sua = Sua + Convert.ToString(aData.Rows[i]["Code"]) + "|";
                    }

                    if (Convert.ToBoolean(aData.Rows[i]["Xoa"]))
                    {
                        Xoa = Xoa + Convert.ToString(aData.Rows[i]["Code"]) + "|";
                    }

                    if (Convert.ToBoolean(aData.Rows[i]["BaoCao"]))
                    {
                        BaoCao = BaoCao + Convert.ToString(aData.Rows[i]["Code"]) + "|";
                    }

                    if (Convert.ToBoolean(aData.Rows[i]["TimKiem"]))
                    {
                        TimKiem = TimKiem + Convert.ToString(aData.Rows[i]["Code"]) + "|";
                    }

                    if (Convert.ToBoolean(aData.Rows[i]["ResetPass"]))
                    {
                        ResetPass = ResetPass + Convert.ToString(aData.Rows[i]["Code"]) + "|";
                    }
                }
                #endregion

                #region
                HttpCookie aCookie = new HttpCookie("Login");

                aCookie.Values["UserName"] = UserName;
                aCookie.Values["Quyen"]    = Quyen;
                aCookie.Values["Xem"]      = Xem;
                aCookie.Values["ThemMoi"]  = ThemMoi;
                aCookie.Values["Sua"]      = Sua;

                aCookie.Values["Xoa"]       = Xoa;
                aCookie.Values["BaoCao"]    = BaoCao;
                aCookie.Values["TimKiem"]   = TimKiem;
                aCookie.Values["ResetPass"] = ResetPass;
                aCookie.Values["FullName"]  = HttpContext.Current.Server.UrlEncode(HoTen);

                aCookie.Values["ViTri"] = ViTri;

                aCookie.Expires.AddHours(8);
                HttpContext.Current.Response.Cookies.Add(aCookie);
                #endregion
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
예제 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    string id_user = Request.Url.Query;
                    if (id_user.LastIndexOf("id_user") > 0)
                    {
                        id_user = id_user.Substring(id_user.LastIndexOf("id_user") + 8, (id_user.Length - id_user.LastIndexOf("id_user") - 8));
                        id_user = Utils.Decrypt(id_user);
                        if (String.IsNullOrEmpty(id_user))
                        {
                            HttpCookie aCookie = HttpContext.Current.Request.Cookies["Login"];
                            if (aCookie != null)
                            {
                                Response.Redirect("/Default.aspx", false);
                            }
                        }
                        else
                        {
                            UsersMN   aUsersMN = new UsersMN();
                            DataTable aData    = aUsersMN.CheckLogin(string.Empty, string.Empty, id_user);
                            if (aData.Rows.Count > 0)
                            {
                                id_user = id_user.ToUpper();
                                LoginSession.Login(id_user);

                                string url = Request.Url.Query;
                                url = url.Substring(5, url.IndexOf("&id_user") - 5);
                                Response.Redirect(url, false);
                            }
                            else
                            {
                                HttpCookie aCookie = HttpContext.Current.Request.Cookies["Login"];
                                if (aCookie != null)
                                {
                                    Response.Redirect("/Default.aspx", false);
                                }
                            }
                        }
                    }
                    else
                    {
                        HttpCookie aCookie = HttpContext.Current.Request.Cookies["Login"];
                        if (aCookie != null)
                        {
                            Response.Redirect("/Default.aspx", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ex.ToString();
                    HttpCookie aCookie = HttpContext.Current.Request.Cookies["Login"];
                    if (aCookie != null)
                    {
                        Response.Redirect("/Default.aspx");
                    }
                }
            }
        }