コード例 #1
0
        public string ChangeStatus(string id, string status)
        {
            string        strResponse = string.Empty;
            FinancialYear holidayData = null;
            bool          Status      = Convert.ToBoolean(status);
            int           did         = Convert.ToInt32(id);

            using (var db = new DbContext(CONNECTION_NAME))
            {
                try
                {
                    holidayData = db.Set <FinancialYear>().Where(s => s.FinancialYearId == did).FirstOrDefault <FinancialYear>();
                    if (holidayData == null)
                    {
                        return(null);
                    }
                    holidayData.IsDeleted = Status;

                    db.Entry(holidayData).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    strResponse = "Status Changed Successfully";
                }
                catch (Exception ex)
                {
                    strResponse = ex.Message.ToString();
                }
            }
            return(strResponse);
        }
コード例 #2
0
ファイル: HolidayCalendarDAC.cs プロジェクト: war-man/EC
        public string AddHoliday(int accountid, string HolidayName, string HolidayDate, string FinancialYearId, string isOptionalHoliday, string isDeleted)
        {
            string          strResponse     = string.Empty;
            int             financialyearid = Convert.ToInt16(FinancialYearId);
            bool            isoptionalid    = Convert.ToBoolean(isOptionalHoliday);
            bool            isactive        = Convert.ToBoolean(isDeleted);
            UserSessionInfo objinfo         = new UserSessionInfo();
            int             userid          = objinfo.UserId;
            DateTime        holidaydate     = Convert.ToDateTime(HolidayDate);
            int             year            = holidaydate.Year;

            using (var db = new DbContext(CONNECTION_NAME))
            {
                HolidayCalendar holidayDetails = db.Set <HolidayCalendar>().Where(s => (s.HolidayName == HolidayName && s.AccountID == accountid && s.ProjectID == null && s.Year == financialyearid && s.isDeleted == false)).FirstOrDefault <HolidayCalendar>();
                HolidayCalendar holidayDetail  = db.Set <HolidayCalendar>().Where(s => (s.HolidayDate == holidaydate && s.AccountID == accountid && s.ProjectID == null && s.Year == financialyearid && s.isDeleted == false)).FirstOrDefault <HolidayCalendar>();
                FinancialYear   startYear      = db.Set <FinancialYear>().Where(s => s.FinancialYearId == financialyearid).FirstOrDefault <FinancialYear>();
                if (holidayDetails != null)
                {
                    return(strResponse = "HolidayName Already Exist In This Account");
                }

                if (holidayDetail != null)
                {
                    return(strResponse = "HolidayDate Already Exist In This Account");
                }
                if (year != startYear.StartDate)
                {
                    return(strResponse = "Please Select Correct Financial Year");
                }
                try
                {
                    HolidayCalendar holidayData = new HolidayCalendar();
                    holidayData.AccountID   = accountid;
                    holidayData.Year        = financialyearid;
                    holidayData.HolidayName = HolidayName;
                    holidayData.HolidayDate = Convert.ToDateTime(HolidayDate);
                    // holidayData.Year = Convert.ToInt16(holiday.Year);
                    holidayData.isOptionalHoliday = isoptionalid;
                    holidayData.isDeleted         = isactive;
                    holidayData.CreatedBy         = userid;
                    holidayData.CreatedDate       = System.DateTime.Now;

                    db.Set <HolidayCalendar>().Add(holidayData);
                    db.SaveChanges();
                    strResponse = "Holiday Successfully Created";
                }
                catch (Exception ex)
                {
                    strResponse = ex.Message.ToString();
                }
            }
            return(strResponse);
        }
