Beispiel #1
0
        public Boolean ApproveCheck(leaveauthority lv, double totaldays)
        {
            Boolean status = false;

            try
            {
                SqlConnection conn  = new SqlConnection(Login.connString);
                string        query = "select a.MaxSanctionLimit   from LeaveSanctionLimit a,EmployeeDesignation b where b.EmployeeID='" + Login.empLoggedIn + "' " +
                                      "and a.Designation = b.Designation and a.LeaveID = '" + lv.leaveid + "'";
                SqlCommand cmd = new SqlCommand(query, conn);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    if (reader.GetInt32(0) >= totaldays)
                    {
                        status = true;
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
                status = false;
            }
            return(status);
        }
Beispiel #2
0
        public Boolean CancelCancelRequest(leaveauthority lv)
        {
            Boolean status   = true;
            string  utString = "";

            try
            {
                string updateSQL = "update LeaveRequest set  Remarks='" + lv.remarks + "', " +
                                   "LeaveRequestStatus=11 " +
                                   "where UserID in (select userid from ViewUserEmployeeList where EmployeeID = '" + lv.EmployeeID + "') and RowID='" + lv.rowid + "'";
                utString = utString + updateSQL + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("approve", "LeaveRequest", "", 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 #3
0
        public Boolean RejectLeave(leaveauthority lv)
        {
            Boolean status   = true;
            string  utString = "";

            try
            {
                string updateSQL = "update LeaveRequest set " +
                                   "Remarks='" + lv.remarks + "'" +
                                   ", LeaveRequestStatus=99 " +
                                   ", ApproveTime=GetDate() " +
                                   " where  RowID='" + lv.rowid + "'";
                utString = utString + updateSQL + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("update", "LeaveRequest", "", 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 ApproveLeaveRequestModified(leaveauthority lv)
        {
            Boolean status   = true;
            string  utString = "";

            try
            {
                string updateSQL = "update LeaveRequest set  Remarks='" + lv.remarks + "', SanctionedToDate='" + lv.sanctionedTo + "', " +
                                   "documentstatus=99,LeaveRequestStatus=9 ,ApproveUser='******', " +
                                   "ApproveTime=GetDate() where RowID='" + lv.rowid + "'";
                utString = utString + updateSQL + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("approve", "LeaveRequest", "", 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 ApproveLeaveRequestCOmpoff(leaveauthority lv, int tp)
        {
            Boolean status    = true;
            string  utString  = "";
            string  updateSQL = "";

            try
            {
                updateSQL = "update LeaveRequest set  Remarks='" + lv.remarks + "', " +
                            " SanctionedFromDate = '" + lv.sanctionedFrom.ToString("yyyy-MM-dd") + "', SanctionedToDate ='" + lv.sanctionedTo.ToString("yyyy-MM-dd") + "'," +
                            "ForwardUser='******',ForwarderList='" + lv.ForwarderList + "', documentstatus=99, ApproveUser='******', ApproveTime=GetDate() " +
                            "where RowID='" + lv.rowid + "'";
                utString = utString + updateSQL + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("approve", "LeaveRequest", "", updateSQL) +
                           Main.QueryDelimiter;
                updateSQL = "update LeaveEarning set Status=2 where   RowID in" +
                            " (select top " + tp + " rowid from LeaveEarning where " +
                            " EmployeeID='" + lv.EmployeeID + "' and LeaveID='CO' and Status=1)";
                utString = utString + updateSQL + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("update", "LeaveEarning", "", 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 forwardleave(leaveauthority lv)
        {
            Boolean status   = true;
            string  utString = "";

            try
            {
                string updateSQL = "update LeaveRequest set DocumentStatus += 1 , forwardUser='******'" +
                                   ", Remarks='" + lv.remarks + "'" +
                                   ", ForwarderList='" + lv.ForwarderList + "'" +
                                   " where RowID='" + lv.rowid + "'";
                utString = utString + updateSQL + Main.QueryDelimiter;
                utString = utString +
                           ActivityLogDB.PrepareActivityLogQquerString("forward", "LeaveRequest", "", 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 <leaveauthority> getLeaveRemain(string empid, string leaveid)
        {
            leaveauthority        lvapp;
            List <leaveauthority> LVlist = new List <leaveauthority>();

            try
            {
                SqlConnection conn  = new SqlConnection(Login.connString);
                string        query = "select  DATEDIFF(DAY,a.SanctionedFromDate ,a.SanctionedToDate ) as totaldays  from LeaveRequest a, " +
                                      "(select b.UserID  from ViewUserEmployeeList b where b.EmployeeID = '" + empid + "') c " +
                                      " where a.UserID = c.UserID and a.LeaveID = '" + leaveid + "' and a.Status = 1 and a.DocumentStatus = 99 and a.LeaveRequestStatus in (1,11,10,9,7) and year(a.SanctionedFromDate)=year(GetDate()) ";
                SqlCommand cmd = new SqlCommand(query, conn);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    lvapp = new leaveauthority();
                    lvapp.leavepending = reader.IsDBNull(0)? 0 : reader.GetInt32(0);
                    LVlist.Add(lvapp);
                }
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
            }
            return(LVlist);
        }
Beispiel #8
0
        public List <leaveauthority> getLeaveLimit(string empid)
        {
            leaveauthority        lvapp;
            List <leaveauthority> LVlist = new List <leaveauthority>();

            try
            {
                SqlConnection conn  = new SqlConnection(Login.connString);
                string        query = "select a.LeaveCount,a.LeaveID from LeaveOB a where EmployeeID='" + empid + "'and a.year=year(GetDate())";
                SqlCommand    cmd   = new SqlCommand(query, conn);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    lvapp         = new leaveauthority();
                    lvapp.maxdays = reader.GetInt32(0);
                    lvapp.leaveid = reader.GetString(1);
                    LVlist.Add(lvapp);
                }
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
            }
            return(LVlist);
        }
Beispiel #9
0
        public List <leaveauthority> getFilteredLeaveApproval(string userList, int opt)
        {
            leaveauthority        lvpr;
            List <leaveauthority> LeaveApr = new List <leaveauthority>();

            try
            {
                SqlConnection conn   = new SqlConnection(Login.connString);
                string        query1 = "select b.EmployeeID,b.Name,c.Description, a.FromDate,a.ToDate,a.DocumentStatus," +
                                       "a.Status,a.LeaveRequestStatus,a.Remarks,a.ForwardUser,a.ForwarderList,a.ApproveUser,a.CreateTime,c.LeaveID,a.RowID,a.SanctionedFromDate,a.SanctionedToDate" +
                                       " from LeaveRequest a, Employee b,LeaveType c, ERPUser d" +
                                       " where b.EmployeeID = d.EmployeeID  and a.LeaveID = c.LeaveID and a.UserID = d.UserID and a.Status = 1 and a.DocumentStatus between 2 and 99" +
                                       " and  a.LeaveRequestStatus in (1,2,4,5) ";

                string query3 = "select b.EmployeeID,b.Name,c.Description, a.FromDate,a.ToDate,a.DocumentStatus, " +
                                "a.Status,a.LeaveRequestStatus,a.Remarks,a.ForwardUser,a.ForwarderList,a.ApproveUser,a.CreateTime,c.LeaveID,a.RowID,a.SanctionedFromDate,a.SanctionedToDate " +
                                " from LeaveRequest a, Employee b,LeaveType c, ERPUser d where b.EmployeeID = d.EmployeeID " +
                                " and a.LeaveID = c.LeaveID and a.UserID = d.UserID and a.Status <> 2 and " +
                                "   a.LeaveRequestStatus not in (4,8)";
                string query = "";
                switch (opt)
                {
                case 1:
                    query = query1;
                    break;

                case 3:
                    query = query3;
                    break;

                default:
                    query = "";
                    break;
                }
                SqlCommand cmd = new SqlCommand(query, conn);
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    lvpr                = new leaveauthority();
                    lvpr.EmployeeID     = reader.GetString(0);
                    lvpr.EmployeeName   = reader.GetString(1);
                    lvpr.Leavetype      = reader.GetString(2);
                    lvpr.fromdate       = reader.GetDateTime(3);
                    lvpr.todate         = reader.GetDateTime(4);
                    lvpr.documentStatus = reader.GetInt32(5);
                    lvpr.status         = reader.GetInt32(6);
                    lvpr.leavestatus    = reader.GetInt32(7);
                    lvpr.remarks        = reader.GetString(8);
                    lvpr.ForwardUser    = reader.IsDBNull(9) ? "" : reader.GetString(9);
                    lvpr.ForwarderList  = reader.IsDBNull(10) ? "" : reader.GetString(10);
                    lvpr.ApproveUser    = reader.IsDBNull(11)?"": reader.GetString(11);
                    lvpr.CreateTime     = reader.GetDateTime(12);
                    lvpr.leaveid        = reader.GetString(13);
                    lvpr.rowid          = reader.GetInt32(14);
                    lvpr.sanctionedFrom = reader.IsDBNull(15)?DateTime.Now: reader.GetDateTime(15);
                    lvpr.sanctionedTo   = reader.IsDBNull(16) ? DateTime.Now : reader.GetDateTime(16);
                    LeaveApr.Add(lvpr);
                }
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error");
            }
            return(LeaveApr);
        }