示例#1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            AttendanceReport rpt = new AttendanceReport();

            rpt.Site = this.Site;
            return(rpt);
        }
示例#2
0
        public override void btnsave_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                if (dataGridView1.Rows[i].Cells[2].Value == null)
                {
                    MessageBox.Show("Please Fill All Field Properly!");
                    return;
                }
            }
            // this changes i have done for bareli school date 10/02/2016. i put !=true and i comment all previous work//
            if (btnShowAttendance.Visible != true)
            {
                if (DialogResult.Yes.Equals(MessageBox.Show("Are You Sure To Save Attendance Date Of \" " + txtAttandanceDate.Text + " \" ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question)))
                {
                    System.Data.SqlClient.SqlTransaction trn = Connection.GetMyConnection().BeginTransaction();
                    Connection.SqlTransection("Delete From tbl_Attendance Where AttendanceDate = '" + txtAttandanceDate.Value.Date.ToString("MM/dd/yyyy") + "'",
                                              Connection.MyConnection, trn);
                    for (int i = 0; i < dataGridView1.Rows.Count; i++)
                    {
                        //foreach (DataGridViewRow r in dataGridView1.Rows)
                        //{
                        Connection.AllPerform("insert into tbl_Attendance (EmpNo, AttendanceDate, Attendance)values('" + dataGridView1.Rows[i].Cells[0].Value + "','" + txtAttandanceDate.Text + "','" + dataGridView1.Rows[i].Cells[2].Value + "')");
                        //Connection.SqlTransection("insert into tbl_Attendance (EmpNo, AttendanceDate, Attendance, TimeIn, TimeOut) "+
                        //    " Values('" + r.Cells[0].Value + "','" + txtAttandanceDate.Text + "','" +
                        //    r.Cells[2].Value + "','" + r.Cells[5].Value + "','" +
                        //    r.Cells[6].Value + "')",
                        //    Connection .MyConnection , trn );
                        //}
                    }
                    trn.Commit();
                }
            }
            else
            {
                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    DataSet ds11 = Connection.GetDataSet("select count(*) from tbl_Attendance where AttendanceDate='" + txtAttandanceDate.Value.Date + "' and empNo='" + dataGridView1.Rows[i].Cells[0].Value.ToString() + "'");
                    if (ds11.Tables[0].Rows[0][0].ToString() == "0")
                    {
                        Connection.AllPerform("insert into tbl_Attendance (EmpNo, AttendanceDate, Attendance)values('" + dataGridView1.Rows[i].Cells[0].Value + "','" + txtAttandanceDate.Text + "','" + dataGridView1.Rows[i].Cells[2].Value + "')");
                    }
                }
            }
            str1 = "SELECT     schoolname, schooladdress, affiliate_by, logoimage  FROM tbl_school";
            str1 = str1 + " SELECT tbl_Attendance.EmpNo, tbl_EmployeeInfo.EmpName, tbl_Attendance.Attendance,tbl_Attendance.AttendanceDate FROM tbl_Attendance INNER JOIN tbl_EmployeeInfo ON tbl_Attendance.EmpNo = tbl_EmployeeInfo.EmpNo WHERE (tbl_Attendance.AttendanceDate = '" + txtAttandanceDate.Value.Date + "') order by tbl_Attendance.EmpNo";
            DataSet ds = Connection.GetDataSet(str1);

            ds.WriteXmlSchema(@"" + Connection.GetAccessPathId() + @"Barcodes\a\TodaysAttendance.xsd");
            AttendanceReport cr1 = new AttendanceReport();

            cr1.PrintOptions.PaperOrientation = PaperOrientation.Portrait;
            cr1.PrintOptions.PaperSize        = CrystalDecisions.Shared.PaperSize.PaperLetter;
            cr1.SetDataSource(ds);
            ShowAllReports s = new ShowAllReports();

            s.crystalReportViewer1.ReportSource = cr1;
            s.Show();
        }