コード例 #1
0
        //ONCE THE ASYNC IMAGE GET IS DONE
        //1. LOAD THE IMAGE TO THE PICTURE BOX
        //2. DISCONNECT DYNAMIC DBCONNECTOR
        //3. START TO ASYNC GET ATTENDANCE

        private void bgw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            lblaction.Text = "completed...";
            if (emp.pic != null)
            {
                MemoryStream ms = new MemoryStream(emp.pic);
                pbEmpPic.Image    = Image.FromStream(ms);
                pbEmpPic.SizeMode = PictureBoxSizeMode.Zoom;
            }
            else
            {
                pbEmpPic.Image    = Properties.Resources.noimagefound;
                pbEmpPic.SizeMode = PictureBoxSizeMode.Zoom;
            }



            //PUT THE SCHEDULE ON THE LISTVIEW
            if (empsched != null)
            {
                lbschedule.Items.Add("Monday").SubItems.Add(empsched.mon);
                lbschedule.Items.Add("Tuesday").SubItems.Add(empsched.tue);
                lbschedule.Items.Add("Wednesday").SubItems.Add(empsched.wed);
                lbschedule.Items.Add("Thursday").SubItems.Add(empsched.thu);
                lbschedule.Items.Add("Friday").SubItems.Add(empsched.fri);
                lbschedule.Items.Add("Saturday").SubItems.Add(empsched.sat);
                lbschedule.Items.Add("Sunday").SubItems.Add(empsched.sun);
            }
            else
            {
                lbschedule.Items.Add("No schedule yet...");
            }



            lblnamepos.Text = emp.empid + " - " + emp.lname.ToUpper() + ", " + emp.fname.ToUpper() + " " + emp.mname.ToUpper() + " - " + emp.position.ToUpper();
            dbcon.DISCONNECT();

            lblaction.Text = "retrieving attendance...";
            bgwattendance.RunWorkerAsync();
            timer1.Enabled = false;
            pb.Value       = 10;
        }
コード例 #2
0
        private void frmCutoffAttendanceReport_Load(object sender, EventArgs e)
        {
            this.rptViewer.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local;
            this.rptViewer.LocalReport.DataSources.Clear();


            string path      = System.Reflection.Assembly.GetExecutingAssembly().Location.ToString();
            var    directory = System.IO.Path.GetDirectoryName(path);

            directory += "\\reports\\atttendance_cutoff.rdlc";


            //C:\projects\MMG-PIAPS\MMG-PIAPS\bin\Debug\reports\cutoff_attendance.rdlc
            //C:\projects\MMG-PIAPS\MMG-PIAPS\bin\Debug\reports\atttendance_cutoff.rdlc
            this.rptViewer.LocalReport.ReportPath = directory;

            //MessageBox.Show(directory);

            Employee emp = new Employee();

            emp.branch = "2";

            DataTable dt = emp.SELECT_BY_BRANCH();



            DataSet1 ds = new DataSet1();

            cutoffdt = ds.Tables["cutoffattendance"];



            //CREATE AN IMAGE COLUMN
            //SET THE IMAGE VALUE
            //THEN ADD TO DATASET FOR REPORT REFERENCE
            DataColumn colByteArray = new DataColumn("emp_img");

            colByteArray.DataType = System.Type.GetType("System.Byte[]");
            dt.Columns.Add(colByteArray);

            foreach (DataRow item in dt.Rows)
            {
                Employee e1 = new Employee();
                e1.empid        = item["empid"].ToString();
                item["emp_img"] = e1.GET_IMAGE_BY_ID();

                //=====================================


                //FOR SUBREPORT DATASOURCE
                //POPULATE THE DATASET, FOR SUBREPORT USAGE
                //WITH THE EMPLOYEE'S ATTENDANCE FROM BIOMETRICS
                //THEN CHECKS THE ATTENDANCE WHETHER GOOD (IN,OUT,IN,OUT)
                //OR INAPPROPRIATE (IN ONLY, OR (IN, OUT, IN), OR (IN,OUT,OUT,IN,OUT)
                //AND OTHER IMPROPER ATTENDANCE LOGS
                int x = 1;
                foreach (DataRow cutoffitem in cutoffdetailsdt.Rows)
                {
                    DataRow c = cutoffdt.NewRow();

                    DateTime d = Convert.ToDateTime(cutoffitem["date_"].ToString());
                    c.BeginEdit();
                    c["empid"] = e1.empid;
                    c["no"]    = x;
                    c["date_"] = d.ToString("MM/dd/yyyy");


                    //CRREATE A DYNAMIC CONNECTION TO DB
                    non_static_dbcon cn = new non_static_dbcon();

                    //COMPARE CUTOFF DATE WITH ATTENDANCE HERE
                    //==============================================
                    String attendance;

                    String status;

                    if (cn.CONNECT())
                    {
                        Attendance att = new Attendance();
                        att.empid = e1.empid;


                        attendance = att.SELECT_STR_BY_EMPID_BY_DATE(d, cn);

                        String[] attarr = attendance.Split(',');

                        if (attendance != "")
                        {
                            if ((attarr.Length == 3) || (attarr.Length > 4))
                            {
                                status = "INAPPROPRIATE";
                            }
                            else if ((attarr.Length == 2) || attarr.Length == 4)
                            {
                                status = "GOOD";
                            }
                            else
                            {
                                status = "INAPPROPRIATE";
                            }
                        }
                        else
                        {
                            status = "";
                        }
                    }
                    else
                    {
                        attendance = "";
                        status     = "";
                    }

                    cn.DISCONNECT();

                    c["attendance_"] = attendance;
                    //===============================================
                    c["day_type"] = cutoffitem["day_type"].ToString();



                    c["status_"] = status;
                    cutoffdt.Rows.Add(c);

                    x++;
                }

                //=====================================
            }//end foreach item in dt.rows
            ReportDataSource r = new ReportDataSource("DataSet1", dt);



            this.rptViewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(localReport_SubreportProcessing);



            //SET REPORT PARAMETER
            ReportParameter from_date = new ReportParameter("cutoff_date_from", cutoff_date_from.ToString("MM/dd/yyyy"));
            ReportParameter to_date   = new ReportParameter("cutoff_date_to", cutoff_date_to.ToString("MM/dd/yyyy"));


            rptViewer.LocalReport.SetParameters(from_date);
            rptViewer.LocalReport.SetParameters(to_date);

            this.rptViewer.LocalReport.DataSources.Add(r);

            // this.rptViewer.SetDisplayMode(DisplayMode.PrintLayout);
            this.rptViewer.RefreshReport();
        }