Ejemplo n.º 1
0
 private void button4_Click(object sender, EventArgs e)
 {
     //dbw.isBookBusy("");
     this.label8.Text = "";
     this.label9.Text = "";
     this.label5.Text = "";
     BookRecord = null;
     ReaderRecord = null;
     label1.Text = "�������� �������� �������";
     button2.Enabled = false;
     button4.Enabled = false;
 }
Ejemplo n.º 2
0
        void Form1_Scanned(object sender, EventArgs ev)
        {
            #region cash
            /*Singletone  - ���� �������� ��� ���
            typedef std::pair<BookId, bool> BookFreePair;
            typedef std::vector<BookFreePair> BooksFreeType;

            � ������ ������ ���� ��������� BooksFreeType

            BooksFreeType cache_;
            ...
            bool isBookBusy(BookId bookId)
            {
               if(iterator find = cashe_.find(bookId))
              return find->second;

               bool busy = ReadBookBusyFromBD();
               cache.push_back(std::make_pair(bookId, busy));
               return busy;
            }
              */
            #endregion
            //MessageBox.Show(((IOPOSScanner_1_10)sender).ScanData.ToString());
            string g = tabControl1.SelectedTab.ToString();
            switch (tabControl1.SelectedTab.Text)
            {
                case "�������� ��������":
                    #region formular
                    //string _data = ((IOPOSScanner_1_10)sender).ScanData.ToString();
                    string _data = FromPort;
                    if (!dbw.isReader(_data))
                    {
                        MessageBox.Show("�������� �������� ��������!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    /*if (_data.Length < 20)
                        _data = _data.Remove(0, 1);*/
                    //_data = _data.Remove(_data.Length - 1, 1);
                    ReaderRecordFormular = new DBWork.dbReader(_data);

                    if (ReaderRecordFormular.barcode == "notfoundbynumber")
                    {
                        MessageBox.Show("�������� �� ������, ���� �������� ��������!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (ReaderRecordFormular.barcode == "numsoc")
                    {
                        MessageBox.Show("�������� �� ������, ���� �������� �������!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (ReaderRecordFormular.barcode == "sersoc")
                    {
                        MessageBox.Show("�� ������������� ����� ���������� �����!�������� ������� ���������� �����!����� ���������� ����� ������� �������, �� ��������� �����! ����� ���������� ����� ���������� ���������������� � ������������!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    OldBase(ReaderRecordFormular);
                    label20.Text = ReaderRecordFormular.Surname + " " + ReaderRecordFormular.Name + " " + ReaderRecordFormular.SecondName;
                    textBox6.Text = ReaderRecordFormular.AbonType;
                    label25.Text = ReaderRecordFormular.id;

                    //dbw.SetPenalty(ReaderRecordFormular.id);
                    this.FormularColumnsForming(ReaderRecordFormular.id);

                    /*Formular.Columns[1].Width = 100;
                    Formular.Columns[2].Visible = false;
                    Formular.Columns[4].Visible = false;
                    Formular.Columns[3].HeaderText = "�����";
                    Formular.Columns[3].Width = 90;
                    Formular.Columns[5].HeaderText = "��� �������";
                    Formular.Columns[5].Width = 110;
                    Formular.Columns[7].Visible = false;
                    Formular.Columns[6].HeaderText = "����� �������";
                    Formular.Columns[6].Width = 170;
                    Formular.Columns[8].HeaderText = "���� ������";
                    Formular.Columns[8].Width = 130;
                    Formular.Columns[9].HeaderText = "�������������� ���� ��������";
                    Formular.Columns[9].Width = 130;
                    Formular.Columns[10].HeaderText = "����������� ���� ��������";
                    Formular.Columns[10].Width = 130;
                    Formular.Columns[11].HeaderText = "���������";
                    Formular.Columns[11].Width = 130;*/

                    //Formular.Columns[8].Visible = false;
                    //Formular.Columns[9].Visible = false;
                    Sorting.WhatStat = Stats.Formular;
                    Sorting.AuthorSort = SortDir.None;
                    Sorting.ZagSort = SortDir.None;
                    break;
                    #endregion
                case "������ ��������� ��������":
                    #region vidachashtrihcoda

                    if (label16.Visible)
                    {
                        //string BarCode = ((IOPOSScanner_1_10)sender).ScanData.ToString().Remove(((IOPOSScanner_1_10)sender).ScanData.ToString().Length - 1, 1);
                        string BarCode = FromPort;
                        switch (dbw.SetReaderBarCode(ReaderSetBarcode.id, BarCode))
                        {
                            case -5:
                                MessageBox.Show("������ �������� ��������!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                break;
                            case -1:
                                MessageBox.Show("������ ���� ������.", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                break;
                            case -2:
                                MessageBox.Show("�������� �� ������", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                break;
                            case -4:
                                MessageBox.Show("����� �������� ��� ���������� � ����! �������� ������!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                break;
                            case -3:
                                MessageBox.Show("� �������� ���� �������� �� ���������� �����! ������ ��������� ����� �������� �� ���������.", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                groupBox4.Enabled = true;
                                break;
                            case 1:
                                textBox5.Text = BarCode;
                                //timer2.Enabled = false;
                                label16.Visible = false;
                                //tabControl1.Enabled = true;
                                groupBox4.Enabled = true;
                                label16.Visible = false;
                                MessageBox.Show("�������� ������� ������ � ��������!", "�������!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                break;

                        }
                        return;
                    }
                    else
                        MessageBox.Show("������� ������� ��������!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    break;
                    #endregion
                case "����/������ �������":
                    #region priemVidacha
                    //timer1.Enabled = true;
                    label1.Enabled = true;
                    //button2.Enabled = false;
                    //button4.Enabled = false;

                    //_data = "9643909027074162622 1107009";

                    if ((this.emul == "") || (this.emul == null))
                    {
                        _data = FromPort;
                    }
                    else
                    {
                        _data = this.emul;
                    }
                    if ((this.ReaderRecord != null) && (this.BookRecord != null))
                    {
                        MessageBox.Show("����������� ���������� ��������!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        this.emul = "";
                        return;
                    }
                    //MessageBox.Show(_data);
                    ReaderRecordWork = null;
                    BookRecordWork = null;
                    if (dbw.isReader(_data))
                    {
                        /*if (_data.Length < 20)
                            _data = _data.Remove(0, 1);*/
                        //_data = _data.Remove(_data.Length - 1, 1);
                        ReaderRecordWork = new DBWork.dbReader(_data);
                        if (ReaderRecordWork.barcode == "notfoundbynumber")
                        {
                            MessageBox.Show("�������� �� ������, ���� �������� ��������!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            this.emul = "";
                            return;
                        }
                        if (ReaderRecordWork.barcode == "numsoc")
                        {
                            MessageBox.Show("�������� �� ������, ���� �������� �������!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            this.emul = "";
                            return;
                        }
                        if (ReaderRecordWork.barcode == "sersoc")
                        {
                            MessageBox.Show("�� ������������� ����� ���������� �����!�������� ������� ���������� �����!����� ���������� ����� ������� �������, �� ��������� �����! ����� ���������� ����� ���������� ���������������� � ������������!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            this.emul = "";
                            return;
                        }

                        if (OldBase())
                        {
                            this.emul = "";
                            return;
                        }
                        if (this.ReaderRecord != null)
                        {
                            this.emul = "";
                            return;
                        }
                        if (this.ReaderRecord != null)
                        {
                            MessageBox.Show("����������� ���������� ��������!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            this.emul = "";
                            return;
                        }
                        if (ReaderRecordWork.barcode == "error")
                        {
                            MessageBox.Show("�������� �� ��������������� ���� �� ������������� ����� ���������� �����!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            this.emul = "";
                            return;
                        }
                        /*if (ReaderRecordWork.RegInMos != DateTime.MinValue)
                        {
                            if ((ReaderRecordWork.RegInMos - DateTime.Today).Days < 60)
                            {
                                MessageBox.Show("� �������� ������������� ���� ����������� � ������! �������� ����� 60 ����!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                this.emul = "";
                            }
                        }*/

                    }
                    else
                    {
                        //_data = _data.Remove(_data.Length - 1, 1);
                        BookRecordWork = new DBWork.dbBook(_data);
                        if (BookRecordWork.id == "�������� ��������")
                        {
                            MessageBox.Show("������ �������� �������� ���� ������� �� �������� (�����) ��������!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            this.emul = "";
                            return;
                         }

                    }
                    if ((BookRecord != null) && (BookRecordWork != null))
                    {
                        MessageBox.Show("������� ��������� 2-� ������� ������! �������� �������� ��������!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        this.emul = "";
                        return;
                    }

                    if (ReaderRecord == null)
                    {
                        if (BookRecord != null)
                        {
                            if (ReaderRecordWork != null)
                            {
                                ReaderRecord = ReaderRecordWork.Clone();
                                this.label5.Text = ReaderRecord.FIO;
                                //��������� ����� � �������� ����� ������ � ����������� ��� ������
                                button2.Enabled = true;
                                button4.Enabled = true;
                                button2.Focus();
                                this.AcceptButton = button2;
                                label1.Text = "����������� ������";
                            }
                            else
                            {
                                MessageBox.Show("������� ��������� 2-� ������� ������! �������� �������� ��������!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                this.emul = "";
                                return;
                            }
                        }
                        else
                        {
                            if (ReaderRecordWork != null)
                            {
                                MessageBox.Show("������ �������� ��������! �������� �������� �������!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                this.emul = "";
                                return;
                            }
                            else
                            {
                                if (dbw.isBookBusy(_data))
                                {
                                    string expireddays = GetExpiredDays(BookRecordWork.inv);
                                    dbw.setBookReturned(BookRecordWork.id, BookRecordWork);

                                    if (int.Parse(expireddays) > 0)
                                    {
                                        MessageBox.Show("������� ������ ����� ��������� �� " + expireddays + " ����. ����� ���������� " + CalculatePeny(BookRecordWork.vzv, DateTime.Today).ToString() + " ���.", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }

                                    dataGridView1.Rows.Insert(0, 1);
                                    dataGridView1.Rows[0].Cells[0].Value = BookRecordWork.inv;
                                    dataGridView1.Rows[0].Cells[1].Value = BookRecordWork.name;
                                    if (BookRecordWork.rname == "-1")
                                    {
                                        BookRecordWork.rname = "����������";
                                    }
                                    dataGridView1.Rows[0].Cells[2].Value = BookRecordWork.rname;
                                    dataGridView1.Rows[0].Cells[3].Value = "����������";
                                    dbw.InsertActionRETURNED(new DBWork.dbReader(BookRecordWork.rbar), BookRecordWork);
                                    BookRecord = null;
                                    ReaderRecord = null;
                                    button2.Enabled = false;
                                    button4.Enabled = false;
                                    label1.Text = "�������� �������� �������";
                                    //MessageBox.Show("����� ����������!", "����������", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    this.emul = "";
                                    return;
                                }
                                else
                                {
                                    this.label8.Text = BookRecordWork.author;
                                    this.label9.Text = BookRecordWork.name;
                                    this.label1.Text = "�������� ����� ��� ��������";
                                    this.button4.Enabled = true;
                                    BookRecord = BookRecordWork.Clone();
                                    this.emul = "";
                                    return;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (BookRecord != null)
                        {
                            MessageBox.Show("����������� ���������� ��������!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            button2.Enabled = true;
                            button4.Enabled = true;
                            this.emul = "";
                            return;
                        }
                        else
                        {
                            this.label1.Text = "�������� ����� ��� �������!";
                            BookRecord = null;
                            ReaderRecord = null;
                        }
                    }

                    /*if (dbw.isReader(_data))
                        ReaderRecord = dbw.getDbReader(_data);
                    else
                        BookRecord = dbw.getDbBook(_data);*/
                    this.emul = "";
                    break;
                    #endregion
                case "�������":
                    //timer1.Enabled = false;
                    label1.Enabled = false;
                    //timer2.Enabled = false;
                    label16.Visible = false;
                    break;

            }
        }
Ejemplo n.º 3
0
        public void button2_Click_1(object sender, EventArgs e)
        {
            //FindReaderInOldBase(ReaderRecord);
            if (ReaderRecord.RegInMos != DateTime.MinValue)
            {
                if ((ReaderRecord.RegInMos - DateTime.Today).Days < 60)
                {
                    MessageBox.Show("� �������� ������������� ���� ����������� � ������! �������� ����� 60 ����!", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.emul = "";
                }
            }

            bool set = false;
            //long copy_tStatus;
            //copy_tStatus = 0;
            if (dbw.isBookBusy(BookRecord.barcode))
            {
                MessageBox.Show("����� � ������� ��������! ���� ��������: " + dbw.GetDateRet(BookRecord.barcode) + ".", "��������!", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                this.label8.Text = "";
                this.label9.Text = "";
                this.label5.Text = "";
                BookRecord = null;
                ReaderRecord = null;
            }
            else
            {
                if (dbw.isReaderHaveRights(ReaderRecord))
                {
                    if (!dbw.isRightsExpired(ReaderRecord.id))
                    {
                        set = true;
                    }
                    else
                    {
                        switch (MessageBox.Show("� ������� �������� ���������� ���� ���� ����������� ������������ �����������! ������ �������� ����� ������������ ����� �� ��������� ���� ������������� ���������� � ������ ��� �����?", "��������!", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
                        {
                            case DialogResult.Yes:
                                set = true;
                                dbw.ProlongRights(ReaderRecord.id);
                                break;
                            case DialogResult.No:
                                set = false;
                                this.label8.Text = "";
                                this.label9.Text = "";
                                this.label5.Text = "";
                                BookRecord = null;
                                ReaderRecord = null;
                                button2.Enabled = false;
                                button4.Enabled = false;
                                label1.Text = "�������� �������� �������";
                                break;
                            case DialogResult.Cancel:
                                set = false;
                                break;
                        }

                    }

                }
                else
                {
                    switch (MessageBox.Show("� ������� �������� ��� ���� ��� ��������� ���� ������������� ����������! ������ ������ ����� ������������ ����� �� ��������� ���� ������������� ���������� � ������ ��� �����?", "��������!", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
                    {
                        case DialogResult.Yes:
                            set = true;
                            dbw.setReaderRight(ReaderRecord.id);
                            break;
                        case DialogResult.No:
                            set = false;
                            this.label8.Text = "";
                            this.label9.Text = "";
                            this.label5.Text = "";
                            BookRecord = null;
                            ReaderRecord = null;
                            button2.Enabled = false;
                            button4.Enabled = false;
                            label1.Text = "�������� �������� �������";
                            break;
                        case DialogResult.Cancel:
                            set = false;
                            break;
                    }

                }
                if (set)
                {
                    /*if (ReaderRecord.AbonType == "��� ��������")
                    {
                        MessageBox.Show("� ������� �������� �� ��������� �������� ���� ����������. ������ ����������. ������� ��������� �������� ��� ���������� �� ������� \"�������� ��������\"�", "��������!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }*/
                    if (dbw.GetBookCountForReader(ReaderRecord.id) >= 5)
                    {
                        switch (MessageBox.Show("������ �������� �������� ����� ����� 5 ����. ������ ���������� ������?", "��������!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                        {
                            case DialogResult.No:
                                this.label8.Text = "";
                                this.label9.Text = "";
                                this.label5.Text = "";
                                BookRecord = null;
                                ReaderRecord = null;
                                button2.Enabled = false;
                                button4.Enabled = false;
                                label1.Text = "�������� �������� �������";
                                return;
                            case DialogResult.Yes:
                                dbw.setBookForReader(BookRecord, ReaderRecord, (int)numericUpDown1.Value);
                                dataGridView1.Rows.Insert(0, 1);
                                dataGridView1.Rows[0].Cells[0].Value = BookRecord.inv;
                                dataGridView1.Rows[0].Cells[1].Value = BookRecord.name;
                                BookRecord = new DBWork.dbBook(BookRecord.barcode);
                                dataGridView1.Rows[0].Cells[2].Value = ReaderRecord.FIO;
                                dataGridView1.Rows[0].Cells[3].Value = "������";
                                this.label8.Text = "";
                                this.label9.Text = "";
                                this.label5.Text = "";
                                dbw.InsertActionISSUED(ReaderRecord,BookRecord);
                                BookRecord = null;
                                ReaderRecord = null;
                                button2.Enabled = false;
                                button4.Enabled = false;
                                label1.Text = "�������� �������� �������";
                                break;
                        }

                    }
                    else
                    {
                        dbw.setBookForReader(BookRecord, ReaderRecord, (int)numericUpDown1.Value);
                        dataGridView1.Rows.Insert(0, 1);
                        dataGridView1.Rows[0].Cells[0].Value = BookRecord.inv;
                        dataGridView1.Rows[0].Cells[1].Value = BookRecord.name;
                        BookRecord = new DBWork.dbBook(BookRecord.barcode);
                        dataGridView1.Rows[0].Cells[2].Value = ReaderRecord.FIO;
                        dataGridView1.Rows[0].Cells[3].Value = "������";
                        this.label8.Text = "";
                        this.label9.Text = "";
                        this.label5.Text = "";
                        dbw.InsertActionISSUED(ReaderRecord,BookRecord);
                        BookRecord = null;
                        ReaderRecord = null;
                        button2.Enabled = false;
                        button4.Enabled = false;
                        label1.Text = "�������� �������� �������";
                    }

                }
            }
            BookRecord = null;
            ReaderRecord = null;
        }