void main_program(object sender, program e)
 {
     try
     {
         if (e.overView == 1)
         {
             Thread getData = new Thread(() =>
             {
                 this.Dispatcher.Invoke((Action)(() =>
                 {
                     readDatabase();
                     cardTab(" WHERE type='1' AND enabled=1");
                     eventTab(" ORDER BY date DESC");
                     defaultSet();
                 }));
             });
             getData.IsBackground = true;
             getData.Start();
         }
     }
     catch (Exception add)
     {
         //using (FileStream fs = new FileStream(@"log\log.txt", FileMode.Append, FileAccess.Write))
         //{
         //    byte[] write = Encoding.ASCII.GetBytes("OVERVIEW EVENTER FAIL\r\n");
         //    fs.Write(write, 0, write.Length);
         //    write = Encoding.ASCII.GetBytes(add.ToString());
         //    fs.Write(write, 0, write.Length);
         //    write = Encoding.ASCII.GetBytes("\r\n--------------------------------------\r\n");
         //    fs.Write(write, 0, write.Length);
         //    fs.Flush();
         //    fs.Close();
         //}
     }
 }
Exemple #2
0
 void activator_activatorEventer(object sender, program e)
 {
     if(e.abort)
     {
         if(wait != null) abort();
     }else if(e.start == true)
     {
         checkCard();
     }
 }
        void main_program(object sender, program e)
        {
            try
            {
                this.Dispatcher.Invoke((Action)(() =>
                {
                    if (e.cardAvaible == 2 && program.Page == 2)
                    {
                        t.Stop();
                        List<string> result = SL500.readCard();

                        if (result != null)
                        {
                            if (result.Count <= 2)
                            {
                                if (!SQL.isInDb(result[0])) SQL.addToDb(result[0], 0);

                                this.card.Content = result[0];
                                this.state.Content = "Not active";
                                this.update.Visibility = Visibility.Hidden;
                                controlstate(2);

                            }
                            else if (result.Count == 3)
                            {
                                controlstate(4, "Sorry, this card is activated for another owner, please remove card from reader");
                            }
                            else if (result != null && result[1] != "6")
                            {
                                this.card.Content = result[0];

                                if (!SQL.isInDb(result[0])) SQL.addToDb(result[0], 0);

                                switch (result[1])
                                {
                                    case "0":
                                        this.type.SelectedIndex = 4;
                                        break;
                                    case "1":
                                        this.type.SelectedIndex = 0;
                                        this.subtype.SelectedIndex = 0;
                                        break;
                                    case "2":
                                        if (debit())
                                        {
                                            this.type.SelectedIndex = 0;
                                            this.subtype.SelectedIndex = 1;
                                        }
                                        else
                                        {
                                            this.type.SelectedIndex = 0;
                                            this.subtype.SelectedIndex = 0;
                                        }
                                        break;
                                    case "3":
                                        this.type.SelectedIndex = 1;
                                        break;
                                    case "4":
                                        this.type.SelectedIndex = 2;
                                        break;
                                    case "5":
                                        this.type.SelectedIndex = 3;
                                        break;
                                }
                                this.name.Text = result[3];
                                this.surname.Text = result[4];
                                this.function.Text = result[5];
                                this.dis_amount.Text = result[6];
                                this.state.Content = "Activated";
                                this.update.Visibility = Visibility.Visible;
                                this.deactivate.Visibility = Visibility.Visible;

                                SQL.updateCard(result);

                                controlstate(0);
                            }
                            else if (result[1] == "6")
                            {
                                this.card.Content = result[0];
                                controlstate(4, "Sorry, this card is only for activation of application or manage machine, please remove card from reader and insert another card");
                            }
                        }

                    }
                    else if (e.cardAvaible == 1)
                    {
                        controlstate(1);
                    }

                    if (e.page == 1)
                    {
                        controlstate(1);
                    }
                }));
            }catch(Exception name)
            {
                //using (FileStream fs = new FileStream(@"log\log.txt", FileMode.Append, FileAccess.Write))
                //{
                //    byte[] write = Encoding.ASCII.GetBytes("ACTIVATOR EVENTER FAIL\r\n");
                //    fs.Write(write, 0, write.Length);
                //    write = Encoding.ASCII.GetBytes(name.Message);
                //    fs.Write(write, 0, write.Length);
                //    write = Encoding.ASCII.GetBytes("\r\n--------------------------------------\r\n");
                //    fs.Write(write, 0, write.Length);
                //    fs.Flush();
                //    fs.Close();
                //}
            }

        }
        void main_program(object sender, program e)
        {
            try
            {
                this.Dispatcher.Invoke((Action)(() =>
                  {
                      #region READ SECTION
                      if (e.cardAvaible == 2 && program.Page == 3)
                      {
                          List<string> result = SL500.readCard();

                          if (result != null && result.Count > 3)
                          {
                              if (!SQL.isInDb(result[0])) SQL.addToDb(result[0], (int.Parse(result[1]) > 0) ? 1 : 0);
                              this.card.Content = result[0];

                              int type = 0;

                              switch (result[1])
                              {
                                  case "1":
                                      this.creditDebet.Content = "credit";
                                      this.delQuestion.Content = "Are you sure, you want delete all credits?";
                                      this.btn_show_del.Content = "delete credit";
                                      typeOfCard = 1;
                                      break;
                                  case "2":
                                      if (CManager.Properties.Settings.Default.debit == 0)
                                      {
                                          managerEventer(this, new program() { abort = true });
                                          read = false;
                                          controlstate(4, "This application is not activated for debit", "Manager is available for credit cards only");
                                          type = 1;
                                          typeOfCard = 0;
                                      }
                                      else
                                      {
                                          this.creditDebet.Content = "debit";
                                          this.delQuestion.Content = "Are you sure, you want delete debet credit?";
                                          this.btn_show_del.Content = "delete debit";
                                          typeOfCard = 2;
                                      }

                                      break;
                                  case "0":
                                  case "3":
                                  case "4":
                                  case "5":
                                      managerEventer(this, new program() { abort = true });
                                      read = true;
                                      controlstate(4, "You can't manage credit or debit at this card", "Manager is available for customer card only. To change type of card go to activation section");
                                      type = 1;
                                      typeOfCard = 0;
                                      break;
                                  case "6":
                                      managerEventer(this, new program() { abort = true });
                                      read = true;
                                      controlstate(4, "ERROR OCCURED", "Sorry, this card is only for activation of application or manage machine, please remove card from reader and insert another card");
                                      type = 1;
                                      typeOfCard = 0;
                                      break;

                              }

                              if (type == 0)
                              {
                                  char[] _trim = new char[] { '\0' };

                                  // work with credit / debet

                                  if (result[2] != "0")
                                  {
                                      double double_credit = double.Parse(result[2]) / 100;
                                      this.amount.Content = double_credit.ToString("F2", CultureInfo.CreateSpecificCulture("en-US"));

                                      if (result[1] == "1")
                                      {
                                          this.btn_show_add.Visibility = Visibility.Visible;
                                          this.btn_show_del.Visibility = Visibility.Visible;
                                      }
                                      else if (result[1] == "2")
                                      {
                                          this.btn_show_add.Visibility = Visibility.Hidden;
                                          this.btn_show_del.Visibility = Visibility.Visible;
                                      }
                                  }
                                  else
                                  {
                                      this.amount.Content = "0.00";

                                      if (result[1] == "1")
                                      {
                                          this.btn_show_add.Visibility = Visibility.Visible;
                                          this.btn_show_del.Visibility = Visibility.Hidden;
                                      }
                                      else if (result[1] == "2")
                                      {
                                          this.btn_show_add.Visibility = Visibility.Hidden;
                                          this.btn_show_del.Visibility = Visibility.Hidden;
                                      }
                                  }

                                  this.name.Text = result[3];
                                  this.surname.Text = result[4];
                                  this.function.Text = result[5];

                                  SQL.updateCard(result);

                                  controlstate(0);
                              }
                          }
                          else if (result.Count == 3)
                          {
                              this.card.Content = result[0];
                              managerEventer(this, new program() { abort = true });
                              read = true;
                              controlstate(4, "ERROR OCCURED", "Sorry, this card is activated for another owner, please remove card from reader and push button");
                          }

                      }
                      else if (e.cardAvaible == 1)
                      {
                          controlstate(1);
                      }
                      #endregion

                      if (e.page == 1)
                      {
                          this.controlstate(1);
                      }
                  }));
            }
            catch (Exception name)
            {
                //using (FileStream fs = new FileStream(@"log\log.txt", FileMode.Append, FileAccess.Write))
                //{
                //    byte[] write = Encoding.ASCII.GetBytes("MANAGER EVENTER FAIL\r\n");
                //    fs.Write(write, 0, write.Length);
                //    write = Encoding.ASCII.GetBytes(name.Message);
                //    fs.Write(write, 0, write.Length);
                //    write = Encoding.ASCII.GetBytes("\r\n--------------------------------------\r\n");
                //    fs.Write(write, 0, write.Length);
                //    fs.Flush();
                //    fs.Close();
                //}
            }
        }
