Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(LearnSite.Model.Signin model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Signin(");
            strSql.Append("Qnum,Qattitude,Qdate,Qyear,Qmonth,Qday,Qweek,Qip,Qmachine,Qnote,Qwork,Qgrade,Qterm,Qsid,Qname,Qclass,Qsyear)");
            strSql.Append(" values (");
            strSql.Append("@Qnum,@Qattitude,@Qdate,@Qyear,@Qmonth,@Qday,@Qweek,@Qip,@Qmachine,@Qnote,@Qwork,@Qgrade,@Qterm,@Qsid,@Qname,@Qclass,@Qsyear)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Qnum",      SqlDbType.NVarChar,  50),
                new SqlParameter("@Qattitude", SqlDbType.Int,        4),
                new SqlParameter("@Qdate",     SqlDbType.DateTime),
                new SqlParameter("@Qyear",     SqlDbType.Int,        4),
                new SqlParameter("@Qmonth",    SqlDbType.Int,        4),
                new SqlParameter("@Qday",      SqlDbType.Int,        4),
                new SqlParameter("@Qweek",     SqlDbType.NVarChar,  50),
                new SqlParameter("@Qip",       SqlDbType.NVarChar,  50),
                new SqlParameter("@Qmachine",  SqlDbType.NVarChar,  50),
                new SqlParameter("@Qnote",     SqlDbType.NVarChar,  50),
                new SqlParameter("@Qwork",     SqlDbType.Int,        4),
                new SqlParameter("@Qgrade",    SqlDbType.Int,        4),
                new SqlParameter("@Qterm",     SqlDbType.Int,        4),
                new SqlParameter("@Qsid",      SqlDbType.Int,        4),
                new SqlParameter("@Qname",     SqlDbType.NVarChar,  50),
                new SqlParameter("@Qclass",    SqlDbType.Int,        4),
                new SqlParameter("@Qsyear",    SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.Qnum;
            parameters[1].Value  = model.Qattitude;
            parameters[2].Value  = model.Qdate;
            parameters[3].Value  = model.Qyear;
            parameters[4].Value  = model.Qmonth;
            parameters[5].Value  = model.Qday;
            parameters[6].Value  = model.Qweek;
            parameters[7].Value  = model.Qip;
            parameters[8].Value  = model.Qmachine;
            parameters[9].Value  = model.Qnote;
            parameters[10].Value = model.Qwork;
            parameters[11].Value = model.Qgrade;
            parameters[12].Value = model.Qterm;
            parameters[13].Value = model.Qsid;
            parameters[14].Value = model.Qname;
            parameters[15].Value = model.Qclass;
            parameters[16].Value = model.Qsyear;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #2
0
        /// <summary>
        ///签到,如果今天的签到记录不存在则增加一条
        ///签到参数:学号、日期、IP
        /// Qnum,Qattitude,Qdate,Qyear,Qmonth,Qday,Qweek,Qip,Qnote,Qwork
        /// </summary>
        /// <param name="smodel"></param>
        public int SigninToday(string Qnum, DateTime Qdate, string Qip, int Qgrade, int Qterm, int Qsid, string Qname, int Qclass, int Qsyear)
        {
            int sg     = 0;
            int Qyear  = Qdate.Year;
            int Qmonth = Qdate.Month;
            int Qday   = Qdate.Day;

            BLL.Computers cbll     = new BLL.Computers();
            string        Qmachine = cbll.GetmachineByIp(Qip);
            string        Qweek    = Qdate.DayOfWeek.ToString();

            Model.Signin qmodel = new LearnSite.Model.Signin();
            qmodel.Qnum      = Qnum;
            qmodel.Qattitude = 0;
            qmodel.Qdate     = Qdate;
            qmodel.Qyear     = Qyear;
            qmodel.Qmonth    = Qmonth;
            qmodel.Qday      = Qday;
            qmodel.Qweek     = Qweek;
            qmodel.Qip       = Qip;
            qmodel.Qnote     = "";
            qmodel.Qwork     = 0;
            qmodel.Qgrade    = Qgrade;
            qmodel.Qterm     = Qterm;
            qmodel.Qmachine  = Qmachine;
            qmodel.Qsid      = Qsid;
            qmodel.Qname     = Qname;
            qmodel.Qclass    = Qclass;
            qmodel.Qsyear    = Qsyear;

            string mysql = "select count(1) from Signin where Qsid=" + Qsid + " and Qday=" + Qday + " and Qmonth=" + Qmonth + " and Qyear=" + Qyear;

            if (!DbHelperSQL.Exists(mysql))
            {
                Add(qmodel);
                sg = 2;
            }
            else
            {
                string sqlstr = "update Signin set Qip='" + Qip + "',Qmachine='" + Qmachine + "' where Qsid=" + Qsid + " and Qyear=" + Qyear + " and Qmonth=" + Qmonth + " and Qday=" + Qday;
                DbHelperSQL.ExecuteSql(sqlstr);
                sg = 3;
            }
            return(sg);
        }
Пример #3
0
        /// <summary>
        /// 根据学号得到一个对象实体,最近的签到记录
        /// </summary>
        public LearnSite.Model.Signin GetModelm(string Qnum)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Qid,Qnum,Qattitude,Qdate,Qyear,Qmonth,Qday,Qweek,Qip,Qmachine,Qnote,Qwork,Qgrade,Qterm,Qgroup,Qgscore,Qsid,Qname,Qclass,Qsyear from Signin ");
            strSql.Append(" where Qnum=@Qnum order by Qdate desc");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Qnum", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = Qnum;

            LearnSite.Model.Signin model = new LearnSite.Model.Signin();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Qid"].ToString() != "")
                {
                    model.Qid = int.Parse(ds.Tables[0].Rows[0]["Qid"].ToString());
                }
                model.Qnum = ds.Tables[0].Rows[0]["Qnum"].ToString();
                if (ds.Tables[0].Rows[0]["Qattitude"].ToString() != "")
                {
                    model.Qattitude = int.Parse(ds.Tables[0].Rows[0]["Qattitude"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Qdate"].ToString() != "")
                {
                    model.Qdate = DateTime.Parse(ds.Tables[0].Rows[0]["Qdate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Qyear"].ToString() != "")
                {
                    model.Qyear = int.Parse(ds.Tables[0].Rows[0]["Qyear"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Qmonth"].ToString() != "")
                {
                    model.Qmonth = int.Parse(ds.Tables[0].Rows[0]["Qmonth"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Qday"].ToString() != "")
                {
                    model.Qday = int.Parse(ds.Tables[0].Rows[0]["Qday"].ToString());
                }
                model.Qweek    = ds.Tables[0].Rows[0]["Qweek"].ToString();
                model.Qip      = ds.Tables[0].Rows[0]["Qip"].ToString();
                model.Qmachine = ds.Tables[0].Rows[0]["Qmachine"].ToString();
                model.Qnote    = ds.Tables[0].Rows[0]["Qnote"].ToString();
                if (ds.Tables[0].Rows[0]["Qwork"].ToString() != "")
                {
                    model.Qwork = int.Parse(ds.Tables[0].Rows[0]["Qwork"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Qgrade"].ToString() != "")
                {
                    model.Qgrade = int.Parse(ds.Tables[0].Rows[0]["Qgrade"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Qterm"].ToString() != "")
                {
                    model.Qterm = int.Parse(ds.Tables[0].Rows[0]["Qterm"].ToString());
                }
                model.Qgroup = ds.Tables[0].Rows[0]["Qgroup"].ToString();
                if (ds.Tables[0].Rows[0]["Qgscore"].ToString() != "")
                {
                    model.Qgscore = int.Parse(ds.Tables[0].Rows[0]["Qgscore"].ToString());
                }
                //,Qsid,Qname,Qclass,Qsyear
                if (ds.Tables[0].Rows[0]["Qsid"].ToString() != "")
                {
                    model.Qsid = int.Parse(ds.Tables[0].Rows[0]["Qsid"].ToString());
                }
                model.Qname = ds.Tables[0].Rows[0]["Qname"].ToString();
                if (ds.Tables[0].Rows[0]["Qclass"].ToString() != "")
                {
                    model.Qclass = int.Parse(ds.Tables[0].Rows[0]["Qclass"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Qsyear"].ToString() != "")
                {
                    model.Qsyear = int.Parse(ds.Tables[0].Rows[0]["Qsyear"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(LearnSite.Model.Signin model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Signin set ");
            strSql.Append("Qnum=@Qnum,");
            strSql.Append("Qattitude=@Qattitude,");
            strSql.Append("Qdate=@Qdate,");
            strSql.Append("Qyear=@Qyear,");
            strSql.Append("Qmonth=@Qmonth,");
            strSql.Append("Qday=@Qday,");
            strSql.Append("Qweek=@Qweek,");
            strSql.Append("Qip=@Qip,");
            strSql.Append("Qmachine=@Qmachine,");
            strSql.Append("Qnote=@Qnote,");
            strSql.Append("Qwork=@Qwork,");
            strSql.Append("Qgrade=@Qgrade,");
            strSql.Append("Qterm=@Qterm");
            strSql.Append(" where Qid=@Qid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Qnum",      SqlDbType.NVarChar,  50),
                new SqlParameter("@Qattitude", SqlDbType.Int,        4),
                new SqlParameter("@Qdate",     SqlDbType.DateTime),
                new SqlParameter("@Qyear",     SqlDbType.Int,        4),
                new SqlParameter("@Qmonth",    SqlDbType.Int,        4),
                new SqlParameter("@Qday",      SqlDbType.Int,        4),
                new SqlParameter("@Qweek",     SqlDbType.NVarChar,  50),
                new SqlParameter("@Qip",       SqlDbType.NVarChar,  50),
                new SqlParameter("@Qmachine",  SqlDbType.NVarChar,  50),
                new SqlParameter("@Qnote",     SqlDbType.NVarChar,  50),
                new SqlParameter("@Qwork",     SqlDbType.Int,        4),
                new SqlParameter("@Qgrade",    SqlDbType.Int,        4),
                new SqlParameter("@Qterm",     SqlDbType.Int,        4),
                new SqlParameter("@Qid",       SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.Qnum;
            parameters[1].Value  = model.Qattitude;
            parameters[2].Value  = model.Qdate;
            parameters[3].Value  = model.Qyear;
            parameters[4].Value  = model.Qmonth;
            parameters[5].Value  = model.Qday;
            parameters[6].Value  = model.Qweek;
            parameters[7].Value  = model.Qip;
            parameters[8].Value  = model.Qmachine;
            parameters[9].Value  = model.Qnote;
            parameters[10].Value = model.Qwork;
            parameters[11].Value = model.Qgrade;
            parameters[12].Value = model.Qterm;
            parameters[13].Value = model.Qid;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
        /// <summary>
        ///ǩ������������ǩ����¼������������һ��
        ///ǩ��������ѧ�š����ڡ�IP
        /// 
        ///ģ���ݲ���Qnum,Qdate,Qyear,Qmonth,Qday,Qweek,Qip
        /// </summary>
        /// <param name="smodel"></param>
        public void SigninToday(string Qnum,DateTime Qdate,string Qip)
        {
            int Qyear = Qdate.Year;
            int Qmonth = Qdate.Month;
            int Qday = Qdate.Day;
            string mysql = "select Qnum from Signin where Qnum='"+Qnum+"' and Qyear="+Qyear+" and Qmonth="+Qmonth+" and Qday="+Qday;
            if (!DbHelperSQL.ExecuteSqlExist(mysql))
            {
                string Qweek = Qdate.DayOfWeek.ToString();

                Model.Signin qmodel = new LearnSite.Model.Signin();
                qmodel.Qnum = Qnum;
                qmodel.Qdate = Qdate;
                qmodel.Qyear = Qyear;
                qmodel.Qmonth = Qmonth;
                qmodel.Qday = Qday;
                qmodel.Qweek = Qweek;
                qmodel.Qip = Qip;
                AddToday(qmodel);
            }
            else
            {
                string sqlstr = "update Signin set Qip='" + Qip + "' where Qnum='" + Qnum + "' and Qyear=" + Qyear + " and Qmonth=" + Qmonth + " and Qday=" + Qday;
                DbHelperSQL.ExecuteSql(sqlstr);
            }
        }
Пример #6
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public LearnSite.Model.Signin GetModel(int Qid)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 Qid,Qnum,Qattitude,Qdate,Qyear,Qmonth,Qday,Qweek,Qip,Qnote,Qwork from Signin ");
            strSql.Append(" where Qid=@Qid ");
            SqlParameter[] parameters = {
                    new SqlParameter("@Qid", SqlDbType.Int,4)};
            parameters[0].Value = Qid;

            LearnSite.Model.Signin model=new LearnSite.Model.Signin();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Qid"].ToString() != "")
                {
                    model.Qid = int.Parse(ds.Tables[0].Rows[0]["Qid"].ToString());
                }
                model.Qnum = ds.Tables[0].Rows[0]["Qnum"].ToString();
                if (ds.Tables[0].Rows[0]["Qattitude"].ToString() != "")
                {
                    model.Qattitude = int.Parse(ds.Tables[0].Rows[0]["Qattitude"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Qdate"].ToString() != "")
                {
                    model.Qdate = DateTime.Parse(ds.Tables[0].Rows[0]["Qdate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Qyear"].ToString() != "")
                {
                    model.Qyear = int.Parse(ds.Tables[0].Rows[0]["Qyear"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Qmonth"].ToString() != "")
                {
                    model.Qmonth = int.Parse(ds.Tables[0].Rows[0]["Qmonth"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Qday"].ToString() != "")
                {
                    model.Qday = int.Parse(ds.Tables[0].Rows[0]["Qday"].ToString());
                }
                model.Qweek = ds.Tables[0].Rows[0]["Qweek"].ToString();
                model.Qip = ds.Tables[0].Rows[0]["Qip"].ToString();
                model.Qnote = ds.Tables[0].Rows[0]["Qnote"].ToString();
                if (ds.Tables[0].Rows[0]["Qwork"].ToString() != "")
                {
                    model.Qwork = int.Parse(ds.Tables[0].Rows[0]["Qwork"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }