示例#1
0
    public static ReturnObject CheckAvailableOT(string otdate, string employee_id)
    {
        overtime_apply page_object       = new overtime_apply();
        DBConnection   db_connection     = new DBConnection();
        DateTime       Overtime_datetime = new DateTime();
        ReturnObject   return_object     = new ReturnObject();
        string         othrs             = string.Empty;
        string         query             = string.Empty;
        int            count             = 0;

        try
        {
            query = "select count(OT) from masterprocessdailydata where emp_id='" + employee_id + "' and pdate='" + otdate + "'";
            count = db_connection.ExecuteQuery_WithReturnValueInteger(query);
            if (count < 0)
            {
                return_object.status      = "error";
                return_object.return_data = "Overtime doesn't exist for the selected date.";
            }
            else
            {
                query = "select OT from masterprocessdailydata where emp_id='" + employee_id + "' and pdate='" + otdate + "'";
                othrs = db_connection.ExecuteQuery_WithReturnValueString(query);
                return_object.status      = "success";
                return_object.return_data = JsonConvert.SerializeObject(othrs, Formatting.Indented);
            }
        }
        catch (Exception ex)
        {
            Logger.LogException(ex, page, "CHECK_AVAILABLE_OT");
            return_object.status      = "error";
            return_object.return_data = "An error occurred while loading Overtime Hrs. Please try again. If the error persists, please contact Support.";
        }
        return(return_object);
    }
示例#2
0
    public static ReturnObject SubmitOT(string jsonData)
    {
        overtime_apply PageObject    = new overtime_apply();
        ReturnObject   return_object = new ReturnObject();
        DBConnection   db_connection = new DBConnection();
        string         employee_id   = string.Empty;
        string         otdate        = string.Empty;
        string         othrs         = string.Empty;
        string         query         = string.Empty;
        string         employee_name = string.Empty;
        int            otcount       = 0;

        try
        {
            JObject json_data = JObject.Parse(jsonData);
            employee_id = json_data["employee_id"].ToString();
            otdate      = json_data["date"].ToString();
            othrs       = json_data["available_ot"].ToString();

            query         = "select Emp_Name[Name] from employeeMaster where Emp_Code='" + employee_id + "'";
            employee_name = db_connection.ExecuteQuery_WithReturnValueString(query);
            otcount       = PageObject.CheckForOTRecord(employee_id, otdate);
            if (otcount > 0)
            {
                return_object.status      = "error";
                return_object.return_data = "OT Application already has been submitted for the selected dates.";
                return(return_object);
            }
            else
            {
                query = "insert into Overtime(empid, OTDate, OTHrs, Flag,MFlag, EmpName) values('" + employee_id + "', '" + otdate + "', '" + othrs + "', 1,1,'" + employee_name + "')";
                db_connection.ExecuteQuery_WithOutReturnValue(query);
                PageObject.SendMail(employee_id, otdate, othrs);
                return_object.status      = "success";
                return_object.return_data = "Overtime Application submitted successfully!";
            }
        }
        catch (Exception ex)
        {
            Logger.LogException(ex, page, "SUBMIT_OT");
            return_object.status      = "error";
            return_object.return_data = "An error occurred while submitting Overtime Application. Please try again. If the error persists, please contact Support.";
        }
        finally
        {
            PageObject.Dispose();
        }
        return(return_object);
    }