예제 #1
0
        public bool SaveWeeklyNote(WeeklyNotes weeklynote)
        {
            string        Id     = string.Empty;
            StringBuilder select = new StringBuilder();

            select.AppendFormat("select * from weeklynotes where name = '{0}' and notedate = '{1}'", weeklynote.Name, weeklynote.NoteDate);
            DataTable dt = MySqlHelper.mySqlExecuteQuery(select.ToString(), null, false);

            if (dt.Rows.Count > 0)
            {
                Id = dt.Rows[0]["ID"].ToString();
            }
            if (Id.Length > 0)
            {
                StringBuilder delete = new StringBuilder();
                delete.AppendFormat("delete from weeklynotes where Id = '{0}'", Id);
                int j = MySqlHelper.mySqlExecuteNonQuery(delete.ToString(), null, false);
            }
            StringBuilder insert = new StringBuilder();

            insert.Append("insert into weeklynotes (Name,Note,NoteDate,Remarks,location)");
            insert.AppendFormat(" values ('{0}','{1}','{2}','{3}','{4}')", weeklynote.Name, weeklynote.Note, weeklynote.NoteDate, weeklynote.Remarks, weeklynote.location);
            int i = MySqlHelper.mySqlExecuteNonQuery(insert.ToString(), null, false);

            return(i > 0);
        }
예제 #2
0
        public bool ModifyLocation(WeeklyNotes weeklynote)
        {
            string    c      = "";
            string    select = string.Format("select count(*) as count from weeklynotes where NoteDate = '{0}' and Name = '{1}' ", weeklynote.NoteDate, weeklynote.Name);
            DataTable dt     = MySqlHelper.mySqlExecuteQuery(select.ToString(), null, false);

            if (dt.Rows.Count > 0)
            {
                c = dt.Rows[0]["count"].ToString();
            }
            if (int.Parse(c) > 0)
            {
                StringBuilder update = new StringBuilder();
                update.AppendFormat("update weeklynotes set Location = '{0}' where NoteDate = '{1}' and Name = '{2}'", weeklynote.location, weeklynote.NoteDate, weeklynote.Name);
                int i = MySqlHelper.mySqlExecuteNonQuery(update.ToString(), null, false);
                return(i > 0);
            }
            else
            {
                StringBuilder insert = new StringBuilder();
                insert.AppendFormat("insert into weeklynotes (Location,NoteDate,Name) values ('{0}','{1}','{2}')", weeklynote.location, weeklynote.NoteDate, weeklynote.Name);
                int i = MySqlHelper.mySqlExecuteNonQuery(insert.ToString(), null, false);
                return(i > 0);
            }
        }
예제 #3
0
        public WeeklyNotes getWeeklyNoteInfo(NameValueCollection paras)
        {
            WeeklyNotes wn = new WeeklyNotes();

            wn.Note     = paras["note"].Trim();
            wn.Remarks  = paras["remark"].Trim();
            wn.NoteDate = paras["date"].Trim();
            wn.Name     = paras["name"].Trim();
            wn.location = paras["location"].Trim();
            return(wn);
        }
예제 #4
0
        public WeeklyNotes SaveNote([FromBody] WeeklyNotes value)
        {
            SaveEntity se = new SaveEntity();

            if (se.SaveWeeklyNote(value))
            {
                return(value);
            }
            else
            {
                return(null);
            }
        }
