Пример #1
0
 private void gridView1_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
 {
     if (!GridViewReport.IsFilterRow(e.RowHandle))
     {
         modified = true;
     }
 }
Пример #2
0
 private void ReportTypeForm_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter && GridViewReport.IsFilterRow(GridViewReport.FocusedRowHandle))
     {
         executeQuery();
     }
 }
Пример #3
0
        private void BindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (RptTypeBindingSource.Current == null)
            {
                return;
            }

            GridViewReport.CloseEditor();
            TextEditCode.Focus();
            //bindingNavigatorPositionItem.Focus();//trigger field leave event
            bool temp = newRec;

            if (checkForms())
            {
                TextEditCode.Focus();
                setReadOnly(true);
                panelControlStatus.Visible = true;
                LabelStatus.Text           = "Record Saved";
                rowStatusSave          = new Timer();
                rowStatusSave.Interval = 3000;
                rowStatusSave.Start();
                rowStatusSave.Tick += TimedEventSave;
            }

            if (!temp && !modified)
            {
                context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, (RPTTYPE)RptTypeBindingSource.Current);
            }
        }
Пример #4
0
    DataTable dt = new DataTable();                    // data structure to store the table from the database
    protected void Page_Load(object sender, EventArgs e)
    {
        string userName = Convert.ToString(Session["userName"]); //to get the userName from the session object

        userNameLabel.Text = userName + " , your Quiz Report is displayed below";

        if (!IsPostBack) /*To avoid execution on page load*/
        {
            score = Convert.ToString(Session["Counter"]);
            if (Session["Report"] != null)
            {
                report = Session["Report"] as List <string>;
            }

            dt.Columns.Add("Question Number");
            dt.Columns.Add("Result");
            for (int i = 0; i < report.Count(); i++)
            {
                dt.Rows.Add(i + 1, report[i]);
            }

            GridViewReport.DataSource = dt;
            GridViewReport.DataBind();
            ScoreLabel.Text = "Total marks: " + score;
        }
    }
Пример #5
0
        protected void LoadReport()
        {
            DataTable dt = new DataTable();

            dt = dal.SelectAllInformation();
            GridViewReport.DataSource = dt;
            GridViewReport.DataBind();
        }
Пример #6
0
        public void GetReport()
        {
            string getReport = "SELECT * FROM Report ORDER BY reportId DESC";

            dt = da.ConnectDataBaseReturnDT(getReport);
            if (dt.Rows.Count > 0)
            {
                GridViewReport.DataSource = HttpUtility.HtmlEncode(dt);
                GridViewReport.DataBind();
            }
        }
Пример #7
0
        private void setValues()
        {
            GridViewReport.SetFocusedRowCellValue("RPT_FILE", string.Empty);
            GridViewReport.SetFocusedRowCellValue("RecipientType", string.Empty);
            GridViewReport.SetFocusedRowCellValue("ReplyToEmail", string.Empty);
            GridViewReport.SetFocusedRowCellValue("ReplyToMessage", string.Empty);
            GridViewReport.SetFocusedRowCellValue("IMG_RES", -1);

            GridViewReport.SetFocusedRowCellValue("CODE", string.Empty);
            GridViewReport.SetFocusedRowCellValue("DESC", string.Empty);
            GridViewReport.SetFocusedRowCellValue("TOURFAX", false);
            GridViewReport.SetFocusedRowCellValue("EDITABLE", false);
            GridViewReport.SetFocusedRowCellValue("MEDIA_RPT", false);
        }
Пример #8
0
 private bool move()
 {
     GridViewReport.CloseEditor();
     //bindingNavigatorPositionItem.Focus();//trigger field leave event
     TextEditCode.Focus();
     temp = newRec;
     if (checkForms())
     {
         if (!temp)
         {
             context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, ( RPTTYPE)RptTypeBindingSource.Current);
         }
         setReadOnly(true);
         newRec   = false;
         modified = false;
         return(true);
     }
     return(false);
 }
