Exemplo n.º 1
0
        public static void AddRecord(DateTime _date, Guid _userId, int _siteId, int _chartId)
        {
            PCMSofCCDataContext db = new PCMSofCCDataContext();
            var newRecord = new Record
            {
                Date = _date.Date,
                UserId = _userId,
                SiteId = _siteId,
                ChartId = _chartId
            };
            db.Record.InsertOnSubmit(newRecord);

            var entries =
                from belong in db.EntryBelongToChart
                where belong.ChartId == _chartId
                select belong.ScoreEntry;
            foreach (var entry in entries)
            {
                var newRecordEntry = new RecordEntry
                {
                    Record = newRecord,
                    ScoreEntry = entry,
                };
                db.RecordEntry.InsertOnSubmit(newRecordEntry);
            }
            db.SubmitChanges();
        }
Exemplo n.º 2
0
 public static void UpdateSite(int _siteId, Func<Site, Site> predict)
 {
     PCMSofCCDataContext db = new PCMSofCCDataContext();
     Site site = db.Site.Single(x => x.Id == _siteId);
     site = predict(site);
     db.SubmitChanges();
 }
Exemplo n.º 3
0
 public static IQueryable<ScoreChart> GetCharts()
 {
     PCMSofCCDataContext db = new PCMSofCCDataContext();
     var q =
         from c in db.ScoreChart
         select c;
     return q;
 }
Exemplo n.º 4
0
 public static void UpdateTime(Guid _userId, WeekDay _flags, DateTime _date)
 {
     PCMSofCCDataContext db = new PCMSofCCDataContext();
     var t = db.AvailableDay.Single(x => x.UserId == _userId);
     t.SubmitDate = _date;
     t.AvailableDayFlag = (int)_flags;
     db.SubmitChanges();
 }
Exemplo n.º 5
0
 public static IQueryable<ScoreEntry> GetAllEntries()
 {
     PCMSofCCDataContext db = new PCMSofCCDataContext();
     var q =
         from entry in db.ScoreEntry
         select entry;
     return q;
 }
Exemplo n.º 6
0
 public static IQueryable<aspnet_Users> GetAllUsers()
 {
     PCMSofCCDataContext db=new PCMSofCCDataContext();
     var q =
         from u in db.aspnet_Users
         select u;
     return q;
 }
Exemplo n.º 7
0
 public static Record GetRecord(int _recordId)
 {
     PCMSofCCDataContext db = new PCMSofCCDataContext();
     var q =
         from r in db.Record
         where r.RecordId == _recordId
         select r;
     return q.Single();
 }
Exemplo n.º 8
0
 public static IQueryable<Site> GetUnassignedSitesOnSomeDay(DateTime _date)
 {
     PCMSofCCDataContext db = new PCMSofCCDataContext();
     var q =
         from s in db.Site
         where !s.Record.Any(r => r.Date == _date)
         select s;
     return q;
 }
Exemplo n.º 9
0
 public static IQueryable<Site> GetAssignedSites(DateTime _date)
 {
     PCMSofCCDataContext db = new PCMSofCCDataContext();
     var q =
         from s in db.Record
         where s.Date == _date
         select s.Site;
     return q;
 }
Exemplo n.º 10
0
 public static Site GetSite(int _siteId)
 {
     PCMSofCCDataContext db = new PCMSofCCDataContext();
     var query =
         from s in db.Site
         where s.Id == _siteId
         select s;
     return query.Single();
 }
Exemplo n.º 11
0
 public static IQueryable<Record> GetRecords(DateTime _date)
 {
     PCMSofCCDataContext db = new PCMSofCCDataContext();
     var q =
         from r in db.Record
         where r.Date == _date
         select r;
     return q;
 }
Exemplo n.º 12
0
 public static Record GetRecord(int _siteId, DateTime _date)
 {
     PCMSofCCDataContext db = new PCMSofCCDataContext();
     var q =
         from r in db.Record
         where r.SiteId == _siteId && r.Date == _date
         select r;
     return q.Single();
 }