예제 #5
0
        public bool CheckWeeklyNote(WeeklyNotes weeklynote)
        {
            string    c      = "";
            string    select = string.Format("select count(*) as count from weeklynotes where NoteDate = '{0}' and Name = '{1}' ", weeklynote.NoteDate, weeklynote.Name);
            DataTable dt     = MySqlHelper.mySqlExecuteQuery(select.ToString(), null, false);

            if (dt.Rows.Count > 0)
            {
                c = dt.Rows[0]["count"].ToString();
            }
            if (int.Parse(c) > 0)
            {
                StringBuilder update = new StringBuilder();
                update.AppendFormat("update weeklynotes set CheckFlag = '{0}', workingload = '{1}', attendance = '{2}', Remarks = '{3}',Checker = '{4}' ", weeklynote.CheckFlag, weeklynote.workingload, weeklynote.attendance, weeklynote.Remarks, weeklynote.Checker);
                if (weeklynote.Checker == score1)
                {
                    update.AppendFormat(", score1 = '{0}' ", weeklynote.score1);
                }
                if (weeklynote.Checker == score2)
                {
                    update.AppendFormat(", score2 = '{0}' ", weeklynote.score1);
                }
                if (weeklynote.Checker == score3)
                {
                    update.AppendFormat(", score3 = '{0}' ", weeklynote.score1);
                }
                update.AppendFormat(" where NoteDate = '{0}' and Name = '{1}' ", weeklynote.NoteDate, weeklynote.Name);
                int i = MySqlHelper.mySqlExecuteNonQuery(update.ToString(), null, false);
                return(i > 0);
            }
            else
            {
                StringBuilder insert = new StringBuilder();
                insert.AppendFormat("insert into weeklynotes (CheckFlag,workingload,attendance,Remarks,Checker,NoteDate,Name) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", weeklynote.CheckFlag, weeklynote.workingload, weeklynote.attendance, weeklynote.Remarks, weeklynote.Checker, weeklynote.NoteDate, weeklynote.Name);
                //insert.AppendFormat(" where NoteDate = '{0}' and Name = '{1}' ", weeklynote.NoteDate, weeklynote.Name);
                int i = MySqlHelper.mySqlExecuteNonQuery(insert.ToString(), null, false);
                return(i > 0);
            }
        }
예제 #6
0
        public List <WeeklyNotes> GetWeeklyNotes(string UserName, string DateSelect = "")
        {
            DateTime Day;

            if (string.IsNullOrEmpty(DateSelect))
            {
                Day = DateTime.Today;
            }
            else
            {
                Day = DateTime.Parse(DateSelect);
            }
            if (!string.IsNullOrEmpty(userName))
            {
                UserName = userName;
            }
            //获取本周第一天
            int Weeknow = Convert.ToInt32(Day.DayOfWeek);

            //因为是以星期一为第一天,所以要判断weeknow等于0时,要向前推6天。
            Weeknow = (Weeknow == 0 ? (7 - 1) : (Weeknow - 1));
            int Daydiff = (-1) * Weeknow;
            //本周第一天
            string FirstDay = Day.AddDays(Daydiff).ToString("yyyy-MM-dd");

            FD = FirstDay;
            //获取本周最后一天
            int Weeknow1 = Convert.ToInt32(Day.DayOfWeek);

            Weeknow1 = (Weeknow1 == 0 ? 7 : Weeknow1);
            Daydiff  = (7 - Weeknow1);
            //本周最后一天
            string LastDay = Day.AddDays(Daydiff).ToString("yyyy-MM-dd");

            List <WeeklyNotes> weeklynotes2 = new List <WeeklyNotes>();
            DataTable          dt           = new DataTable();
            StringBuilder      select       = new StringBuilder();

            select.AppendFormat("select * from weeklynotes where notedate >='{0}' and notedate <='{1}' and Name = '{2}'", FirstDay, LastDay, UserName);
            dt           = MySqlHelper.mySqlExecuteQuery(select.ToString(), null, false);
            weeklynotes2 = (from x in dt.AsEnumerable()
                            orderby x.Field <string>("NoteDate")
                            select new WeeklyNotes
            {
                Name = x.Field <string>("Name"),
                Note = x.Field <string>("Note"),
                NoteDate = x.Field <string>("NoteDate"),
                CheckOpinion = x.Field <string>("CheckOpinion"),
                CheckFlag = x.Field <string>("CheckFlag"),
                Remarks = x.Field <string>("Remarks"),
                attendance = x.Field <string>("attendance"),
                location = x.Field <string>("location"),
            }).ToList <WeeklyNotes>();
            List <WeeklyNotes> weeklynotes3 = new List <WeeklyNotes>();
            DateTime           day          = DateTime.Parse(FirstDay);

            string[] WeekDays = new string[7];
            for (int I = 0; I < 7; I++)//7行
            {
                WeeklyNotes weeklyItem = new WeeklyNotes();
                string      day1       = day.AddDays(I - 0).ToString("yyyy-MM-dd");
                WeekDays[I] = day1;
                var Flag = true;
                foreach (var Item in weeklynotes2)
                {
                    if (Item.NoteDate == WeekDays[I])
                    {
                        weeklynotes3.Add(Item);
                        Flag = false;
                        break;
                    }
                }
                if (Flag)
                {
                    weeklyItem.NoteDate = day1;
                    weeklyItem.Name     = UserName;
                    weeklynotes3.Add(weeklyItem);
                }
            }
            return(weeklynotes3);
        }