FullCalendar3.8事件新增

Event_add.ashx

内容

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq;
using System.Data.Entity;
using FineUI;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.IO;
using System.Text;
namespace AppTask
{
    /// 
    /// taskadd 的摘要说明
    /// 
    public class task_add : IHttpHandler
    {
        string _strStart, _strEnd,attypename,atuser, attitle, atcontent, atsdate,atcolor, atedate,atbgcolor, atbdcolor, attextcolor, atguid, CreateUser,remark;
        DateTime CreateTime;
        public static SqlConnection AppConn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Default"].ToString());
        public void ProcessRequest(HttpContext context)
        {
            

             attypename = System.Web.HttpUtility.UrlDecode(context.Request["attype"], Encoding.UTF8);//事件类别
             attitle = System.Web.HttpUtility.UrlDecode(context.Request["title"], Encoding.UTF8);//标题
             atcontent = System.Web.HttpUtility.UrlDecode(context.Request["description"], Encoding.UTF8);//内容

             atsdate = System.Web.HttpUtility.UrlDecode(context.Request["start"], Encoding.UTF8);//开始时间
             atedate = System.Web.HttpUtility.UrlDecode(context.Request["end"], Encoding.UTF8);//结束时间
            if(attypename=="1")
            {
                 atuser= Common.LoginUser;
                 atcolor = "#0066CC";
                 atbgcolor = "#0066CC";
                 atbdcolor = "#FFFFFF";
                 attextcolor = "#FFFFE0";
                remark = "公开日程";
                 atguid = Guid.NewGuid().ToString();
                 CreateUser = Common.LoginUser;
                 CreateTime = DateTime.Now;
            }
            else
            {
                atuser = Common.LoginUser;
                atcolor = "#00A600";
                atbgcolor = "#00A600";
                atbdcolor = "#FFFFFF";
                attextcolor = "#F8F8FF";
                remark = "个人日程";
                atguid = Guid.NewGuid().ToString();
                CreateUser = Common.LoginUser;
                CreateTime = DateTime.Now;
            }
            //getTimeSpan(System.Web.HttpUtility.UrlDecode(context.Request["start"], Encoding.UTF8));
            if (attitle != "")
            {
                if(atcontent != "")
                {
                    if(atsdate != "")
                    {
                        if(atedate != "")
                        {
                            //SqlConnection con = new SqlConnection(@"Password=tac26901333;Persist Security Info=True;User ID=sa;Initial Catalog=DocumentManagement;Data Source=.");
                            string eventStr = "INSERT INTO  [AppCube].[dbo].[atTasks]"+
                                "(atuser,attypename,attitle,atcontent,atallday, atsdate, atedate, aturl, atclassname, ateditable,"+
                                "atsource, atcolor, atbgcolor, atbdcolor, attextcolor, Remark, atguid, CreateUser, CreateTime)"+
                                "VALUES('" + atuser + "','" + attypename + "','" + attitle + "','"+ atcontent + "',0,'" + atsdate + "',"+
                                "'" + atedate + "','','',0,'','" + atcolor + "','"+ atbgcolor + "','"+ atbdcolor + "','" + attextcolor + "','"+remark+"','"+ atguid + "','" + CreateUser + "','" + CreateTime + "');select SCOPE_IDENTITY() as id";
                            SqlDataAdapter eventDA = new SqlDataAdapter(eventStr, AppConn);
                            DataSet eventDS = new DataSet();
                            eventDA.Fill(eventDS);
                            AppConn.Close();

                            string id = eventDS.Tables[0].Rows[0]["id"].ToString();
                            context.Response.Write(id);
                        }
                    }
                }

            }
        }
        protected bool getTimeSpan(string timeStr)
        {
            string eventStr = "SELECT * FROM [AppCube].[dbo].[atTasks] WHERE atuser='" + Common.LoginUser + "' AND datediff(day,atsdate,'"+ atsdate.Substring(0,10) + "')=0 ";

            SqlDataAdapter eventDA = new SqlDataAdapter(eventStr, AppConn);
            DataSet eventDS = new DataSet();
            eventDA.Fill(eventDS);
             
            if (eventDS.Tables[0].Rows[0][1].ToString().Length != 0)
            {
                 _strStart = eventDS.Tables[0].Rows[0][2].ToString();//订单数量
                 _strEnd = eventDS.Tables[0].Rows[0][4].ToString();//物料

            }
            //判断当前时间是否在工作时间段内
             //_strStart = atsdate;//工作时间上午08:30
             //_strEnd = atedate;
            TimeSpan dspWorkingDayAM = DateTime.Parse(_strStart).TimeOfDay;
            TimeSpan dspWorkingDayPM = DateTime.Parse(_strEnd).TimeOfDay;

            //string time1 = "2017-2-17 8:10:00";
            DateTime t1 = Convert.ToDateTime(timeStr);

            TimeSpan dspNow = t1.TimeOfDay;
            if (dspNow > dspWorkingDayAM && dspNow < dspWorkingDayPM)
            {
                return true;
            }
            return false;
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}


你可能感兴趣的:(FineUI开发实践)