Ejemplo n.º 1
0
        public void init(bool isShowStaffInfo, string year, string weekNo)
        {
            DataSet _ds;

            this.SuspendLayout();
            int y=-1;
            foreach ( DataRow dr in dtRoster.Rows )
            {

                int i = Convert.ToInt32( dr["week_day"].ToString() );
                this.txtSunDate.Text = Convert.ToDateTime( dr["today"].ToString() ).AddDays(8-i).ToString("dd-MM-yyyy");
                this.txtMonDate.Text = Convert.ToDateTime( dr["today"].ToString() ).AddDays(2-i).ToString("dd-MM-yyyy");
                this.txtTueDate.Text = Convert.ToDateTime( dr["today"].ToString() ).AddDays(3-i).ToString("dd-MM-yyyy");
                this.txtWedDate.Text = Convert.ToDateTime( dr["today"].ToString() ).AddDays(4-i).ToString("dd-MM-yyyy");
                this.txtThuDate.Text = Convert.ToDateTime( dr["today"].ToString() ).AddDays(5-i).ToString("dd-MM-yyyy");
                this.txtFriDate.Text = Convert.ToDateTime( dr["today"].ToString() ).AddDays(6-i).ToString("dd-MM-yyyy");
                this.txtSatDate.Text = Convert.ToDateTime( dr["today"].ToString() ).AddDays(7-i).ToString("dd-MM-yyyy");
                dateSun = Convert.ToDateTime(dr["today"]).AddDays(8-i);
                dateMon = Convert.ToDateTime(dr["today"]).AddDays(2-i);
                dateTue = Convert.ToDateTime(dr["today"]).AddDays(3-i);
                dateWed = Convert.ToDateTime(dr["today"]).AddDays(4-i);
                dateThu = Convert.ToDateTime(dr["today"]).AddDays(5-i);
                dateFri = Convert.ToDateTime(dr["today"]).AddDays(6-i);
                dateSat = Convert.ToDateTime(dr["today"]).AddDays(7-i);
            }
            panelRosterDetails.DataBindings.Clear();
            panelRosterDetails.Controls.Remove(ACMSRosterDetails1);
            panelRosterDetails.Controls.Clear();

            foreach ( DataRow dr1 in dtRosterDetail.Rows )
            {
                this.ACMSRosterDetails1 = new ACMSRosterDetails();
                this.ACMSRosterDetails1.Location = new System.Drawing.Point(0, y);
                this.ACMSRosterDetails1.Name = "ACMSRosterDetails1";
                this.ACMSRosterDetails1.Size = new System.Drawing.Size(792, 54);
                this.ACMSRosterDetails1.TabIndex = 0;
                this.ACMSRosterDetails1.Click += new System.EventHandler(this._Click);
                y = y+55;
                this.ACMSRosterDetails1.year = dr1["rYear"].ToString();
                this.ACMSRosterDetails1.WeekNo = dr1["Week_No"].ToString();
                this.ACMSRosterDetails1.lblEmpID.Text = dr1["nEmployeeID"].ToString();
                this.ACMSRosterDetails1.lblJob.Text = "(" + dr1["strJobPositionCode"].ToString() + ")";
                this.ACMSRosterDetails1.lblEmpName.Text = dr1["strEmployeeName"].ToString();
                this.ACMSRosterDetails1.lblEmpDept.Text = "DEPT :" + dr1["DepartmentName"].ToString().ToUpper();
                this.ACMSRosterDetails1.SunTime.Text = ConvertToTime(dr1["sunStartTime"]) + " " + ConvertToTime(dr1["sunEndTime"]);
                this.ACMSRosterDetails1.MonTime.Text = ConvertToTime(dr1["monStartTime"]) + " " + ConvertToTime(dr1["monEndTime"]);
                this.ACMSRosterDetails1.TueTime.Text = ConvertToTime(dr1["tueStartTime"]) + " " + ConvertToTime(dr1["tueEndTime"]) ;
                this.ACMSRosterDetails1.WedTime.Text = ConvertToTime(dr1["wedStartTime"]) + " " + ConvertToTime(dr1["wedEndTime"]);
                this.ACMSRosterDetails1.ThuTime.Text = ConvertToTime(dr1["thuStartTime"]) + " " + ConvertToTime(dr1["thuEndTime"]);
                this.ACMSRosterDetails1.FriTime.Text = ConvertToTime(dr1["friStartTime"]) + " " + ConvertToTime(dr1["friEndTime"]);
                this.ACMSRosterDetails1.SatTime.Text = ConvertToTime(dr1["satStartTime"]) + " " + ConvertToTime(dr1["satEndTime"]);
                this.ACMSRosterDetails1.TotalHourWrk.Text = dr1["totalHour"].ToString();
                this.ACMSRosterDetails1.panelStaffInfo.Visible = isShowStaffInfo;
                this.panelRosterDetails.Controls.Add(ACMSRosterDetails1);

                // To Set Grey Color for Multi Shift Roster
                // Monday
                _ds = new DataSet();
                string strSQL="select nRosterID from tblRoster where dtDate='" + dateMon.ToString("yyyy-MM-dd") + "' and nEmployeeID=" + Convert.ToInt32(dr1["nEmployeeID"]);
                SqlHelper.FillDataset(SqlHelperUtils.connectionString,CommandType.StoredProcedure,"UP_GETDATA",_ds,new string[] {"Table"}, new SqlParameter("@strSQL", strSQL) );
                if (_ds.Tables[0].Rows.Count>1)
                {
                    ACMSRosterDetails1.panelMON.BackColor = Color.Gray;
                }
                // Tuesday
                _ds = new DataSet();
                strSQL="select nRosterID from tblRoster where dtDate='" + dateTue.ToString("yyyy-MM-dd") + "' and nEmployeeID=" + Convert.ToInt32(dr1["nEmployeeID"]);
                SqlHelper.FillDataset(SqlHelperUtils.connectionString,CommandType.StoredProcedure,"UP_GETDATA",_ds,new string[] {"Table"}, new SqlParameter("@strSQL", strSQL) );
                if (_ds.Tables[0].Rows.Count>1)
                {
                    ACMSRosterDetails1.panelTUE.BackColor = Color.Gray;
                }
                // Wednersday
                _ds = new DataSet();
                strSQL="select nRosterID from tblRoster where dtDate='" + dateWed.ToString("yyyy-MM-dd") + "' and nEmployeeID=" + Convert.ToInt32(dr1["nEmployeeID"]);
                SqlHelper.FillDataset(SqlHelperUtils.connectionString,CommandType.StoredProcedure,"UP_GETDATA",_ds,new string[] {"Table"}, new SqlParameter("@strSQL", strSQL) );
                if (_ds.Tables[0].Rows.Count>1)
                {
                    ACMSRosterDetails1.panelWED.BackColor = Color.Gray;
                }
                // Thursday
                _ds = new DataSet();
                strSQL="select nRosterID from tblRoster where dtDate='" + dateThu.ToString("yyyy-MM-dd") + "' and nEmployeeID=" + Convert.ToInt32(dr1["nEmployeeID"]);
                SqlHelper.FillDataset(SqlHelperUtils.connectionString,CommandType.StoredProcedure,"UP_GETDATA",_ds,new string[] {"Table"}, new SqlParameter("@strSQL", strSQL) );
                if (_ds.Tables[0].Rows.Count>1)
                {
                    ACMSRosterDetails1.panelTHU.BackColor = Color.Gray;
                }
                // Friday
                _ds = new DataSet();
                strSQL="select nRosterID from tblRoster where dtDate='" + dateFri.ToString("yyyy-MM-dd") + "' and nEmployeeID=" + Convert.ToInt32(dr1["nEmployeeID"]);
                SqlHelper.FillDataset(SqlHelperUtils.connectionString,CommandType.StoredProcedure,"UP_GETDATA",_ds,new string[] {"Table"}, new SqlParameter("@strSQL", strSQL) );
                if (_ds.Tables[0].Rows.Count>1)
                {
                    ACMSRosterDetails1.panelFRI.BackColor = Color.Gray;
                }
                // Saturday
                _ds = new DataSet();
                strSQL="select nRosterID from tblRoster where dtDate='" + dateSat.ToString("yyyy-MM-dd") + "' and nEmployeeID=" + Convert.ToInt32(dr1["nEmployeeID"]);
                SqlHelper.FillDataset(SqlHelperUtils.connectionString,CommandType.StoredProcedure,"UP_GETDATA",_ds,new string[] {"Table"}, new SqlParameter("@strSQL", strSQL) );
                if (_ds.Tables[0].Rows.Count>1)
                {
                    ACMSRosterDetails1.panelSAT.BackColor = Color.Gray;
                }

                // Sunday
                _ds = new DataSet();
                strSQL="select nRosterID from tblRoster where dtDate='" + dateSun.ToString("yyyy-MM-dd") + "' and nEmployeeID=" + Convert.ToInt32(dr1["nEmployeeID"]);
                SqlHelper.FillDataset(SqlHelperUtils.connectionString,CommandType.StoredProcedure,"UP_GETDATA",_ds,new string[] {"Table"}, new SqlParameter("@strSQL", strSQL) );
                if (_ds.Tables[0].Rows.Count>1)
                {
                    ACMSRosterDetails1.panelSUN.BackColor = Color.Gray;
                }

                // To Display Leave Color on Roster
                if ( IsShowLeave )
                {
                    DateTime startDate, endDate;
                    startDate=dateMon;
                    endDate = dateSun;

                    _ds = new DataSet();

                    SqlHelper.FillDataset(SqlHelperUtils.connectionString,CommandType.StoredProcedure,"pr_SelectLeave",_ds,new string[] {"table"},
                        new SqlParameter("@ddtStartDate", startDate),
                        new SqlParameter("@ddtEndDate", endDate),
                        new SqlParameter("@inEmployeeID", Convert.ToInt32(dr1["nEmployeeID"]))
                        );

                    dtLeaveDetails = _ds.Tables[0];

                    foreach(DataRow row in dtLeaveDetails.Rows)
                    {
                        SetLeaveColor(row);
                    }
                }
            }

            if (dtRosterDetail.Rows.Count == 0)
            {
                this.ACMSRosterDetails1 = new ACMSRosterDetails();
                this.ACMSRosterDetails1.Location = new System.Drawing.Point(0, y);
                this.ACMSRosterDetails1.Name = "ACMSRosterDetails1";
                this.ACMSRosterDetails1.Size = new System.Drawing.Size(792, 54);
                this.ACMSRosterDetails1.TabIndex = 0;
                this.ACMSRosterDetails1.Click += new System.EventHandler(this._Click);
                y = y+55;
                this.ACMSRosterDetails1.year = year;
                this.ACMSRosterDetails1.WeekNo = weekNo;
                this.ACMSRosterDetails1.lblEmpID.Text = string.Empty;
                this.ACMSRosterDetails1.lblEmpName.Text = string.Empty;
                this.ACMSRosterDetails1.lblEmpDept.Text = string.Empty;
                this.ACMSRosterDetails1.SunTime.Text =string.Empty;
                this.ACMSRosterDetails1.MonTime.Text = string.Empty;
                this.ACMSRosterDetails1.TueTime.Text = string.Empty;
                this.ACMSRosterDetails1.WedTime.Text = string.Empty;
                this.ACMSRosterDetails1.ThuTime.Text = string.Empty;
                this.ACMSRosterDetails1.FriTime.Text = string.Empty;
                this.ACMSRosterDetails1.SatTime.Text = string.Empty;
                this.ACMSRosterDetails1.TotalHourWrk.Text = string.Empty;
                this.ACMSRosterDetails1.panelStaffInfo.Visible = false;
                this.panelRosterDetails.Controls.Add(this.ACMSRosterDetails1);
            }
            this.ResumeLayout();
        }