Пример #9
0
 private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
 {
     GridViewReport.ClearColumnsFilter();
     if (RptTypeBindingSource.Current == null)
     {
         //fake query in order to create a link between the database table and the binding source
         RptTypeBindingSource.DataSource = from opt in context.RPTTYPE where opt.CODE == "KJM9" select opt;
         RptTypeBindingSource.AddNew();
         if (GridViewReport.FocusedRowHandle == GridControl.AutoFilterRowHandle)
         {
             GridViewReport.FocusedRowHandle = GridViewReport.RowCount - 1;
         }
         setValues();
         TextEditCode.Focus();
         setReadOnly(false);
         newRec = true;
         return;
     }
     TextEditCode.Focus();
     //bindingNavigatorPositionItem.Focus();  //trigger field leave event
     GridViewReport.CloseEditor();
     temp = newRec;
     if (checkForms())
     {
         if (!temp)
         {
             context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, ( RPTTYPE)RptTypeBindingSource.Current);
         }
         RptTypeBindingSource.AddNew();
         if (GridViewReport.FocusedRowHandle == GridControl.AutoFilterRowHandle)
         {
             GridViewReport.FocusedRowHandle = GridViewReport.RowCount - 1;
         }
         TextEditCode.Focus();
         setValues();
         setReadOnly(false);
         newRec = true;
     }
 }
Пример #10
0
        private void executeQuery()
        {
            this.Cursor = Cursors.WaitCursor;
            string colName = GridViewReport.FocusedColumn.FieldName;
            string value   = String.Empty;

            if (!string.IsNullOrWhiteSpace(GridViewReport.GetFocusedDisplayText()))
            {
                value = GridViewReport.GetFocusedDisplayText();
            }
            if (!string.IsNullOrWhiteSpace(value))
            {
                string query   = String.Format("it.CODE like '{0}%'", GridViewReport.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "CODE"));
                var    special = context.RPTTYPE.Where(query);

                if (!string.IsNullOrWhiteSpace(GridViewReport.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "DESC")))
                {
                    query   = String.Format("it.{0} like '{1}%'", "[DESC]", GridViewReport.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "DESC"));
                    special = special.Where(query);
                }
                int count = special.Count();
                if (count > 0)
                {
                    RptTypeBindingSource.DataSource = special;
                    GridViewReport.SetRowCellValue(GridControl.AutoFilterRowHandle, colName, value);
                    GridViewReport.FocusedRowHandle        = 0;
                    GridViewReport.FocusedColumn.FieldName = colName;
                }
                else
                {
                    MessageBox.Show("No records in database.");
                    GridViewReport.ClearColumnsFilter();
                }
            }
            this.Cursor = Cursors.Default;
        }
Пример #11
0
 private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
 {
     if (RptTypeBindingSource.Current == null)
     {
         return;
     }
     GridViewReport.CloseEditor();
     if (MessageBox.Show("Are you sure you want to delete?", "CONFIRM", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         modified = false;
         newRec   = false;
         RptTypeBindingSource.RemoveCurrent();
         errorProvider1.Clear();
         context.SaveChanges();
         setReadOnly(true);
         panelControlStatus.Visible = true;
         LabelStatus.Text           = "Record Deleted";
         rowStatusDelete            = new Timer();
         rowStatusDelete.Interval   = 3000;
         rowStatusDelete.Start();
         rowStatusDelete.Tick += new EventHandler(TimedEventDelete);
     }
     currentVal = TextEditCode.Text;
 }
Пример #12
0
        public void GenerateStudentsReportInExcel(int ClassID, int SessionID)
        {
            DataTable dtStudents;


            string constr = Connection.ConnectionString;

            using (SqlConnection con = new SqlConnection(constr))
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@SessionID", SessionID);
                cmd.Parameters.AddWithValue("@ClassID", ClassID);
                cmd.CommandText = "pICAS_RPT_GetStudentList_BySessionAndClass";


                using (SqlDataAdapter sda = new SqlDataAdapter())
                {
                    cmd.Connection    = con;
                    sda.SelectCommand = cmd;
                    using (DataTable dt = new DataTable())
                    {
                        sda.Fill(dt);
                        dt.TableName = "TSDC_" + ddlSession.Text.ToString() + "_Plus" + ClassID.ToString();
                        Response.ClearContent();
                        Response.AppendHeader("content-disposition", "attachment;filename=TSDC_Students_Report" + ddlSession.Text.ToString() + "_Plus" + ClassID.ToString() + ".xlsx");
                        Response.ContentType = "application/excel";

                        StringWriter   sWriterObj    = new StringWriter();
                        HtmlTextWriter htmlWriterObj = new HtmlTextWriter(sWriterObj);

                        GridViewReport.DataSource = dt;
                        GridViewReport.DataBind();

                        GridViewReport.RenderControl(htmlWriterObj);

                        //GridViewReport.HeaderRow.Style.Add("background-color", "#ffffff");
                        //foreach (TableCell itemCell in GridViewReport.Rows)
                        //{
                        //    itemCell.Style["background-color"] = "#00ff00";
                        //}
                        Response.Write(sWriterObj.ToString());
                        Response.End();
                        //using (XLWorkbook wb = new XLWorkbook())
                        //{
                        //    string SheetName = string.Format("Sheet_{0}_plus_{1}", ddlSession.Text.ToString(), ClassID.ToString());

                        //    wb.Worksheets.Add(dt, SheetName);
                        //    Response.Clear();
                        //    Response.Buffer = true;
                        //    Response.Charset = "";
                        //    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                        //    Response.AddHeader("content-disposition", "attachment;filename=TSDC_Students_Report" + ddlSession.Text.ToString() + "_Plus" + ClassID.ToString() + ".xlsx");
                        //    using (MemoryStream MyMemoryStream = new MemoryStream())
                        //    {
                        //        wb.SaveAs(MyMemoryStream);
                        //        MyMemoryStream.WriteTo(Response.OutputStream);
                        //        Response.Flush();
                        //        Response.End();
                        //    }
                        //}
                    }
                    //}
                }
            }
        }
