Beispiel #1
0
        public List <string> validateOfficeWDforHW(HolidayList ofhw)
        {
            string        offc    = "";
            List <string> offlist = new List <string>();

            try
            {
                string[] office = ofhw.officeID.Split(Main.delimiter1);
                foreach (string ofce in office)
                {
                    if (ofce != "")
                    {
                        string        query = "select Description from HolidayList where  Date='" + ofhw.date.ToString("yyyy-MM-dd") + "' and   officeIDs like '%" + ofce + "%'";
                        SqlConnection conn  = new SqlConnection(Login.connString);
                        SqlCommand    cmd   = new SqlCommand(query, conn);
                        conn.Open();
                        SqlDataReader reader = cmd.ExecuteReader();
                        if (!reader.Read())
                        {
                            offc = ofce;
                        }
                        conn.Close();
                        if (offc != "")
                        {
                            offlist.Add(offc);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("validateOfficeWDforHW Error!!!");
            }
            return(offlist);
        }
Beispiel #2
0
        public Boolean ValidateOfficeHW(HolidayList Ofc)
        {
            //Regex r = new Regex("[a-zA-Z]");
            Boolean stat = true;

            try
            {
                if (Ofc.Type == "" || Ofc.Type.Trim().Length == 0)
                {
                    stat = false;
                }
                if (Ofc.Description == "" || Ofc.Description.Trim().Length == 0)
                {
                    stat = false;
                }

                if (Ofc.officeID == "" || Ofc.officeID.Trim().Length == 0)
                {
                    stat = false;
                }
            }
            catch (Exception ex)
            {
            }
            return(stat);
        }
Beispiel #3
0
        public Boolean InsertLeaveOfficeWO(HolidayList ofh)
        {
            Boolean status   = true;
            string  utString = "";

            try
            {
                string updateSQL = "insert into OfficeWeekOff (officeID,Weekoffs)" +
                                   "values (" +
                                   "'" + ofh.officeID + "','" +
                                   ofh.Weekoffs + "')";
                utString = utString + updateSQL + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("insert", "OfficeWeekOff", "", updateSQL) +
                           Main.QueryDelimiter;
                if (!UpdateTable.UT(utString))
                {
                    status = false;
                }
            }
            catch (Exception)
            {
                MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
                status = false;
            }
            return(status);
        }
Beispiel #4
0
        public Boolean InsertLeaveOfficeHW(HolidayList ofh)
        {
            Boolean status   = true;
            string  utString = "";

            try
            {
                string updateSQL = "insert into HolidayList (Type,Date,officeIDs,Description)" +
                                   "values (" +
                                   "'" + ofh.Type + "'," +
                                   "'" + ofh.date.ToString("yyyy-MM-dd") + "','" +
                                   ofh.officeID + "','" +
                                   ofh.Description + "')";
                utString = utString + updateSQL + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("insert", "HolidayList", "", updateSQL) +
                           Main.QueryDelimiter;
                if (!UpdateTable.UT(utString))
                {
                    status = false;
                }
            }
            catch (Exception)
            {
                MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
                status = false;
            }
            return(status);
        }
Beispiel #5
0
        public Boolean UpdateOfficeWO(HolidayList Ofw)
        {
            Boolean status   = true;
            string  utString = "";

            try
            {
                string updateSQL = "Update OfficeWeekOff set WeekOffs='" + Ofw.Weekoffs + "'" +
                                   " where OfficeID='" + Ofw.officeID + "' and  RowID='" + Ofw.RowID + "'";
                utString = utString + updateSQL + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("update", "OfficeWeekOff", "", updateSQL) +
                           Main.QueryDelimiter;

                if (!UpdateTable.UT(utString))
                {
                    status = false;
                }
            }
            catch (Exception)
            {
                MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
                status = false;
            }
            return(status);
        }
Beispiel #6
0
        public Boolean UpdateOfficeHW(HolidayList Ofw)
        {
            Boolean status   = true;
            string  utString = "";

            try
            {
                string updateSQL = "Update HolidayList set Description='" + Ofw.Description + "',officeIDs='" + Ofw.officeID + "'," +
                                   " Date='" + Ofw.date.ToString("yyyy-MM-dd") + "' where RowID='" + Ofw.RowID + "'";
                utString = utString + updateSQL + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("update", "HolidayList", "", updateSQL) +
                           Main.QueryDelimiter;

                if (!UpdateTable.UT(utString))
                {
                    status = false;
                }
            }
            catch (Exception)
            {
                MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
                status = false;
            }
            return(status);
        }
Beispiel #7
0
        public List <HolidayList> getOfficeWD()
        {
            HolidayList        Wdlist;
            List <HolidayList> OfficeWDList = new List <HolidayList>();

            try
            {
                string        query = "select RowID,Type,Date,officeID,Description from OfficeWorkingDay  where datepart(yyyy,Date)='" + UpdateTable.getSQLDateTime().Year + "' ";
                SqlConnection conn  = new SqlConnection(Login.connString);
                SqlCommand    cmd   = new SqlCommand(query, conn);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Wdlist             = new HolidayList();
                    Wdlist.RowID       = reader.GetInt32(0);
                    Wdlist.Type        = reader.GetString(1);
                    Wdlist.date        = reader.GetDateTime(2);
                    Wdlist.officeID    = reader.GetString(3);
                    Wdlist.Description = reader.GetString(4);
                    OfficeWDList.Add(Wdlist);
                }
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
            }
            return(OfficeWDList);
        }
Beispiel #8
0
        public List <HolidayList> getOfficeWO()
        {
            HolidayList        WOlist;
            List <HolidayList> OfficeWOList = new List <HolidayList>();

            try
            {
                string        query = "select RowID,OfficeID,Weekoffs from OfficeWeekOff ";
                SqlConnection conn  = new SqlConnection(Login.connString);
                SqlCommand    cmd   = new SqlCommand(query, conn);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    WOlist          = new HolidayList();
                    WOlist.RowID    = reader.GetInt32(0);
                    WOlist.officeID = reader.GetString(1);
                    WOlist.Weekoffs = reader.GetString(2);
                    OfficeWOList.Add(WOlist);
                }
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
            }
            return(OfficeWOList);
        }
Beispiel #9
0
        //public Boolean validateOfficeWDforHW(officehw ofhw)
        //{
        //    int count = 0;
        //    Boolean status = false;
        //    try
        //    {
        //        string query = "select Description from OfficeHW where  Date='" + ofhw.date.ToString("yyyy-MM-dd") + "'";
        //        SqlConnection conn = new SqlConnection(Login.connString);
        //        SqlCommand cmd = new SqlCommand(query, conn);
        //        conn.Open();
        //        SqlDataReader reader = cmd.ExecuteReader();
        //        if (reader.Read())
        //        {
        //            status = true;
        //        }
        //        conn.Close();
        //    }
        //    catch (Exception ex)
        //    {
        //        status = false;
        //    }
        //    return status;
        //}

        public List <string> validateOfficeWDforWO(HolidayList ofhw)
        {
            string        offc    = "";
            List <string> offlist = new List <string>();

            try
            {
                string[] office = ofhw.officeID.Split(Main.delimiter1);
                foreach (string ofce in office)
                {
                    if (ofce != "")
                    {
                        string        query = "select Weekoffs from OfficeWeekOff where  OfficeID='" + ofce + "'";
                        SqlConnection conn  = new SqlConnection(Login.connString);
                        SqlCommand    cmd   = new SqlCommand(query, conn);
                        conn.Open();
                        SqlDataReader reader = cmd.ExecuteReader();
                        if (reader.Read())
                        {
                            List <DateTime> allweekenddate = GetAllweekends(UpdateTable.getSQLDateTime().Year, reader.GetString(0));
                            if (!allweekenddate.Contains(ofhw.date.Date))
                            {
                                offc = ofce;
                            }
                        }
                        else
                        {
                            offc = ofce;
                        }
                        conn.Close();
                        if (offc != "")
                        {
                            offlist.Add(offc);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("validateOfficeWDforWO Error!!!");
            }
            return(offlist);
        }
Beispiel #10
0
        public Boolean validateOfficeWD(HolidayList ofhw)
        {
            int     count  = 0;
            Boolean status = true;

            try
            {
                string        query = "select Description from OfficeWorkingDay where Type='" + ofhw.Type + "' and Date='" + ofhw.date.ToString("yyyy-MM-dd") + "'";
                SqlConnection conn  = new SqlConnection(Login.connString);
                SqlCommand    cmd   = new SqlCommand(query, conn);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    status = false;
                }
                conn.Close();
            }
            catch (Exception ex)
            {
                status = false;
            }
            return(status);
        }
Beispiel #11
0
        public Boolean validateOfficeWO(HolidayList ofhw)
        {
            int     count  = 0;
            Boolean status = true;

            try
            {
                string        query = "select WeekOffs from OfficeWeekOff where OfficeID='" + ofhw.officeID + "'";
                SqlConnection conn  = new SqlConnection(Login.connString);
                SqlCommand    cmd   = new SqlCommand(query, conn);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    status = false;
                }
                conn.Close();
            }
            catch (Exception ex)
            {
                status = false;
            }
            return(status);
        }