コード例 #3
0
        public string SaveFinancialyears(string startyear /*, string endyear*/, string status)
        {
            string strresponse = "";
            int    strtyear    = Convert.ToInt32(startyear);
            // int edyear = Convert.ToInt32(endyear);
            int           sttus = Convert.ToInt32(status);
            FinancialYear fid   = new FinancialYear();
            bool          b     = Convert.ToBoolean(sttus);

            try
            {
                using (var db = new DbContext(CONNECTION_NAME))
                {
                    fid = db.Set <FinancialYear>().Where(s => s.StartDate == strtyear).FirstOrDefault <FinancialYear>();
                    FinancialYear fiy = db.Set <FinancialYear>().Where(s => s.StartDate == strtyear).FirstOrDefault <FinancialYear>();
                    if (fid != null)
                    {
                        return(strresponse = "Financial year Already Exist");
                    }
                    if (fiy != null)
                    {
                        return(strresponse = "Financial year Already Existed");
                    }
                    db.Set <FinancialYear>().Add(new FinancialYear
                    {
                        StartDate = strtyear,
                        // EndDate= edyear,
                        IsDeleted = b
                    });
                    db.SaveChanges();
                    strresponse = "Financial year Successfully Added";
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(strresponse);
        }
コード例 #4
0
ファイル: HolidayCalendarDAC.cs プロジェクト: war-man/EC
        public string UpdateHoliday(string HolidayCalendarID, string HolidayName, string HolidayDate, string FinancialYearId, string isOptionalHoliday, string isActive, string HolidayCalendarProjectId)
        {
            HolidayCalendar holidayDetails = null;

            string          strResponse     = string.Empty;
            int             hcid            = Convert.ToInt32(HolidayCalendarID);
            int             financialyearid = Convert.ToInt16(FinancialYearId);
            bool            isoptionalid    = Convert.ToBoolean(isOptionalHoliday);
            bool            isactive        = Convert.ToBoolean(isActive);
            UserSessionInfo objinfo         = new UserSessionInfo();
            int             userid          = objinfo.UserId;
            int             accountid       = objinfo.AccountId;
            DateTime        holidaydate     = Convert.ToDateTime(HolidayDate);
            int             Pid             = Convert.ToInt32(HolidayCalendarProjectId);
            int             year            = holidaydate.Year;

            using (var db = new DbContext(CONNECTION_NAME))
            {
                try
                {
                    holidayDetails = db.Set <HolidayCalendar>().Where(s => s.HolidayCalendarID == hcid).FirstOrDefault <HolidayCalendar>();
                    HolidayCalendar holidayDet    = db.Set <HolidayCalendar>().Where(s => (s.HolidayName == HolidayName && s.HolidayCalendarID != hcid && s.AccountID == accountid && s.Year == financialyearid && s.isDeleted == false)).FirstOrDefault <HolidayCalendar>();
                    HolidayCalendar holidayDetail = db.Set <HolidayCalendar>().Where(s => (s.HolidayDate == holidaydate && s.HolidayCalendarID != hcid && s.AccountID == accountid && s.Year == financialyearid && s.isDeleted == false)).FirstOrDefault <HolidayCalendar>();
                    FinancialYear   startYear     = db.Set <FinancialYear>().Where(s => s.FinancialYearId == financialyearid).FirstOrDefault <FinancialYear>();

                    if (holidayDet != null)
                    {
                        return(strResponse = "HolidayName Already Exist");
                    }

                    if (holidayDetail != null)
                    {
                        return(strResponse = "HolidayDate Already Exist");
                    }
                    if (year != startYear.StartDate)
                    {
                        return(strResponse = "Please Select Correct financialyear");
                    }
                    if (holidayDetails == null)
                    {
                        return(null);
                    }
                    //holidayDetails.AccountID = holiday.AccountID;
                    holidayDetails.HolidayName       = HolidayName;
                    holidayDetails.HolidayDate       = Convert.ToDateTime(HolidayDate);
                    holidayDetails.Year              = financialyearid;
                    holidayDetails.isOptionalHoliday = isoptionalid;
                    holidayDetails.isDeleted         = isactive;
                    holidayDetails.ModifiedBy        = userid;
                    holidayDetails.ModifiedDate      = System.DateTime.Now;
                    holidayDetails.CL_ProjectID      = Pid;

                    db.Entry(holidayDetails).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    strResponse = "Holiday successfully updated";
                }
                catch (Exception ex)
                {
                    strResponse = ex.Message.ToString();
                }
                return(strResponse);
            }
        }
コード例 #5
0
ファイル: HolidayCalendarDAC.cs プロジェクト: war-man/EC
        public string AddHolidayforclient(List <HolidayCalendarEntity> holidays)
        {
            string strResponse = string.Empty;

            for (int i = 0; i <= holidays.Count - 1; i++)
            {
                int             financialyearid = Convert.ToInt16(holidays[i].FinancialYearId);
                string          holidayname     = holidays[i].HolidayName;
                bool            isoptionalid    = Convert.ToBoolean(holidays[i].isOptionalHoliday);
                bool            isactive        = Convert.ToBoolean(holidays[i].isActive);
                UserSessionInfo objinfo         = new UserSessionInfo();
                int             userid          = objinfo.UserId;
                int             accountid       = objinfo.AccountId;
                int             peojectid       = Convert.ToInt32(holidays[i].ProjectID);
                int?            ClientCalPid    = Convert.ToInt32(holidays[i].HolidayCalendarProjectId);
                DateTime        holidaydate     = Convert.ToDateTime(holidays[i].HolidayDate);
                int             year            = holidaydate.Year;
                try
                {
                    using (var db = new DbContext(CONNECTION_NAME))
                    {
                        HolidayCalendar holidayDetails = db.Set <HolidayCalendar>().Where(s => (s.HolidayName == holidayname && s.AccountID == accountid && s.ProjectID == peojectid && s.Year == financialyearid)).FirstOrDefault <HolidayCalendar>();
                        HolidayCalendar holidayDetail  = db.Set <HolidayCalendar>().Where(s => (s.HolidayDate == holidaydate && s.AccountID == accountid && s.ProjectID == peojectid && s.Year == financialyearid)).FirstOrDefault <HolidayCalendar>();
                        FinancialYear   startYear      = db.Set <FinancialYear>().Where(s => s.FinancialYearId == financialyearid).FirstOrDefault <FinancialYear>();


                        //if (holidayDetails != null && ClientCalPid == null)
                        //{
                        //    return strResponse = "HolidayName Already Exist In This Project";
                        //}

                        //if (holidayDetail != null && ClientCalPid != null)
                        //{
                        //    return strResponse = "HolidayDate Already Exist In This Project";
                        //}
                        if (year != startYear.StartDate)
                        {
                            return(strResponse = "Please Select Correct Financialyear");
                        }

                        HolidayCalendar holidayData = new HolidayCalendar();
                        holidayData.AccountID   = accountid;
                        holidayData.Year        = financialyearid;
                        holidayData.HolidayName = holidays[i].HolidayName;
                        holidayData.HolidayDate = Convert.ToDateTime(holidays[i].HolidayDate);
                        // holidayData.Year = Convert.ToInt16(holiday.Year);
                        holidayData.isOptionalHoliday = isoptionalid;
                        //holidayData.isActive = isactive;
                        holidayData.CreatedBy    = userid;
                        holidayData.CreatedDate  = System.DateTime.Now;
                        holidayData.ProjectID    = peojectid;
                        holidayData.CL_ProjectID = ClientCalPid;
                        holidayData.isDeleted    = isactive;
                        db.Set <HolidayCalendar>().Add(holidayData);
                        db.SaveChanges();
                        strResponse = "Holiday Successfully Created";
                    }
                }
                catch (Exception ex)
                {
                    strResponse = ex.Message.ToString();
                }
            }
            return(strResponse);
        }