Ejemplo n.º 2
0
        public void init(bool isShowStaffInfo, string year, string weekNo)
        {
            DataSet _ds;

            this.SuspendLayout();
            int y = -1;

            foreach (DataRow dr in dtRoster.Rows)
            {
                int i = Convert.ToInt32(dr["week_day"].ToString());
                this.txtSunDate.Text = Convert.ToDateTime(dr["today"].ToString()).AddDays(8 - i).ToString("dd-MM-yyyy");
                this.txtMonDate.Text = Convert.ToDateTime(dr["today"].ToString()).AddDays(2 - i).ToString("dd-MM-yyyy");
                this.txtTueDate.Text = Convert.ToDateTime(dr["today"].ToString()).AddDays(3 - i).ToString("dd-MM-yyyy");
                this.txtWedDate.Text = Convert.ToDateTime(dr["today"].ToString()).AddDays(4 - i).ToString("dd-MM-yyyy");
                this.txtThuDate.Text = Convert.ToDateTime(dr["today"].ToString()).AddDays(5 - i).ToString("dd-MM-yyyy");
                this.txtFriDate.Text = Convert.ToDateTime(dr["today"].ToString()).AddDays(6 - i).ToString("dd-MM-yyyy");
                this.txtSatDate.Text = Convert.ToDateTime(dr["today"].ToString()).AddDays(7 - i).ToString("dd-MM-yyyy");
                dateSun = Convert.ToDateTime(dr["today"]).AddDays(8 - i);
                dateMon = Convert.ToDateTime(dr["today"]).AddDays(2 - i);
                dateTue = Convert.ToDateTime(dr["today"]).AddDays(3 - i);
                dateWed = Convert.ToDateTime(dr["today"]).AddDays(4 - i);
                dateThu = Convert.ToDateTime(dr["today"]).AddDays(5 - i);
                dateFri = Convert.ToDateTime(dr["today"]).AddDays(6 - i);
                dateSat = Convert.ToDateTime(dr["today"]).AddDays(7 - i);
            }
            panelRosterDetails.DataBindings.Clear();
            panelRosterDetails.Controls.Remove(ACMSRosterDetails1);
            panelRosterDetails.Controls.Clear();

            foreach (DataRow dr1 in dtRosterDetail.Rows)
            {
                this.ACMSRosterDetails1          = new ACMSRosterDetails();
                this.ACMSRosterDetails1.Location = new System.Drawing.Point(0, y);
                this.ACMSRosterDetails1.Name     = "ACMSRosterDetails1";
                this.ACMSRosterDetails1.Size     = new System.Drawing.Size(792, 54);
                this.ACMSRosterDetails1.TabIndex = 0;
                this.ACMSRosterDetails1.Click   += new System.EventHandler(this._Click);
                y = y + 55;
                this.ACMSRosterDetails1.year                   = dr1["rYear"].ToString();
                this.ACMSRosterDetails1.WeekNo                 = dr1["Week_No"].ToString();
                this.ACMSRosterDetails1.lblEmpID.Text          = dr1["nEmployeeID"].ToString();
                this.ACMSRosterDetails1.lblJob.Text            = "(" + dr1["strJobPositionCode"].ToString() + ")";
                this.ACMSRosterDetails1.lblEmpName.Text        = dr1["strEmployeeName"].ToString();
                this.ACMSRosterDetails1.lblEmpDept.Text        = "DEPT :" + dr1["DepartmentName"].ToString().ToUpper();
                this.ACMSRosterDetails1.SunTime.Text           = ConvertToTime(dr1["sunStartTime"]) + " " + ConvertToTime(dr1["sunEndTime"]);
                this.ACMSRosterDetails1.MonTime.Text           = ConvertToTime(dr1["monStartTime"]) + " " + ConvertToTime(dr1["monEndTime"]);
                this.ACMSRosterDetails1.TueTime.Text           = ConvertToTime(dr1["tueStartTime"]) + " " + ConvertToTime(dr1["tueEndTime"]);
                this.ACMSRosterDetails1.WedTime.Text           = ConvertToTime(dr1["wedStartTime"]) + " " + ConvertToTime(dr1["wedEndTime"]);
                this.ACMSRosterDetails1.ThuTime.Text           = ConvertToTime(dr1["thuStartTime"]) + " " + ConvertToTime(dr1["thuEndTime"]);
                this.ACMSRosterDetails1.FriTime.Text           = ConvertToTime(dr1["friStartTime"]) + " " + ConvertToTime(dr1["friEndTime"]);
                this.ACMSRosterDetails1.SatTime.Text           = ConvertToTime(dr1["satStartTime"]) + " " + ConvertToTime(dr1["satEndTime"]);
                this.ACMSRosterDetails1.TotalHourWrk.Text      = dr1["totalHour"].ToString();
                this.ACMSRosterDetails1.panelStaffInfo.Visible = isShowStaffInfo;
                this.panelRosterDetails.Controls.Add(ACMSRosterDetails1);

                // To Set Grey Color for Multi Shift Roster
                // Monday
                _ds = new DataSet();
                string strSQL = "select nRosterID from tblRoster where dtDate='" + dateMon.ToString("yyyy-MM-dd") + "' and nEmployeeID=" + Convert.ToInt32(dr1["nEmployeeID"]);
                SqlHelper.FillDataset(SqlHelperUtils.connectionString, CommandType.StoredProcedure, "UP_GETDATA", _ds, new string[] { "Table" }, new SqlParameter("@strSQL", strSQL));
                if (_ds.Tables[0].Rows.Count > 1)
                {
                    ACMSRosterDetails1.panelMON.BackColor = Color.Gray;
                }
                // Tuesday
                _ds    = new DataSet();
                strSQL = "select nRosterID from tblRoster where dtDate='" + dateTue.ToString("yyyy-MM-dd") + "' and nEmployeeID=" + Convert.ToInt32(dr1["nEmployeeID"]);
                SqlHelper.FillDataset(SqlHelperUtils.connectionString, CommandType.StoredProcedure, "UP_GETDATA", _ds, new string[] { "Table" }, new SqlParameter("@strSQL", strSQL));
                if (_ds.Tables[0].Rows.Count > 1)
                {
                    ACMSRosterDetails1.panelTUE.BackColor = Color.Gray;
                }
                // Wednersday
                _ds    = new DataSet();
                strSQL = "select nRosterID from tblRoster where dtDate='" + dateWed.ToString("yyyy-MM-dd") + "' and nEmployeeID=" + Convert.ToInt32(dr1["nEmployeeID"]);
                SqlHelper.FillDataset(SqlHelperUtils.connectionString, CommandType.StoredProcedure, "UP_GETDATA", _ds, new string[] { "Table" }, new SqlParameter("@strSQL", strSQL));
                if (_ds.Tables[0].Rows.Count > 1)
                {
                    ACMSRosterDetails1.panelWED.BackColor = Color.Gray;
                }
                // Thursday
                _ds    = new DataSet();
                strSQL = "select nRosterID from tblRoster where dtDate='" + dateThu.ToString("yyyy-MM-dd") + "' and nEmployeeID=" + Convert.ToInt32(dr1["nEmployeeID"]);
                SqlHelper.FillDataset(SqlHelperUtils.connectionString, CommandType.StoredProcedure, "UP_GETDATA", _ds, new string[] { "Table" }, new SqlParameter("@strSQL", strSQL));
                if (_ds.Tables[0].Rows.Count > 1)
                {
                    ACMSRosterDetails1.panelTHU.BackColor = Color.Gray;
                }
                // Friday
                _ds    = new DataSet();
                strSQL = "select nRosterID from tblRoster where dtDate='" + dateFri.ToString("yyyy-MM-dd") + "' and nEmployeeID=" + Convert.ToInt32(dr1["nEmployeeID"]);
                SqlHelper.FillDataset(SqlHelperUtils.connectionString, CommandType.StoredProcedure, "UP_GETDATA", _ds, new string[] { "Table" }, new SqlParameter("@strSQL", strSQL));
                if (_ds.Tables[0].Rows.Count > 1)
                {
                    ACMSRosterDetails1.panelFRI.BackColor = Color.Gray;
                }
                // Saturday
                _ds    = new DataSet();
                strSQL = "select nRosterID from tblRoster where dtDate='" + dateSat.ToString("yyyy-MM-dd") + "' and nEmployeeID=" + Convert.ToInt32(dr1["nEmployeeID"]);
                SqlHelper.FillDataset(SqlHelperUtils.connectionString, CommandType.StoredProcedure, "UP_GETDATA", _ds, new string[] { "Table" }, new SqlParameter("@strSQL", strSQL));
                if (_ds.Tables[0].Rows.Count > 1)
                {
                    ACMSRosterDetails1.panelSAT.BackColor = Color.Gray;
                }


                // Sunday
                _ds    = new DataSet();
                strSQL = "select nRosterID from tblRoster where dtDate='" + dateSun.ToString("yyyy-MM-dd") + "' and nEmployeeID=" + Convert.ToInt32(dr1["nEmployeeID"]);
                SqlHelper.FillDataset(SqlHelperUtils.connectionString, CommandType.StoredProcedure, "UP_GETDATA", _ds, new string[] { "Table" }, new SqlParameter("@strSQL", strSQL));
                if (_ds.Tables[0].Rows.Count > 1)
                {
                    ACMSRosterDetails1.panelSUN.BackColor = Color.Gray;
                }


                // To Display Leave Color on Roster
                if (IsShowLeave)
                {
                    DateTime startDate, endDate;
                    startDate = dateMon;
                    endDate   = dateSun;

                    _ds = new DataSet();

                    SqlHelper.FillDataset(SqlHelperUtils.connectionString, CommandType.StoredProcedure, "pr_SelectLeave", _ds, new string[] { "table" },
                                          new SqlParameter("@ddtStartDate", startDate),
                                          new SqlParameter("@ddtEndDate", endDate),
                                          new SqlParameter("@inEmployeeID", Convert.ToInt32(dr1["nEmployeeID"]))
                                          );

                    dtLeaveDetails = _ds.Tables[0];

                    foreach (DataRow row in dtLeaveDetails.Rows)
                    {
                        SetLeaveColor(row);
                    }
                }
            }

            if (dtRosterDetail.Rows.Count == 0)
            {
                this.ACMSRosterDetails1          = new ACMSRosterDetails();
                this.ACMSRosterDetails1.Location = new System.Drawing.Point(0, y);
                this.ACMSRosterDetails1.Name     = "ACMSRosterDetails1";
                this.ACMSRosterDetails1.Size     = new System.Drawing.Size(792, 54);
                this.ACMSRosterDetails1.TabIndex = 0;
                this.ACMSRosterDetails1.Click   += new System.EventHandler(this._Click);
                y = y + 55;
                this.ACMSRosterDetails1.year                   = year;
                this.ACMSRosterDetails1.WeekNo                 = weekNo;
                this.ACMSRosterDetails1.lblEmpID.Text          = string.Empty;
                this.ACMSRosterDetails1.lblEmpName.Text        = string.Empty;
                this.ACMSRosterDetails1.lblEmpDept.Text        = string.Empty;
                this.ACMSRosterDetails1.SunTime.Text           = string.Empty;
                this.ACMSRosterDetails1.MonTime.Text           = string.Empty;
                this.ACMSRosterDetails1.TueTime.Text           = string.Empty;
                this.ACMSRosterDetails1.WedTime.Text           = string.Empty;
                this.ACMSRosterDetails1.ThuTime.Text           = string.Empty;
                this.ACMSRosterDetails1.FriTime.Text           = string.Empty;
                this.ACMSRosterDetails1.SatTime.Text           = string.Empty;
                this.ACMSRosterDetails1.TotalHourWrk.Text      = string.Empty;
                this.ACMSRosterDetails1.panelStaffInfo.Visible = false;
                this.panelRosterDetails.Controls.Add(this.ACMSRosterDetails1);
            }
            this.ResumeLayout();
        }