Пример #13
0
        private void ExportReport(object sender, RadRoutedEventArgs e)
        {
            try
            {
                string extension = "xls";

                var dialog = new SaveFileDialog()
                {
                    DefaultExt  = extension,
                    Filter      = String.Format("{1} files (.{0})|.{0}|All files (.)|.", extension, "Excel"),
                    FilterIndex = 1
                };

                if (dialog.ShowDialog() == true)
                {
                    using (var stream = dialog.OpenFile())
                    {
                        using (var excel = new ExcelPackage(stream))
                        {
                            var reportName = CommonResourceManager.Instance.GetEnumResource(reportGadgetViewModel.ReportSelectedItemStat);

                            var ws = excel.Workbook.Worksheets.Add(reportName);

                            using (var ms = new MemoryStream())
                            {
                                GridViewReport.ElementExporting += GridViewReport_ElementExporting;

                                GridViewReport.Export(ms, new GridViewCsvExportOptions
                                {
                                    Format            = ExportFormat.Csv,
                                    Encoding          = Encoding.UTF8,
                                    ShowColumnHeaders = true,
                                    ShowColumnFooters = false,
                                    ShowGroupFooters  = false,
                                    ColumnDelimiter   = ";"
                                });

                                GridViewReport.ElementExporting -= GridViewReport_ElementExporting;

                                var csv = Encoding.UTF8.GetString(ms.ToArray()).Replace("\"", string.Empty);

                                var textFormat = new ExcelTextFormat
                                {
                                    Delimiter = ';'
                                };

                                var columns = csv.Split(new[] { Environment.NewLine }, StringSplitOptions.None);

                                if (columns.Length > 0)
                                {
                                    var columsCount = columns[0].Count(x => x == ';') + 1;
                                    textFormat.DataTypes = Enumerable.Range(0, columsCount).Select(x => eDataTypes.String).ToArray();
                                }

                                ws.Cells["A1"].LoadFromText(csv, textFormat);
                                ws.Cells.AutoFitColumns();

                                excel.Save();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogProvider.Log.Error(this, "Could not export report to excel format.", ex);
                ErrorBox.Show("Error", ex, "Unexpected error occurred. Please contact support.");
            }
        }
Пример #14
0
 protected void GridViewReport_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     LoadReport();
     GridViewReport.PageIndex = e.NewPageIndex;
     GridViewReport.DataBind();
 }
Пример #15
0
 private void BindGridView(string search)
 {
     GridViewReport.DataSource = da.GetEmployees(search);
     GridViewReport.DataBind();
 }