Exemplo n.º 13
0
 public static void GetAvailableDayAndSubmitDate(Guid _userId, out int? flags, out DateTime? submitDate)
 {
     PCMSofCCDataContext db = new PCMSofCCDataContext();
     var q =
         from d in db.AvailableDay
         where d.UserId == _userId
         select d;
     flags = q.Single().AvailableDayFlag;
     submitDate = q.Single().SubmitDate;
 }
Exemplo n.º 14
0
 public static void DeleteEntries(int _chartId)
 {
     PCMSofCCDataContext db = new PCMSofCCDataContext();
     var q =
         from b in db.EntryBelongToChart
         where b.ChartId == _chartId
         select b;
     db.EntryBelongToChart.DeleteAllOnSubmit(q);
     db.SubmitChanges();
 }
Exemplo n.º 15
0
 public static IQueryable<ScoreEntry> GetChartEntries(int _chartId)
 {
     PCMSofCCDataContext db = new PCMSofCCDataContext();
     var q =
         from entry in db.ScoreEntry
         from es in entry.EntryBelongToChart
         where es.ChartId == _chartId
         select entry;
     return q;
 }
Exemplo n.º 16
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     PCMSofCCDataContext db = new PCMSofCCDataContext();
     foreach (GridViewRow row in gvCompleteRecord.Rows)
     {
         RecordEntry entry = db.RecordEntry.Single(x => x.Id == (int)gvCompleteRecord.DataKeys[row.RowIndex].Value);
         entry.Score = int.Parse(((TextBox)row.FindControl("tbxScore")).Text);
         entry.Problem = ((TextBox)row.FindControl("tbxProblem")).Text;
         entry.Solution = ((TextBox)row.FindControl("tbxSolution")).Text;
     }
     db.SubmitChanges();
 }
Exemplo n.º 17
0
 public static void AddScoreEntry(string _name, int _maxScore, string _criteria, string _remark)
 {
     PCMSofCCDataContext db = new PCMSofCCDataContext();
     var newScoreEntry = new ScoreEntry
     {
         Name = _name,
         Criteria = StringHelper.ReplaceNewLine(_criteria),
         MaxScore = _maxScore,
         Remark = StringHelper.ReplaceNewLine(_remark)
     };
     db.ScoreEntry.InsertOnSubmit(newScoreEntry);
     db.SubmitChanges();
 }
Exemplo n.º 18
0
 public static void AddEntries(int _chartId, List<int> _entries)
 {
     PCMSofCCDataContext db = new PCMSofCCDataContext();
     foreach (int id in _entries)
     {
         var newBelong = new EntryBelongToChart
         {
             ChartId = _chartId,
             EntryId = id
         };
         db.EntryBelongToChart.InsertOnSubmit(newBelong);
     }
     db.SubmitChanges();
 }
Exemplo n.º 19
0
 public static void AddSite(string _name, string _number, string _address, double _lon, double _lati, int _companyId)
 {
     PCMSofCCDataContext db = new PCMSofCCDataContext();
     var newSite = new Site
     {
         Name = _name,
         Number = _number,
         Address = _address,
         Longitude = _lon,
         Latitude = _lati,
         CompanyId = _companyId,
         IsUsed = 1
     };
     db.Site.InsertOnSubmit(newSite);
     db.SubmitChanges();
 }
Exemplo n.º 20
0
 public static void AddChart(string _chartName, List<int> _entries)
 {
     PCMSofCCDataContext db = new PCMSofCCDataContext();
     var newChart = new ScoreChart
     {
         Name = _chartName
     };
     db.ScoreChart.InsertOnSubmit(newChart);
     foreach (int id in _entries)
     {
         var newBelong = new EntryBelongToChart
         {
             ScoreChart = newChart,
             EntryId = id
         };
         db.EntryBelongToChart.InsertOnSubmit(newBelong);
     }
     db.SubmitChanges();
 }
Exemplo n.º 21
0
 public static System.Data.Linq.ISingleResult<GetCompleteRecordByChartId_个结果> GetCompleteRecord(int _chartId)
 {
     PCMSofCCDataContext db = new PCMSofCCDataContext();
     return db.GetCompleteRecordByChartId(_chartId);
 }