public static string changeStatus(string companyid, string nid, string action, string empid, string projectid, string groupid, string newdate, string status, string remark, string createdby)
        {
            ClsTimeSheet   objts  = new ClsTimeSheet();
            DataSet        ds     = new DataSet();
            GeneralMethod  objgen = new GeneralMethod();
            ClsScheduleBAL objSch = new ClsScheduleBAL();

            objts.projectid = projectid;
            objts.groupid   = groupid;
            objts.empid     = empid;
            objts.date      = newdate;
            objts.remark    = remark;
            objts.Status    = status;
            objts.companyId = companyid;
            objts.nid       = nid;
            if (action == "one")
            {
                objts.action = "setstatus";
            }
            else
            {
                objts.action = "setgroupstatus";
            }

            ds = objts.schedule();
            string result = "";

            result = objgen.serilizeinJson(ds.Tables[0]);
            return(result);
        }
        public static string generateemail(string companyid, string nid)
        {
            string         result = "";
            ClsTimeSheet   objts  = new ClsTimeSheet();
            DataSet        ds     = new DataSet();
            GeneralMethod  objgen = new GeneralMethod();
            ClsScheduleBAL objSch = new ClsScheduleBAL();

            objts.action    = "getDetailByGroup";
            objts.companyId = companyid;
            objts.nid       = nid;

            ds = objts.schedule();

            try
            {
                //Read File Data
                string HTMLBODY = File.Exists(HttpContext.Current.Server.MapPath("EmailTemplates/clientschedule.htm")) ? File.ReadAllText(HttpContext.Current.Server.MapPath("EmailTemplates/clientschedule.htm")) : "";

                HTMLBODY = HTMLBODY.Replace("#URL#", ds.Tables[1].Rows[0]["schedulerURL"].ToString());
                HTMLBODY = HTMLBODY.Replace("##Date##", ds.Tables[0].Rows[0]["date"].ToString() + " " + ds.Tables[0].Rows[0]["time"].ToString());
                HTMLBODY = HTMLBODY.Replace("##ClientName##", ds.Tables[0].Rows[0]["clientname"].ToString());
                HTMLBODY = HTMLBODY.Replace("##ProjectName##", ds.Tables[0].Rows[0]["projectname"].ToString());
                HTMLBODY = HTMLBODY.Replace("##ClientAddress##", ds.Tables[0].Rows[0]["clientaddress"].ToString());
                HTMLBODY = HTMLBODY.Replace("##Status##", ds.Tables[0].Rows[0]["status"].ToString());
                HTMLBODY = HTMLBODY.Replace("##CompanyContact##", ds.Tables[1].Rows[0]["phone"].ToString());
                HTMLBODY = HTMLBODY.Replace("##CompanyName##", ds.Tables[1].Rows[0]["companyname"].ToString());
                string strreceiver = "", strrecName = "";
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (ds.Tables[0].Rows[i]["emailid"].ToString() != "")
                    {
                        strreceiver += ds.Tables[0].Rows[i]["emailid"].ToString() + ",";
                    }
                    if ((i - 1) != ds.Tables[0].Rows.Count)
                    {
                        strrecName += ds.Tables[0].Rows[i]["fname"].ToString() + ", ";
                    }
                    else
                    {
                        strrecName += ds.Tables[0].Rows[i]["fname"].ToString();
                    }
                }
                HTMLBODY = HTMLBODY.Replace("[FirstName]", strrecName);
                result   = "1####" + strrecName + "####" + strreceiver + "####" + "Re: Schedule with - " + ds.Tables[0].Rows[0]["clientname"].ToString() + "####" + HTMLBODY;
            }
            catch (Exception ex)
            {
                result = @"0####" + ex.ToString();
            }

            return(result);
        }
        public static string getdata(string companyid, string fromdate, string todate, string status, string schtype, string client, string project)
        {
            ClsTimeSheet   objts  = new ClsTimeSheet();
            DataSet        ds     = new DataSet();
            GeneralMethod  objgen = new GeneralMethod();
            ClsScheduleBAL objSch = new ClsScheduleBAL();

            objts.nid       = "";
            objts.action    = "selectgroup";
            objts.companyId = companyid;
            objts.from      = fromdate;
            objts.to        = todate;
            objts.clientid  = client;
            objts.projectid = project;
            objts.empid     = "";
            objts.Status    = status;
            objts.remark    = schtype;
            ds = objts.schedule();

            string result = "";

            DataTable dtbyItem = new DataTable();
            var       cWeek    = DateRange.getLastDates("Current Week");
            var       NWeek    = DateRange.getLastDates("Next Week");


            dtbyItem = objgen.filterTable("date>=#01/01/" + (DateTime.Now.Year - 1).ToString() + "# and date<=#12/31/" + (DateTime.Now.Year - 1).ToString() + "#", ds.Tables[0]);
            result   = objSch.scheduleHTML(dtbyItem, "Previous Year Schedules", "pys");

            dtbyItem = objgen.filterTable("date>=#01/01/" + DateTime.Now.Year.ToString() + "# and date<#" + cWeek.fromdate + "#", ds.Tables[0]);
            result   = result + objSch.scheduleHTML(dtbyItem, "Older Schedules", "os");


            dtbyItem = objgen.filterTable("date>=#" + cWeek.fromdate + "# and date<=#" + cWeek.todate + "#", ds.Tables[0]);
            result   = result + objSch.scheduleHTML(dtbyItem, "Current Week Schedules", "cv");

            dtbyItem = objgen.filterTable("date>=#" + NWeek.fromdate + "# and date<=#" + NWeek.todate + "#", ds.Tables[0]);
            result   = result + objSch.scheduleHTML(dtbyItem, "Next Week Schedules", "nv");

            dtbyItem = objgen.filterTable("date>#" + NWeek.todate + "#", ds.Tables[0]);
            result   = result + objSch.scheduleHTML(dtbyItem, "Upcoming Schedules", "uc");



            return(result);
        }
        public static string getSchDetailData(string companyid, string nid)
        {
            ClsTimeSheet   objts  = new ClsTimeSheet();
            DataSet        ds     = new DataSet();
            GeneralMethod  objgen = new GeneralMethod();
            ClsScheduleBAL objSch = new ClsScheduleBAL();

            objts.action    = "getDetailByGroup";
            objts.companyId = companyid;
            objts.nid       = nid;

            ds = objts.schedule();

            string result = "";

            result = objgen.serilizeinJson(ds.Tables[0]);
            return(result);
        }
        public static string UpdateTime(string schduleId, string startDate, string endDate)
        {
            ClsTimeSheet   objts  = new ClsTimeSheet();
            DataSet        ds     = new DataSet();
            GeneralMethod  objgen = new GeneralMethod();
            ClsScheduleBAL objsch = new ClsScheduleBAL();
            string         result = "";

            objts.from = startDate;
            objts.to   = endDate;
            objts.nid  = schduleId;

            objts.CreatedBy = HttpContext.Current.Session["userid"].ToString().ToLower();
            objts.action    = "modifydate";

            ds     = objts.schedule();
            result = objgen.serilizeinJson(ds.Tables[0]);


            return(result);
        }
        public static string deleteGroupSchedule(string companyid, string nid, string action)
        {
            ClsTimeSheet   objts  = new ClsTimeSheet();
            DataSet        ds     = new DataSet();
            GeneralMethod  objgen = new GeneralMethod();
            ClsScheduleBAL objSch = new ClsScheduleBAL();

            objts.nid = nid;

            if (action == "one")
            {
                objts.action = "delete";
            }
            else
            {
                objts.action = "deleteGRpup";
            }
            objts.companyId = companyid;
            ds = objts.schedule();
            string result = "";

            result = objgen.serilizeinJson(ds.Tables[0]);
            return(result);
        }
        public static string saveSchedule(string action, string companyid, string nid, string empid, string clientid, string fromdate, string todate, string time, string status, string remark, string createdby, string groupid, string projectid, string scheduletype)
        {
            ClsTimeSheet   objts  = new ClsTimeSheet();
            DataSet        ds     = new DataSet();
            GeneralMethod  objgen = new GeneralMethod();
            ClsScheduleBAL objsch = new ClsScheduleBAL();
            string         result = "";

            objts.from     = fromdate;
            objts.to       = todate;
            objts.clientid = clientid;

            objts.date      = time;
            objts.hours     = time;
            objts.companyId = companyid;
            objts.CreatedBy = createdby;
            objts.empid     = empid;
            objts.projectid = projectid;
            objts.groupid   = groupid;
            objts.type      = scheduletype;
            objts.Status    = status;
            objts.remark    = remark;
            objts.nid       = nid;

            if (nid != "")
            {
                objts.action = "modify";
                objts.nid    = nid;
                ds           = objts.schedule();
                result       = objgen.serilizeinJson(ds.Tables[0]);
                try
                {
                    //   objsch.sendreschedulemail(ds.Tables[1], companyid);
                }
                catch { }
            }
            else
            {
                ds = objts.insertschedule();
                if (ds.Tables[0].Rows[0]["errormessage"].ToString() == "")
                {
                    if (ds.Tables.Count > 1)
                    {
                        if (ds.Tables[1].Rows.Count > 0)
                        {
                            if (objts.type.ToLower() != "office")
                            {
                                try
                                {
                                    //  objsch.sendreschedulemail(ds.Tables[1], companyid);
                                }
                                catch { }
                            }
                        }
                    }
                    result = @"[{""result"":""1"",""msg"":""""}]";
                }
                else
                {
                    result = @"[{""result"":""0"",""msg"":""" + ds.Tables[0].Rows[0]["errormessage"].ToString() + @"""}]";
                }
            }



            return(result);
        }