Exemple #1
0
        public string GetHistoryByPostID(int PostID)
        {
            string temp = string.Empty;
            try
            {
                Coe25DBDataContext db = new Coe25DBDataContext();
                List<tbl_History> history = (from m in db.tbl_Histories
                                             where m.PostID == PostID &&
                                                   m.IsFixed == false
                                             select m).ToList();
                db.Dispose();
                history.ForEach(delegate(tbl_History indexHistory)
                {
                    temp += "Post Id: " + indexHistory.PostID.ToString() + Environment.NewLine;
                    temp += "Date of triggered event: " + indexHistory.CreateDate + Environment.NewLine + Environment.NewLine;

                });

            }
            catch (Exception ex)
            {
                throw ex;
            }
            return temp;
        }
Exemple #2
0
 public List<string> getAllPostInHistory()
 {
     Coe25DBDataContext db = new Coe25DBDataContext();
     List<string> posts = null;
     List<int> postId = new List<int>();
     try
     {
         postId = (from m in db.tbl_Histories
                   where m.IsFixed == false
                   select (int)m.PostID).ToList();
         if (postId.Count > 0)
         {
             this.button1.Enabled = true;
             posts = new List<string>();
             string temp = string.Empty;
             postId.ForEach(delegate(int index)
             {
                 temp = "Post Id: " + index.ToString();
                 if (!IsHistoryIDinList(temp, posts))
                     posts.Add(temp);
             });
         }
         else
         {
             this.button1.Enabled = false;
             MessageBox.Show("All Post is Fixed.");
             this.Close();
         }
     }
     catch (Exception)
     {
         throw;
     }
     return posts;
 }
 public List<string> getAllCluster()
 {
     Coe25DBDataContext db = new Coe25DBDataContext();
     List<string> clusters = new List<string>();
     try
     {
         clusters = (from m in db.tbl_Clusters
                     select m.UniqueCode).ToList();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return clusters;
 }
 public string getUniqueID()
 {
     Random rand = new Random();
     string temp = string.Empty;
     string UniqueID = string.Empty;
     bool running = true;
     try
     {
         Coe25DBDataContext db = new Coe25DBDataContext();
         while (running)
         {
             temp = rand.Next(0, 9).ToString();
             if (!string.IsNullOrEmpty(temp))
             {
                 UniqueID = UniqueID + temp;
             }
             if (UniqueID.Length == 5)
             {
                 var dbChecker = (from m in db.tbl_Clusters
                                  where m.UniqueCode == UniqueID
                                  select m).FirstOrDefault();
                 if (dbChecker != null)
                 {
                     UniqueID = string.Empty;
                 }
                 else
                 {
                     running = false;
                     break;
                 }
             }
         }
         db.Dispose();
     }
     catch (Exception)
     {
         throw;
     }
     return UniqueID;
 }
Exemple #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     //Fix Button
     if (PostIdentity != 0)
     {
         Coe25DBDataContext db = new Coe25DBDataContext();
         List<tbl_History> history = (from m in db.tbl_Histories
                                      where m.PostID == PostIdentity &&
                                            m.IsFixed == false
                                      select m).ToList();
         if (history.Count > 0)
         {
             history.ForEach(delegate(tbl_History hist)
             {
                 hist.IsFixed = true;
             });
             db.SubmitChanges();
             MessageBox.Show("POST is Fix.");
             SetListBox();
         }
     }
 }
Exemple #6
0
 public void ShowMapByPost()
 {
     if (PostIdentity > 0)
     {
         Coe25DBDataContext db = new Coe25DBDataContext();
         tbl_Map map = (from m in db.tbl_Maps
                        where m.PostID == PostIdentity
                        select m).FirstOrDefault();
         if (map != null)
         {
             string Url = string.Format("http://localhost:3270/?lat={0}&long={1}&PostDetail={2}",map.Latitude, map.Longitude, PostIdentity);
             this.webBrowser1.Navigate(Url);
         }
     }
 }
 public tbl_Cluster getClusterByText(string Value)
 {
     Coe25DBDataContext db = new Coe25DBDataContext();
     return db.tbl_Clusters.FirstOrDefault(c => c.UniqueCode == Value);
 }
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         tbl_Cluster cluster = new tbl_Cluster();
         cluster.UniqueCode = this.textBox2.Text;
         cluster.ClusterPhoneNumber = this.textBox1.Text;
         cluster.CreateDate = DateTime.UtcNow;
         Coe25DBDataContext db = new Coe25DBDataContext();
         db.tbl_Clusters.InsertOnSubmit(cluster);
         db.SubmitChanges();
         db.Dispose();
         CreateNewCluster = cluster.UniqueCode;
         this.Close();
     }
     catch { }
 }