コード例 #1
0
    public static ReturnObject DeleteHoliday(string current)
    {
        masters_holiday page_object   = new masters_holiday();
        DBConnection    db_connection = new DBConnection();
        ReturnObject    return_object = new ReturnObject();
        string          query         = string.Empty;
        int             count         = 0;

        string
            company_code       = string.Empty,
            holiday_group_code = string.Empty,
            holiday_code       = string.Empty,
            holiday_from       = string.Empty,
            holiday_to         = string.Empty,
            holiday_type       = string.Empty;

        try
        {
            JObject current_data = JObject.Parse(current);
            holiday_code = current_data["holiday_code"].ToString();
            holiday_from = current_data["holiday_from"].ToString();
            holiday_to   = current_data["holiday_to"].ToString();
            company_code = current_data["company_code"].ToString();
            holiday_type = current_data["holiday_type"].ToString();

            query = "select count(*) from HolidayListDetails where holcode in(select distinct holcode from HolidayMaster where holcode = '" + holiday_code + "')";
            count = db_connection.GetRecordCount(query);
            if (count > 0)
            {
                return_object.status      = "error";
                return_object.return_data = "Holidays have been mapped to Holiday Group List. Please unassign the holidays from the Holiday Group List and try again.";
            }
            else
            {
                page_object.UpdateDatabase(holiday_code, null, holiday_from, holiday_to, company_code, "0", holiday_code, "D", holiday_type);

                return_object.status      = "success";
                return_object.return_data = "Holiday deleted successfully!";
            }
        }
        catch (Exception Ex)
        {
            Logger.LogException(Ex, page, "DELETE_HOLIDAY");

            return_object.status      = "error";
            return_object.return_data = "An error occurred while performing this operation. Please try again. If the error persists, please contact Support";

            throw;
        }
        finally
        {
            page_object.Dispose();
        }

        return(return_object);
    }
コード例 #2
0
    public static ReturnObject GetHolidayData(int page_number, bool is_filter, string filters)
    {
        masters_holiday page_object = new masters_holiday();
        DBConnection    db_connection = new DBConnection();
        DataTable       holiday_data_table = new DataTable();
        ReturnObject    return_object = new ReturnObject();
        string          employee_id, query, company_code = string.Empty;
        int             start_row        = (page_number - 1) * 30;
        int             number_of_record = page_number * 30 + 1;

        try
        {
            employee_id = HttpContext.Current.Session["employee_id"].ToString();
            // if employee is logged in then showing only that employee company  data (  done for royal group client first then implemnted in standard as well )
            if (employee_id != "")
            {
                query        = "select emp_company from employeemaster where emp_code='" + employee_id + "'";
                company_code = db_connection.ExecuteQuery_WithReturnValueString(query);
                query        = "select holcode as holiday_code, holname as holiday_name, holfrom as holiday_from, holto as holiday_to, holtype as holiday_type, CompanyCode as company_code, CompanyName as company_name FROM (select hl.holcode, hl.holname, convert(varchar,hl.holfrom,103) as holfrom, convert(varchar,hl.holto,103) as holto, hl.holtype, hl.CompanyCode, c.CompanyName, ROW_NUMBER() OVER (ORDER BY hl.holcode) as row from HolidayListDetails hl, CompanyMaster c where c.CompanyCode = hl.companycode and c.CompanyCode='" + company_code + "' ";
            }
            else
            {
                query = "select holcode as holiday_code, holname as holiday_name, holfrom as holiday_from, holto as holiday_to, holtype as holiday_type, CompanyCode as company_code, CompanyName as company_name FROM (select hl.holcode, hl.holname, convert(varchar,hl.holfrom,103) as holfrom, convert(varchar,hl.holto,103) as holto, hl.holtype, hl.CompanyCode, c.CompanyName, ROW_NUMBER() OVER (ORDER BY hl.holcode) as row from HolidayListDetails hl, CompanyMaster c where c.CompanyCode = hl.companycode ";
            }

            if (is_filter)
            {
                query = page_object.GetFilterQuery(filters, query);
            }

            query += " ) a where row > " + start_row + " and row < " + number_of_record;

            holiday_data_table = db_connection.ReturnDataTable(query);

            return_object.status      = "success";
            return_object.return_data = JsonConvert.SerializeObject(holiday_data_table, Formatting.Indented);
        }
        catch (Exception ex)
        {
            Logger.LogException(ex, page, "GET_HOLIDAY_DATA");

            return_object.status      = "error";
            return_object.return_data = "An error occurred while performing this operation. Please try again. If the error persists, please contact Support.";

            throw;
        }
        finally
        {
            page_object.Dispose();
        }

        return(return_object);
    }