Exemple #5
0
        void programEventer(object sender, program e)
        {
            try
            {
                this.Dispatcher.Invoke((Action)(() =>
                {
                    if (e.typeOfIcon != 0)
                    {
                        setInfo(e.typeOfIcon, e.textForMesenger);
                    }
                    #region mode button
                    if (e.setMode == 2 && this.mode.IsEnabled != true && program.Owner != 0)
                    {
                        this.owerview.IsEnabled = true;
                        this.mode.IsEnabled = true;
                    }
                    else if (e.setMode == 1 && this.mode.IsEnabled != false && program.Owner != 0) this.owerview.IsEnabled = false;
                    #endregion

                    #region Page Selector
                    if (e.page > 0)
                    {
                        switch (e.page)
                        {
                            case 1: // selector
                                this.Navigate(selector_, 1, 1, false);
                                break;
                            case 2: // activator
                                this.Navigate(activator_, 2, 2, true);
                                break;
                            case 3: // manager
                                this.Navigate(manager_, 2, 3, true);
                                break;
                            case 4: // owerview
                                this.Navigate(owerview_, 2, 4, false);
                                break;
                            case 5: // first start
                                this.Navigate(first_, 1, 5, true);
                                break;
                        }
                    }
                    #endregion

                    #region Card events
                    if (e.deviceAvaible == 2)
                    {
                        com.connect();
                        setInfo(3, "reader is connected");
                    }
                    else if (e.deviceAvaible == 1)
                    {
                        com.disconnect();
                        if (program.Page != 4 && program.Page != 5) this.content.animateHeight(HeightProperty, this.content.Height, 3);
                        setInfo(1, "reader is not connected");
                    }
                    #endregion
                }));
            }
            catch (Exception add)
            {
                //using (FileStream fs = new FileStream(@"log\log.txt", FileMode.Append, FileAccess.Write))
                //{
                //    byte[] write = Encoding.ASCII.GetBytes("MAIN EVENTER FAIL\r\n");
                //    fs.Write(write, 0, write.Length);
                //    write = Encoding.ASCII.GetBytes(add.ToString());
                //    fs.Write(write, 0, write.Length);
                //    write = Encoding.ASCII.GetBytes("\r\n--------------------------------------\r\n");
                //    fs.Write(write, 0, write.Length);
                //    fs.Flush();
                //    fs.Close();
                //}
            }
        }
        void main_program(object sender, program e)
        {
            try
            {
                this.Dispatcher.Invoke((Action)(() =>
                {
                    if (e.deviceAvaible == 2)
                    {
                        com.connect();
                    }
                    if (e.setMode == 2)
                    {
                        com.checkCard();
                    }
                    if (e.cardAvaible == 2)
                    {
                        t.Stop();
                        List<string> result = SL500.readCard();

                        if (result != null)
                        {
                            if (result.Count <= 2)
                            {
                                this.card.Content = result[0];
                                this.state.Content = "Not active";
                                this.update.Visibility = Visibility.Hidden;
                                controlstate(2);

                            }
                            else if (result.Count == 3 && result[1] == "6" && IsSelect == true)
                            {
                                this.own_new.Content = own_name.Text + " (" + result[2] + ")";
                                SQL.addowner(result[2], own_name.Text);
                                activatorEventer(this, new program() { abort = true });
                            }
                            else if (result.Count == 7 && result[1] == "6" && IsSelect == false)
                            {
                                controlstate(4, "This card i for activation | owner: " + program.Owner.ToString());
                            }
                            else if (result.Count == 3 && result[2] != program.Owner.ToString())
                            {
                                deErr.Visibility = Visibility.Visible;
                                controlstate(4, "This card i for another owner: " + result[2] + "\r\n Do you want deactivate this card?");
                            }
                            else if (result != null && result[1] != "6")
                            {
                                this.card.Content = result[0];
                                switch (result[1])
                                {
                                    case "0":
                                        this.type.SelectedIndex = 4;
                                        break;
                                    case "1":
                                        this.type.SelectedIndex = 0;
                                        this.subtype.SelectedIndex = 0;
                                        break;
                                    case "2":
                                        this.type.SelectedIndex = 0;
                                        this.subtype.SelectedIndex = 0;
                                        break;
                                    case "3":
                                        this.type.SelectedIndex = 1;
                                        break;
                                    case "4":
                                        this.type.SelectedIndex = 2;
                                        break;
                                    case "5":
                                        this.type.SelectedIndex = 3;
                                        break;
                                }
                                this.name.Text = result[3];
                                this.surname.Text = result[4];
                                this.function.Text = result[5];
                                //this.dis_amount.Text = result[6];
                                this.state.Content = "Activated";
                                this.update.Visibility = Visibility.Visible;
                                this.deactivate.Visibility = Visibility.Visible;

                                controlstate(0);
                            }
                        }

                    }
                    else if (e.cardAvaible == 1)
                    {
                        controlstate(1);
                    }
                }));
            }
            catch (Exception name)
            {
                using (FileStream fs = new FileStream(@"log\log.txt", FileMode.Append, FileAccess.Write))
                {
                    byte[] write = Encoding.ASCII.GetBytes("ACTIVATOR EVENTER FAIL\r\n");
                    fs.Write(write, 0, write.Length);
                    write = Encoding.ASCII.GetBytes(name.Message);
                    fs.Write(write, 0, write.Length);
                    write = Encoding.ASCII.GetBytes("\r\n--------------------------------------\r\n");
                    fs.Write(write, 0, write.Length);
                    fs.Flush();
                    fs.Close();
                }
            }

        }
