Exemplo n.º 1
0
        private void GetDetails()
        {
            string path = ReadText.ReadFilePath("datapath");
            // string filepath = path + "\\ClubInfo.txt";

            string birdDetailsPath = path + "\\PigeonDetails\\" + txtMemberID.Text + "\\" + txtrfid.Text + ".txt";

            if (EntryList != "" && EntryList.Contains(txtrfid.Text))
            {
                MessageBox.Show("Bird Already Entry.", "Information");
                this.txtrfid.Text = "";
            }
            else
            {
                if (File.Exists(birdDetailsPath))
                {
                    string[] pigeonDetailsCollection = ReadText.ReadTextFile(birdDetailsPath);
                    txtRingNumber.Text = pigeonDetailsCollection[0];
                    txtSex.Text        = pigeonDetailsCollection[3];
                    txtColor.Text      = pigeonDetailsCollection[4];
                    txtCategory.Text   = pigeonDetailsCollection[2];
                    LoadImage(txtrfid.Text, txtMemberID.Text);
                    Save();
                }
                else
                {
                    MessageBox.Show("Bird not found!", "Error");
                    this.txtrfid.Text = "";
                    this.txtrfid.Focus();
                }
            }
        }
Exemplo n.º 2
0
        private void SyncEntryInDatabase()
        {
            try
            {
                string path           = AppDomain.CurrentDomain.BaseDirectory + "SyncApplication";
                string filepath       = path + "\\resultinfo.txt";
                string Actionfilepath = path + "\\action.txt";


                string dateString = this.DateRelease.Year.ToString() + this.DateRelease.Month.ToString().PadLeft(2, '0') + this.DateRelease.Day.ToString().PadLeft(2, '0');

                string[] args       = { ClubName, dateString, ReadText.ReadFilePath("datapath"), this.DateRelease.ToShortDateString() };
                string[] actionargs = { "ENTRYDB" };

                System.IO.File.WriteAllLines(filepath, args);             //pigeondetails
                System.IO.File.WriteAllLines(Actionfilepath, actionargs); //pigeondetails

                var process = Process.Start(path + "\\SyncEclock.exe");
                process.WaitForExit();
                var exitCode = process.ExitCode;
                this.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                string memberID = this.txtMemberID.Text;
                string path     = ReadText.ReadFilePath("datapath");
                string filepath = path + "\\PigeonList\\" + memberID + ".txt";

                string[] pigeonlist = GetPigeonForEntry(filepath);
                string[] entryCol   = { };
                if (pigeonlist.Count() > 0)
                {
                    foreach (var item in pigeonlist)
                    {
                        string[] pigeonDetails = item.Split('|');
                        string[] entry         = { pigeonDetails[2] };

                        entryCol = entryCol.Concat(entry).Distinct().ToArray();
                    }

                    string dateString     = this.dateTimePicker1.Value.Year.ToString() + this.dateTimePicker1.Value.Month.ToString().PadLeft(2, '0') + this.dateTimePicker1.Value.Day.ToString().PadLeft(2, '0');
                    string entryDirectory = path + "\\entry\\" + dateString;
                    string entryfilepath  = entryDirectory + "\\" + memberID + ".txt";

                    System.IO.File.WriteAllLines(entryfilepath, entryCol); //entrylist
                    GetPigeonList(this.txtMemberID.Text);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }
Exemplo n.º 4
0
        public static void CreateStorageFolder()
        {
            try
            {
                string path   = ReadText.ReadFilePath("datapath");
                string images = path + @"\Images";
                if (!Directory.Exists(images))
                {
                    Directory.CreateDirectory(images);
                }

                string members = path + @"\Members";
                if (!Directory.Exists(members))
                {
                    Directory.CreateDirectory(members);
                }

                string pigeonDetails = path + @"\PigeonDetails";
                if (!Directory.Exists(pigeonDetails))
                {
                    Directory.CreateDirectory(pigeonDetails);
                }

                string pigeonList = path + @"\PigeonList";
                if (!Directory.Exists(pigeonList))
                {
                    Directory.CreateDirectory(pigeonList);
                }

                string pigeonMobileNumberList = path + @"\PigeonMobileList";
                if (!Directory.Exists(pigeonMobileNumberList))
                {
                    Directory.CreateDirectory(pigeonMobileNumberList);
                }

                string entryList = path + @"\Entry";
                if (!Directory.Exists(entryList))
                {
                    Directory.CreateDirectory(entryList);
                }

                string resultList = path + @"\Result";
                if (!Directory.Exists(resultList))
                {
                    Directory.CreateDirectory(resultList);
                }

                string pigeonLogs = path + @"\Logs";
                if (!Directory.Exists(pigeonLogs))
                {
                    Directory.CreateDirectory(pigeonLogs);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }
Exemplo n.º 5
0
        private Boolean SavetoFile(string MemberIDNo, string MemberName, Int64 PigeonID, string BandNumber, string Sex, string Color, PictureBox Photo1, PictureBox Photo2, string RFID, String category, string TestRing)
        {
            try
            {
                string path           = ReadText.ReadFilePath("datapath");
                string detailspath    = path + "\\pigeondetails\\" + MemberIDNo + "\\" + RFID + ".txt";
                string memberpath     = path + "\\members\\" + MemberIDNo + ".txt";
                string pigeonlistpath = path + "\\pigeonlist\\" + MemberIDNo + ".txt";

                if (ActionType != "EDIT" && File.Exists(detailspath))
                {
                    MessageBox.Show("Tag already assign to other bird.", "Error");
                    return(false);
                }


                string[] memberDetails = { MemberIDNo, MemberName, TestRing };
                string[] pigeonDetails = { BandNumber, RFID, category, Sex, Color };

                string[] pigeonList = SetPigeonList(ActionType, PigeonID.ToString(), BandNumber, Sex, Color, RFID, category).ToArray();

                System.IO.File.WriteAllLines(memberpath, memberDetails);  //memberdetails
                System.IO.File.WriteAllLines(pigeonlistpath, pigeonList); //memberpigeonlist

                string pigeondetailsDirectory = path + "\\pigeondetails\\" + MemberIDNo;
                if (!Directory.Exists(pigeondetailsDirectory))
                {
                    Directory.CreateDirectory(pigeondetailsDirectory);
                }
                System.IO.File.WriteAllLines(detailspath, pigeonDetails); //pigeondetails


                string pigeonimageDirectory = path + "\\images\\" + MemberIDNo;
                if (!Directory.Exists(pigeonimageDirectory))
                {
                    Directory.CreateDirectory(pigeonimageDirectory);
                }

                if (Photo1.Image != null)
                {
                    string filename = pigeonimageDirectory + "\\" + RFID + ".txt";
                    File.WriteAllBytes(filename, GetPhoto(imgCapture));
                }

                if (Photo2.Image != null)
                {
                    string filename = pigeonimageDirectory + "\\" + RFID + "_P2" + ".txt";
                    File.WriteAllBytes(filename, GetPhoto(pictureBox1));
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 6
0
        private void grid_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                DataGridView datagrid = this.dtList;
                int          index;
                //Int64 PigeonID;
                String BandNumber = "";
                String RFID       = "";
                if (datagrid.RowCount > 0)
                {
                    index = datagrid.CurrentRow.Index;
                    //PigeonID = Convert.ToInt64(datagrid.Rows[Convert.ToInt32(index)].Cells[2].Value);
                    BandNumber = Convert.ToString(datagrid.Rows[Convert.ToInt32(index)].Cells[2].Value);
                    RFID       = Convert.ToString(datagrid.Rows[Convert.ToInt32(index)].Cells[3].Value);
                    string Category = Convert.ToString(datagrid.Rows[Convert.ToInt32(index)].Cells[4].Value);
                    string Sex      = Convert.ToString(datagrid.Rows[Convert.ToInt32(index)].Cells[5].Value);
                    string Color    = Convert.ToString(datagrid.Rows[Convert.ToInt32(index)].Cells[6].Value);

                    if (BandNumber != "")
                    {
                        if ((string)datagrid.CurrentCell.Value.ToString() == "DELETE")
                        {
                            if ((MessageBox.Show("Are you sure! You would like to delete this record?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes))
                            {
                                ActionType = "DELETE";
                                string   path       = ReadText.ReadFilePath("datapath");
                                string[] pigeonList = SetPigeonList(ActionType, BandNumber, RFID).ToArray();

                                string dateString     = this.dateTimePicker1.Value.Year.ToString() + this.dateTimePicker1.Value.Month.ToString().PadLeft(2, '0') + this.dateTimePicker1.Value.Day.ToString().PadLeft(2, '0');
                                string entryDirectory = path + "\\entry\\" + dateString;
                                string filepath       = entryDirectory + "\\" + txtMemberID.Text + ".txt";

                                if (File.Exists(filepath))
                                {
                                    File.Delete(filepath);
                                }

                                System.IO.File.WriteAllLines(filepath, pigeonList);
                                GetPigeonList(txtMemberID.Text);
                                ActionType = "";
                                this.btnRead.Focus();
                                MessageBox.Show("Record Deleted.", "Delete Record");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }
Exemplo n.º 7
0
        private Boolean SavetoFile(string MemberIDNo, string RFID)
        {
            try
            {
                // string[] pigeonEntry = {RFID};

                string path       = ReadText.ReadFilePath("datapath");
                string dateString = this.dateTimePicker1.Value.Year.ToString() + this.dateTimePicker1.Value.Month.ToString().PadLeft(2, '0') + this.dateTimePicker1.Value.Day.ToString().PadLeft(2, '0');

                string entryDirectory = path + "\\entry\\" + dateString;
                string filepath       = entryDirectory + "\\" + MemberIDNo + ".txt";

                string[] pigeonEntry = SetPigeonList(ActionType, this.txtRingNumber.Text, RFID).ToArray();

                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }

                if (!Directory.Exists(entryDirectory))
                {
                    Directory.CreateDirectory(entryDirectory);
                }

                if (File.Exists(filepath))
                {
                    string[] entryList = ReadText.ReadTextFile(filepath);
                    if (entryList.Contains(RFID))
                    {
                        MessageBox.Show("Bird Already Entry.");
                        return(false);
                    }
                    else
                    {
                        System.IO.File.WriteAllLines(filepath, pigeonEntry); //entrylist
                    }
                }
                else
                {
                    System.IO.File.WriteAllLines(filepath, pigeonEntry); //entrylist
                }

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 8
0
        private void GetMemberName(string memberID)
        {
            try
            {
                string path     = ReadText.ReadFilePath("datapath");
                string filepath = path + "\\members\\" + memberID + ".txt";

                if (File.Exists(filepath))
                {
                    string[] memberDetails = ReadText.ReadTextFile(filepath);
                    this.txtName.Text = memberDetails[1].ToString();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 9
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (this.listBox1.Items.Count > 0)
     {
         string path = ReadText.ReadFilePath("datapath");
         //string filepath = path + "\\pigeonlist\\" + MemberID + ".txt";
         foreach (string item in this.listBox1.Items)
         {
             string[] col = item.Split('|');
             string   pigeonMobileListPath = path + "\\PigeonMobileList\\" + col[0].ToString().Trim() + ".txt";
             if (this.txtName.Text != "" && this.txtMobileNumber.Text != "")
             {
                 string[] mvalue = { this.txtName.Text + "|" + this.txtMobileNumber.Text };
                 System.IO.File.WriteAllLines(pigeonMobileListPath, mvalue); //memberpigeonlist
             }
         }
         MessageBox.Show("Record(s) Save.");
         this.listBox1.Items.Clear();
         GetPigeonList();
     }
 }
Exemplo n.º 10
0
        public static void Logs(string ErrorMessage)
        {
            string path       = ReadText.ReadFilePath("datapath");
            string dateString = DateTime.Today.Year.ToString() + DateTime.Today.Month.ToString().PadLeft(2, '0') + DateTime.Today.Day.ToString().PadLeft(2, '0');
            string errorLogs  = path + @"\" + dateString + ".txt";

            if (File.Exists(errorLogs))
            {
                using (StreamWriter sw = File.AppendText(errorLogs))
                {
                    sw.WriteLine(ErrorMessage);
                }
            }
            else
            {
                using (StreamWriter sw = File.CreateText(errorLogs))
                {
                    sw.WriteLine(ErrorMessage);
                }
            }
        }
Exemplo n.º 11
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you want to delete this record(s)?", "Delete", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                string path = ReadText.ReadFilePath("datapath");
                //string filepath = path + "\\pigeonlist\\" + MemberID + ".txt";
                foreach (string item in this.listBox1.Items)
                {
                    string[] col = item.Split('|');
                    string   pigeonMobileListPath = path + "\\PigeonMobileList\\" + col[0].ToString().Trim() + ".txt";

                    if (File.Exists(pigeonMobileListPath))
                    {
                        File.Delete(pigeonMobileListPath);
                    }
                }
                MessageBox.Show("Record(s) Deleted");
                this.listBox1.Items.Clear();
                GetPigeonList();
            }
        }
Exemplo n.º 12
0
        private void GetMemberName(string memberID)
        {
            try
            {
                string path     = ReadText.ReadFilePath("datapath");
                string filepath = path + "\\members\\" + memberID + ".txt";

                if (File.Exists(filepath))
                {
                    string[] memberDetails = ReadText.ReadTextFile(filepath);
                    this.txtName.Text = memberDetails[1].ToString();
                }
                else
                {
                    MessageBox.Show("Invalid MemberID", "Error");
                    ClearControl();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 13
0
 private void button5_Click(object sender, EventArgs e)
 {
     try
     {
         string MemberIDNo = txtMemberID.Text;
         if (MemberIDNo != "")
         {
             if (MessageBox.Show("Are you sure. You would like to delete this member?", "Delete Record", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 string path = ReadText.ReadFilePath("datapath");
                 File.Delete(path + "\\members\\" + MemberIDNo + ".txt");    //memberdetails
                 File.Delete(path + "\\pigeonlist\\" + MemberIDNo + ".txt"); //memberpigeonlist
                 Directory.Delete(path + "\\pigeonDetails\\" + MemberIDNo, true);
                 Directory.Delete(path + "\\images\\" + MemberIDNo, true);
                 MessageBox.Show("Record Deleted.", "Delete Record");
                 ClearControl();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error");
     }
 }
Exemplo n.º 14
0
        private void LoadImage(string rfid, string memberid)
        {
            try
            {
                string path = ReadText.ReadFilePath("datapath") + "\\images\\" + memberid + "\\";
                if (File.Exists(path + rfid + ".txt"))
                {
                    string       filename = path + rfid + ".txt";
                    MemoryStream ms       = new MemoryStream(File.ReadAllBytes(filename));
                    imgCapture.Image = Image.FromStream(ms);
                }

                if (File.Exists(path + rfid + "_P2" + ".txt"))
                {
                    string       filename = path + rfid + "_P2" + ".txt";
                    MemoryStream ms       = new MemoryStream(File.ReadAllBytes(filename));
                    pictureBox1.Image = Image.FromStream(ms);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 15
0
        private void GetPigeonList(string memberid)
        {
            try
            {
                DataTable pigeonList = new DataTable();

                //DataColumn dc1 = new DataColumn();
                //dc1.ColumnName = "EDIT";

                //DataColumn dc2 = new DataColumn();
                //dc2.ColumnName = "DELETE";

                DataColumn dc2 = new DataColumn();
                dc2.ColumnName = "SeqID";

                DataColumn dc4 = new DataColumn();
                dc4.ColumnName = "BandNumber";

                DataColumn dc5 = new DataColumn();
                dc5.ColumnName = "TagID";

                DataColumn dc6 = new DataColumn();
                dc6.ColumnName = "Category";

                DataColumn dc7 = new DataColumn();
                dc7.ColumnName = "Sex";

                DataColumn dc8 = new DataColumn();
                dc8.ColumnName = "Color";

                DataColumn dc3 = new DataColumn();
                dc3.ColumnName = "Arrival";

                DataColumn dc9 = new DataColumn();
                dc9.ColumnName = "Flight";

                DataColumn dc10 = new DataColumn();
                dc10.ColumnName = "Speed";

                //pigeonList.Columns.Add(dc1);
                pigeonList.Columns.Add(dc2);

                pigeonList.Columns.Add(dc4);
                pigeonList.Columns.Add(dc5);
                pigeonList.Columns.Add(dc6);
                pigeonList.Columns.Add(dc7);
                pigeonList.Columns.Add(dc8);
                pigeonList.Columns.Add(dc3);
                pigeonList.Columns.Add(dc9);
                pigeonList.Columns.Add(dc10);

                string path       = ReadText.ReadFilePath("datapath");
                string dateString = this.dateTimePicker1.Value.Year.ToString() + this.dateTimePicker1.Value.Month.ToString().PadLeft(2, '0') + this.dateTimePicker1.Value.Day.ToString().PadLeft(2, '0');

                //string entryDirectory = path + "entry\\" + dateString;
                //string filepath = entryDirectory + "\\" + memberid + ".txt";

                string resultDirectory = path + "\\result\\" + dateString;
                string filepath        = resultDirectory + "\\" + memberid + ".txt";

                //string filepathList = entryDirectory + "\\" + MemberID + ".txt";

                if (File.Exists(filepath))
                {
                    string[] entryCollection = ReadText.ReadTextFile(filepath);
                    int      counter         = 1;
                    foreach (var rfid in entryCollection)
                    {
                        string   birdDetailsPath         = path + "\\PigeonDetails\\" + memberid + "\\" + rfid + ".txt";
                        string[] pigeonDetailsCollection = ReadText.ReadTextFile(birdDetailsPath);

                        DataRow dr = pigeonList.NewRow();
                        //dr["EDIT"] = "EDIT";
                        //dr["DELETE"] = "DELETE";
                        dr["SeqID"]      = counter;
                        dr["BandNumber"] = pigeonDetailsCollection[0].ToString();
                        dr["TagID"]      = pigeonDetailsCollection[1].ToString();
                        dr["Category"]   = pigeonDetailsCollection[2].ToString();
                        dr["Color"]      = pigeonDetailsCollection[4].ToString();
                        dr["Sex"]        = pigeonDetailsCollection[3].ToString();



                        String resultDetailsPath = resultDirectory + "\\" + memberid + "\\" + rfid + ".txt";

                        if (File.Exists(resultDetailsPath))
                        {
                            string[] resultDetails = ReadText.ReadTextFile(resultDetailsPath);
                            dr["Arrival"] = resultDetails[3] + " " + resultDetails[4];

                            if (resultDetails.Count() > 5)
                            {
                                dr["Flight"] = resultDetails[5];
                                dr["Speed"]  = resultDetails[6];
                            }
                        }

                        pigeonList.Rows.Add(dr);
                        counter++;
                    }
                }

                dtList.DataSource = pigeonList;
                lblcount.Text     = "Total Birds: " + pigeonList.Rows.Count.ToString();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 16
0
        private void GetPigeonList(string memberid)
        {
            try
            {
                DataTable pigeonList = new DataTable();

                DataColumn dc1 = new DataColumn();
                dc1.ColumnName = "EDIT";

                DataColumn dc2 = new DataColumn();
                dc2.ColumnName = "DELETE";

                DataColumn dc3 = new DataColumn();
                dc3.ColumnName = "SeqNo";

                DataColumn dc4 = new DataColumn();
                dc4.ColumnName = "BandNumber";

                DataColumn dc5 = new DataColumn();
                dc5.ColumnName = "TagID";

                DataColumn dc6 = new DataColumn();
                dc6.ColumnName = "Category";

                DataColumn dc7 = new DataColumn();
                dc7.ColumnName = "Sex";

                DataColumn dc8 = new DataColumn();
                dc8.ColumnName = "Color";

                pigeonList.Columns.Add(dc1);
                pigeonList.Columns.Add(dc2);
                pigeonList.Columns.Add(dc3);
                pigeonList.Columns.Add(dc4);
                pigeonList.Columns.Add(dc5);
                pigeonList.Columns.Add(dc6);
                pigeonList.Columns.Add(dc7);
                pigeonList.Columns.Add(dc8);

                //add test ring on the top list
                DataRow drtest = pigeonList.NewRow();
                drtest["EDIT"]       = "";
                drtest["DELETE"]     = "";
                drtest["SeqNo"]      = 1.ToString();
                drtest["BandNumber"] = "TEST RING";
                drtest["TagID"]      = this.txtTestRing.Text;
                drtest["Category"]   = "BOTH";
                drtest["Color"]      = "NA";
                drtest["Sex"]        = "NA";
                pigeonList.Rows.Add(drtest);

                string path     = ReadText.ReadFilePath("datapath");
                string filepath = path + "\\pigeonlist\\" + memberid + ".txt";
                if (File.Exists(filepath))
                {
                    string[] pigeonCollection = ReadText.ReadTextFile(filepath);
                    int      seqNumber        = 2;
                    foreach (string item in pigeonCollection)
                    {
                        string[] value = item.Split('|');
                        DataRow  dr    = pigeonList.NewRow();
                        dr["EDIT"]       = "EDIT";
                        dr["DELETE"]     = "DELETE";
                        dr["SeqNo"]      = seqNumber.ToString();
                        dr["BandNumber"] = value[1].ToString();
                        dr["TagID"]      = value[2].ToString();
                        dr["Category"]   = value[3].ToString();
                        dr["Color"]      = value[4].ToString();
                        dr["Sex"]        = value[5].ToString();
                        pigeonList.Rows.Add(dr);
                        seqNumber++;
                    }
                }

                dtList.DataSource = pigeonList;
                lblcount.Text     = "Total Birds: " + pigeonList.Rows.Count.ToString();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 17
0
        private void GetPigeonList()
        {
            try
            {
                DataTable pigeonList = new DataTable();

                DataColumn dc1 = new DataColumn();
                dc1.ColumnName = " ";

                DataColumn dc2 = new DataColumn();
                dc2.ColumnName = "  ";

                DataColumn dc3 = new DataColumn();
                dc3.ColumnName = "SeqNo";

                DataColumn dc4 = new DataColumn();
                dc4.ColumnName = "BandNumber";


                DataColumn dc5 = new DataColumn();
                dc5.ColumnName = "TagID";

                DataColumn dc6 = new DataColumn();
                dc6.ColumnName = "Name";

                DataColumn dc7 = new DataColumn();
                dc7.ColumnName = "MobileNumner";

                //DataColumn dc8 = new DataColumn();
                //dc8.ColumnName = "Color";

                pigeonList.Columns.Add(dc1);
                pigeonList.Columns.Add(dc2);
                pigeonList.Columns.Add(dc3);
                pigeonList.Columns.Add(dc4);
                pigeonList.Columns.Add(dc5);
                pigeonList.Columns.Add(dc6);
                pigeonList.Columns.Add(dc7);
                //pigeonList.Columns.Add(dc8);

                string path     = ReadText.ReadFilePath("datapath");
                string filepath = path + "\\pigeonlist\\" + MemberID + ".txt";
                if (File.Exists(filepath))
                {
                    string[] pigeonCollection = ReadText.ReadTextFile(filepath);
                    int      seqNumber        = 1;
                    foreach (string item in pigeonCollection)
                    {
                        string[] value = item.Split('|');
                        DataRow  dr    = pigeonList.NewRow();
                        dr[" "]          = "ADD";
                        dr["  "]         = "REMOVE";
                        dr["SeqNo"]      = seqNumber.ToString();
                        dr["BandNumber"] = value[1].ToString();
                        dr["TagID"]      = value[2].ToString();

                        //string path = ReadText.ReadFilePath("datapath");
                        string pigeonMobileListPath = path + "\\PigeonMobileList\\" + value[2].ToString() + ".txt";
                        if (File.Exists(pigeonMobileListPath))
                        {
                            string[] pigeonMobileCollection = ReadText.ReadTextFile(pigeonMobileListPath);
                            string[] values = pigeonMobileCollection[0].ToString().Split('|');
                            dr["Name"]         = values[0].ToString().Trim();
                            dr["MobileNumner"] = values[1].ToString().Trim();
                        }

                        pigeonList.Rows.Add(dr);
                        seqNumber++;
                    }
                }

                dataGridView1.DataSource = pigeonList;
                lblcount.Text            = "Total Birds: " + pigeonList.Rows.Count.ToString();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 18
0
        private void grid_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                DataGridView datagrid = this.dtList;
                int          index;
                //Int64 PigeonID;
                String BandNumber = "";
                String RFID       = "";
                if (datagrid.RowCount > 0)
                {
                    index = datagrid.CurrentRow.Index;
                    int addcellindex = 1;
                    //PigeonID = Convert.ToInt64(datagrid.Rows[Convert.ToInt32(index)].Cells[2].Value);
                    BandNumber = Convert.ToString(datagrid.Rows[Convert.ToInt32(index)].Cells[2 + addcellindex].Value);
                    RFID       = Convert.ToString(datagrid.Rows[Convert.ToInt32(index)].Cells[3 + addcellindex].Value);
                    string Category = Convert.ToString(datagrid.Rows[Convert.ToInt32(index)].Cells[4 + addcellindex].Value);
                    string Sex      = Convert.ToString(datagrid.Rows[Convert.ToInt32(index)].Cells[5 + addcellindex].Value);
                    string Color    = Convert.ToString(datagrid.Rows[Convert.ToInt32(index)].Cells[6 + addcellindex].Value);

                    if (BandNumber != "")
                    {
                        if ((string)datagrid.CurrentCell.Value.ToString() == "EDIT")
                        {
                            ActionType         = "EDIT";
                            txtRingNumber.Text = BandNumber;
                            txtColor.Text      = Color;
                            int indexitem = -1;
                            if (Sex != "")
                            {
                                indexitem = cbmSex.FindString(Sex);
                            }
                            cbmSex.SelectedIndex = indexitem;

                            if (Category != "")
                            {
                                indexitem = cmbCategory.FindString(Category);
                            }
                            cmbCategory.SelectedIndex = indexitem;

                            txtrfid.Text = RFID;
                            LoadImage(RFID, txtMemberID.Text);
                            txtRingNumber.Enabled = false;
                        }
                        else if ((string)datagrid.CurrentCell.Value.ToString() == "DELETE")
                        {
                            if ((MessageBox.Show("Are you sure! You would like to delete this record?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes))
                            {
                                ActionType = "DELETE";
                                string   path       = ReadText.ReadFilePath("datapath");
                                string[] pigeonList = SetPigeonList(ActionType, "0", BandNumber, "", "", RFID, "").ToArray();
                                System.IO.File.WriteAllLines(path + "\\pigeonlist\\" + txtMemberID.Text + ".txt", pigeonList);
                                GetPigeonList(txtMemberID.Text);

                                string deletePath = path + "\\pigeondetails\\" + txtMemberID.Text + "\\" + RFID + ".txt";
                                if (File.Exists(deletePath))
                                {
                                    File.Delete(deletePath);
                                }

                                ActionType = "";
                                //ClearControl();
                                MessageBox.Show("Record Deleted.", "Delete Record");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }
Exemplo n.º 19
0
        private void SyncBanded()
        {
            Eclock eclock     = new Eclock();
            string serialPort = eclock.GetPort();

            string[] ports    = SerialPort.GetPortNames();
            string   commPort = "";

            foreach (var item in ports)
            {
                if (serialPort.Contains(item))
                {
                    commPort = item;
                }
            }

            if (!String.IsNullOrEmpty(commPort))
            {
                //eclock.SyncTime(commPort);
                DataTable dt = new DataTable();
                dt = DataList;

                eclock.SendData("$Stat$", commPort);
                progressBar1.Maximum = dt.Rows.Count;
                System.Threading.Thread.Sleep(2500);

                int counter = 1;
                foreach (DataRow item in dt.Rows)
                {
                    if (counter >= DataStartIndex && counter <= DataEndtIndex)
                    {
                        string path = ReadText.ReadFilePath("datapath");
                        string pigeonMobileListPath = path + "\\PigeonMobileList\\" + item["TagID"].ToString() + ".txt";
                        string mobileNumber         = "";
                        if (File.Exists(pigeonMobileListPath))
                        {
                            string[] pigeonMobileCollection = ReadText.ReadTextFile(pigeonMobileListPath);
                            string[] values = pigeonMobileCollection[0].ToString().Split('|');
                            mobileNumber = values[1].ToString().Trim();
                        }

                        String bandedData = "$BaNd$" +
                                            ClubName + "|" +
                                            item["BandNumber"].ToString() + "|" +
                                            item["TagID"].ToString() + "|" +
                                            item["Category"].ToString() + "|" +
                                            item["Color"].ToString() + "|" +
                                            item["Sex"].ToString().Substring(0, 1) + (mobileNumber != "" ? "|" + mobileNumber + "|#" : "|#");

                        eclock.SendData(bandedData, commPort);
                        this.txtCount.Text = counter.ToString();
                        System.Threading.Thread.Sleep(2500);
                    }

                    progressBar1.Value = counter;
                    counter++;
                }

                eclock.SendData("$Done$|#", commPort);
                MessageBox.Show("Data sync", "Eclock Sync");
                this.Close();
            }
        }
Exemplo n.º 20
0
        private void RetryEntry(string RFID, string MemberID, string OldRemarks)
        {
            try
            {
                string path       = ReadText.ReadFilePath("datapath");
                string dateString = this.DateRelease.Year.ToString() + this.DateRelease.Month.ToString().PadLeft(2, '0') + this.DateRelease.Day.ToString().PadLeft(2, '0');

                string entryDirectory = path + "\\entry\\" + dateString;

                string pathSyncApplication = AppDomain.CurrentDomain.BaseDirectory + "SyncApplication";
                string EntryLogs           = pathSyncApplication + "\\entrylogs.txt";

                string bandedFileName = path + "\\PigeonDetails\\" + MemberID + "\\" + RFID + ".txt";
                string MobileFileName = path + "\\PigeonMobileList\\" + RFID + ".txt";
                if (File.Exists(bandedFileName))
                {
                    string[] pigeondetails = ReadText.ReadTextFile(bandedFileName);
                    BusinessLayer.EclockEntryBLL entryBll    = new EclockEntryBLL();
                    DomainObjects.Entry          entryObject = new DomainObjects.Entry();
                    entryObject.Clubname              = ClubName;
                    entryObject.MemberIDNo            = MemberID;
                    entryObject.ReleaseDate           = this.DateRelease;
                    entryObject.RingNumber            = pigeondetails[0];
                    entryObject.RaceCategoryName      = pigeondetails[2];
                    entryObject.MobileNumber          = "";
                    entryObject.RaceCategoryGroupName = "EClock";
                    entryObject.RFID = RFID;

                    if (File.Exists(MobileFileName))
                    {
                        string[] pigeonMobileCollection = ReadText.ReadTextFile(MobileFileName);
                        string[] values = pigeonMobileCollection[0].ToString().Split('|');
                        entryObject.MobileNumber = values[1].ToString().Trim();
                    }

                    DataSet dtResult = new DataSet();
                    dtResult = entryBll.EclockEntrySave(entryObject);

                    if (dtResult.Tables.Count > 0)
                    {
                        if (dtResult.Tables[0].Rows.Count > 0)
                        {
                            String Remarks = dtResult.Tables[0].Rows[0]["Remarks"].ToString();

                            if (Remarks.ToUpper() != "SUCCESS")
                            {
                                String LogContents        = MemberID + "|" + RFID + "|" + pigeondetails[0] + "|" + Remarks + "|";
                                string removeFromLogsPath = pathSyncApplication + "\\entrylogs.txt";
                                if (!CheckRemarks(LogContents, removeFromLogsPath))
                                {
                                    if (File.Exists(EntryLogs))
                                    {
                                        using (StreamWriter sw = File.AppendText(EntryLogs))
                                        {
                                            sw.WriteLine(LogContents);
                                        }
                                    }
                                    else
                                    {
                                        using (StreamWriter sw = File.CreateText(EntryLogs))
                                        {
                                            sw.WriteLine(LogContents);
                                        }
                                    }
                                }

                                MessageBox.Show("Error detected.", "Error");
                            }
                            else
                            {
                                string removeFromLogsPath = pathSyncApplication + "\\entrylogs.txt";
                                String removeFromLogs     = MemberID + "|" + RFID + "|" + pigeondetails[0] + "|" + OldRemarks + "|";
                                UpdateLogs(removeFromLogs, removeFromLogsPath);
                                MessageBox.Show("Eclock entry sync to database.", "Eclock Sync");
                            }
                        }
                    }
                }
                ReadEntryLogs();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 21
0
        private void RetryResult(string RFID, string MemberID, string OldRemarks)
        {
            try
            {
                string path = ReadText.ReadFilePath("datapath");
                string pathSyncApplication = AppDomain.CurrentDomain.BaseDirectory + "SyncApplication";

                string dateString = this.DateRelease.Year.ToString() + this.DateRelease.Month.ToString().PadLeft(2, '0') + this.DateRelease.Day.ToString().PadLeft(2, '0');

                string resultDirectory = path + "\\result\\" + dateString;
                string resultLogs      = pathSyncApplication + "\\resultlogs.txt";

                string resultFileName = resultDirectory + "\\" + MemberID + "\\" + RFID + ".txt";
                if (File.Exists(resultFileName))
                {
                    string[] resultdetails           = ReadText.ReadTextFile(resultFileName);
                    BusinessLayer.ResultBLL entryBll = new ResultBLL();

                    //sample ECLOCK 0001 15204188 19/07/05 07:48:18
                    String ResultStringFormat    = "ECLOCK " + resultdetails[0] + " " + resultdetails[1] + " " + resultdetails[3] + " " + resultdetails[4];
                    DomainObjects.Result dObject = new DomainObjects.Result
                    {
                        ClubName   = ClubName,
                        SMSContent = ResultStringFormat,
                        ActionFrom = "E-Clock Apps"
                    };

                    DataSet dtResult = new DataSet();
                    dtResult = entryBll.EclockResultSave(dObject);

                    if (dtResult.Tables.Count > 0)
                    {
                        if (dtResult.Tables[0].Rows.Count > 0)
                        {
                            String Remarks = dtResult.Tables[0].Rows[0]["Remarks"].ToString();

                            if (Remarks.ToUpper() != "SUCCESS")
                            {
                                String LogContents        = MemberID + "|" + RFID + "|" + resultdetails[3] + "|" + Remarks + "|";
                                string removeFromLogsPath = pathSyncApplication + "\\resultlogs.txt";
                                if (!CheckRemarks(LogContents, removeFromLogsPath))
                                {
                                    if (File.Exists(resultLogs))
                                    {
                                        using (StreamWriter sw = File.AppendText(resultLogs))
                                        {
                                            sw.WriteLine(LogContents);
                                        }
                                    }
                                    else
                                    {
                                        using (StreamWriter sw = File.CreateText(resultLogs))
                                        {
                                            sw.WriteLine(LogContents);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                //string pathSyncApplication = AppDomain.CurrentDomain.BaseDirectory + "SyncApplication";
                                string removeFromLogsPath = pathSyncApplication + "\\resultlogs.txt";

                                String removeFromLogs = MemberID + "|" + RFID + "|" + resultdetails[3] + "|" + OldRemarks + "|";
                                UpdateLogs(removeFromLogs, removeFromLogsPath);
                                MessageBox.Show("Eclock entry sync to database.", "Eclock Sync");
                            }
                        }
                    }
                }
                ReadResultLogs();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }