Esempio n. 1
0
        private void LoadReportData()
        {
            try
            {
                bool ViewAll = Common.CheckUserInRole(UserID, 4); // view all daily reports
                ReportDT = InitializeReportGridViewDataTable();
                V_DailyReport report = new V_DailyReport();
                if (!ViewAll)
                {
                    report.Where.UserID.Value = UserID;
                }
                else
                {
                    report.Where.BranchID.Value = Common.GetUserBranchID(UserID);
                    //report.Where.Status.Value = "Not Filled";
                    //report.Where.Status.Operator = MyGeneration.dOOdads.WhereParameter.Operand.NotEqual;
                }
                report.Query.AddOrderBy(V_DailyReport.ColumnNames.ReprotDate, MyGeneration.dOOdads.WhereParameter.Dir.DESC);
                if (report.Query.Load())
                {
                    do
                    {
                        DataRow dr = ReportDT.NewRow();
                        dr["ID"]           = report.ID;
                        dr["ReportDate"]   = report.ReprotDate.ToString("dd/MM/yyyy");
                        dr["UserName"]     = report.FirstName + " " + report.LastName;
                        dr["ModifiedDate"] = report.ModifiedDate.ToString("dd/MM/yyyy");
                        dr["Status"]       = report.Status;
                        dr["ViewURL"]      = "ViewReport.aspx?RID=" + Server.UrlEncode(Encrypt_Decrypt.Encrypt(report.s_ID, key));
                        dr["Review"]       = report.s_Review;
                        dr["Reviewed"]     = report.Reviewed;
                        if (UserID == report.UserID && report.Status == "Not Filled")
                        {
                            dr["CanEdit"] = true;
                            dr["URL"]     = "EditReport.aspx?RID=" + Server.UrlEncode(Encrypt_Decrypt.Encrypt(report.s_ID, key));
                        }
                        else
                        {
                            dr["CanEdit"] = false;
                            dr["URL"]     = "#";
                        }
                        List <string> groups = new List <string>();
                        groups.Add("SalesManagers");
                        if (Common.CheckUserInGroups(UserID, groups) && report.Status == "Pending Verification")
                        {
                            dr["CanVer"] = true;
                            dr["URL"]    = "VarifyReport.aspx?RID=" + Server.UrlEncode(Encrypt_Decrypt.Encrypt(report.s_ID, key));
                        }
                        else
                        {
                            dr["CanVer"] = false;
                            //   dr["URL"] = "#";
                        }

                        if (UserID == report.UserID || (report.Status != "Not Filled"))
                        {
                            ReportDT.Rows.Add(dr);
                        }
                    }while (report.MoveNext());
                }
                GV_Reports.DataSource = ReportDT;
                GV_Reports.DataBind();
                ViewState["ReportDT"] = ReportDT;
            }
            catch (Exception ex)
            {
                Page.Response.Write(ex.Message);
            }
        }
Esempio n. 2
0
 protected void GV_Reports_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     GV_Reports.PageIndex  = e.NewPageIndex;
     GV_Reports.DataSource = (DataTable)ViewState["ReportDT"];
     GV_Reports.DataBind();
 }