Exemple #7
0
        void main_program(object sender, program e)
        {
            try
            {
                if (e.cardAvaible == 2 && program.Page == 5)
                {
                    List<string> result = SL500.readCard();

                    if (result.Count == 3 && result != null)
                    {
                        this.Dispatcher.Invoke((Action)(() =>
                        {
                            if (result[1] == "6")
                            {
                                CManager.Properties.Settings.Default.owner = SL500.ownerId(0);
                                CManager.Properties.Settings.Default.Save();

                                CManager.Properties.Settings.Default.debit = SL500.ownerId(1);
                                CManager.Properties.Settings.Default.Save();

                                this.bg.BlurApply(8, program.tSpan);
                                this.success.Visibility = Visibility.Visible;
                                this.spinWait.Visibility = Visibility.Hidden;
                                this.unsuccess.Visibility = Visibility.Hidden;
                            }
                            else
                            {
                                this.bg.BlurApply(8, program.tSpan);
                                this.success.Visibility = Visibility.Hidden;
                                this.spinWait.Visibility = Visibility.Hidden;
                                this.unsuccess.Visibility = Visibility.Visible;
                            }

                            firstEventer(this, new program() { abort = true });
                        }));
                    }
                    else
                    {
                        this.Dispatcher.BeginInvoke((Action)(() =>
                        {
                            this.bg.BlurApply(8, program.tSpan);
                            this.success.Visibility = Visibility.Hidden;
                            this.spinWait.Visibility = Visibility.Hidden;
                            this.unsuccess.Visibility = Visibility.Visible;
                            firstEventer(this, new program() { abort = true });
                        }));
                    }
                }
            }
            catch (Exception add)
            {
                //using (FileStream fs = new FileStream(@"log\log.txt", FileMode.Append, FileAccess.Write))
                //{
                //    byte[] write = Encoding.ASCII.GetBytes("FIRST EVENTER FAIL\r\n");
                //    fs.Write(write, 0, write.Length);
                //    write = Encoding.ASCII.GetBytes(add.ToString());
                //    fs.Write(write, 0, write.Length);
                //    write = Encoding.ASCII.GetBytes("\r\n--------------------------------------\r\n");
                //    fs.Write(write, 0, write.Length);
                //    fs.Flush();
                //    fs.Close();
                //}
            }
        }