コード例 #3
0
    public static ReturnObject EditHoliday(string current, string previous)
    {
        masters_holiday page_object           = new masters_holiday();
        DBConnection    db_connection         = new DBConnection();
        ReturnObject    return_object         = new ReturnObject();
        string          query                 = string.Empty;
        string          holiday_code          = string.Empty;
        string          holiday_name          = string.Empty;
        string          holiday_from          = string.Empty;
        string          holiday_to            = string.Empty;
        string          company_code          = string.Empty;
        string          holiday_type          = string.Empty;
        string          original_holiday_name = string.Empty;
        string          original_holiday_from = string.Empty;
        string          original_holiday_to   = string.Empty;
        int             count                 = 0;

        if (HttpContext.Current.Session["username"] == null)  // checking session expired or not
        {
            return_object = page_object.DoLogout();
        }
        else
        {
            try
            {
                JObject current_data  = JObject.Parse(current);
                JObject original_data = JObject.Parse(previous);

                holiday_code = current_data["holiday_code"].ToString();
                holiday_name = current_data["holiday_name"].ToString();
                holiday_from = current_data["holiday_from"].ToString();
                holiday_to   = current_data["holiday_to"].ToString();
                company_code = current_data["company_code"].ToString();
                holiday_type = current_data["holiday_type"].ToString();

                original_holiday_name = original_data["holiday_name"].ToString();
                original_holiday_from = original_data["holiday_from"].ToString();
                original_holiday_to   = original_data["holiday_to"].ToString();

                if (original_holiday_name != holiday_name)
                {
                    count = page_object.CheckHolidayName(holiday_name, company_code);
                    if (count > 0)
                    {
                        return_object.status      = "error";
                        return_object.return_data = "A Holiday with the same Name has been created. Please try again with a different Holiday Name.";

                        return(return_object);
                    }
                }
                Debug.Write(original_holiday_from + " " + holiday_from);
                if (original_holiday_from != holiday_from || original_holiday_to != holiday_to)
                {
                    count = page_object.CheckHolidayDates(holiday_from, holiday_to);
                    if (count > 0)
                    {
                        return_object.status      = "error";
                        return_object.return_data = "The selected From and To Dates have been mapped to another Holiday. Please try again with different Dates";

                        return(return_object);
                    }
                }

                page_object.UpdateDatabase(holiday_code, holiday_name, holiday_from, holiday_to, company_code, "0", holiday_code, "U", holiday_type);

                return_object.status      = "success";
                return_object.return_data = "Holiday edited successfully!";
            }
            catch (Exception Ex)
            {
                Logger.LogException(Ex, page, "EDIT_HOLIDAY");

                return_object.status      = "error";
                return_object.return_data = "An error occurred while performing this operation. Please try again. If the error persists, please contact Support";

                throw;
            }
            finally
            {
                page_object.Dispose();
            }
        }
        return(return_object);
    }
コード例 #4
0
    public static ReturnObject AddHoliday(string current)
    {
        masters_holiday page_object   = new masters_holiday();
        DBConnection    db_connection = new DBConnection();
        ReturnObject    return_object = new ReturnObject();

        int count = 0;

        string
            query        = string.Empty,
            holiday_code = string.Empty,
            holiday_name = string.Empty,
            holiday_from = string.Empty,
            holiday_to   = string.Empty,
            company_code = string.Empty,
            holiday_type = string.Empty;

        try
        {
            JObject current_data = JObject.Parse(current);
            holiday_code = current_data["holiday_code"].ToString();
            holiday_name = current_data["holiday_name"].ToString();
            holiday_from = current_data["holiday_from"].ToString();
            holiday_to   = current_data["holiday_to"].ToString();
            company_code = current_data["company_code"].ToString();
            holiday_type = current_data["holiday_type"].ToString();


            count = page_object.CheckHolidayCode(holiday_code, company_code);
            if (count > 0)
            {
                return_object.status      = "error";
                return_object.return_data = "A Holiday with the same Code has been created. Please try again with a different Holiday Code.";

                return(return_object);
            }

            count = page_object.CheckHolidayName(holiday_name, company_code);
            if (count > 0)
            {
                return_object.status      = "error";
                return_object.return_data = "A Holiday with the same Name has been created. Please try again with a different Holiday Name.";

                return(return_object);
            }

            count = page_object.CheckHolidayDates(holiday_from, holiday_to, company_code);
            if (count > 0)
            {
                return_object.status      = "error";
                return_object.return_data = "The selected From and To Dates have been mapped to another holiday. Please try again with different dates.";

                return(return_object);
            }

            page_object.UpdateDatabase(holiday_code, holiday_name, holiday_from, holiday_to, company_code, "0", "hol", "I", holiday_type);

            return_object.status      = "success";
            return_object.return_data = "Holiday added successfully!";
        }
        catch (Exception Ex)
        {
            Logger.LogException(Ex, page, "ADD_HOLIDAY");

            return_object.status      = "error";
            return_object.return_data = "An error occurred while performing this operation. Please try again. If the error persists, please contact Support.";

            throw;
        }
        finally
        {
            page_object.Dispose();
        }

        return(return_object);
    }