示例#1
0
        public Device_Management_System()
        {
            InitializeComponent();
            label1.Text = Account_n;
            DBHelper db      = new DBHelper();
            string   SqlText = "select * from Admin where Account='" + Account_n + "';";
            DataSet  data    = db.DBselect(SqlText, null);

            if (data.Tables[0].Rows.Count == 0)
            {
                db      = new DBHelper();
                SqlText = "select * from Users where Account='" + Account_n + "';";
                data    = db.DBselect(SqlText, null);
                char Scope = Convert.ToChar(data.Tables[0].Rows[0][2]);
                switch (Scope)
                {
                case 'A':
                    Refresh_SqlText = "select * from Borrow_Device_Input_List where Return_data is NUll union all select * from Borrow_Device_CellPhoneTablet_List where Return_data is NUll";
                    TableArr        = new string [] { "Borrow_Device_Input_List", "Borrow_Device_CellPhoneTablet_List" };
                    break;

                case 'B':
                    Refresh_SqlText = "select * from Borrow_Device_FlashStorage_List where Return_data is NUll union all select * from Borrow_Device_ODD_List where Return_data is NUll union all select * from Device_Others_List where Return_data is NUll";
                    TableArr        = new string[] { "Borrow_Device_FlashStorage_List", "Borrow_Device_ODD_List", "Device_Others_List" };
                    break;

                case 'C':
                    Refresh_SqlText = "select * from Borrow_Device_CardReader_List where Return_data is NUll union all select * from Borrow_Device_HUB_List where Return_data is NUll union all select * from Borrow_Device_Adapter_List where Return_data is NUll union all select * from Borrow_Device_MediaCard_List where Return_data is NUll  union all select * from Borrow_Device_DongleCable_List where Return_data is NUll";
                    TableArr        = new string[] { "Borrow_Device_CardReader_List", "Borrow_Device_HUB_List", "Borrow_Device_Adapter_List", "Borrow_Device_MediaCard_List", "Borrow_Device_DongleCable_List" };
                    break;

                case 'D':
                    Refresh_SqlText = "select * from Borrow_Device_DisplayTV_List where Return_data is NUll";
                    TableArr        = new string[] { "Borrow_Device_DisplayTV_List" };
                    break;

                case 'E':
                    Refresh_SqlText = "select * from Borrow_Device_Audio_List where Return_data is NUll";
                    TableArr        = new string[] { "Borrow_Device_Audio_List" };
                    break;

                case 'F':
                    Refresh_SqlText = "select * from Borrow_Device_PrinterScanner_List where Return_data is NUll union all select * from Borrow_Device_AccessPointStation_List where Return_data is NUll union all select * from Borrow_Device_Switch_List where Return_data is NUll";
                    TableArr        = new string[] { "Borrow_Device_PrinterScanner_List", "Borrow_Device_AccessPointStation_List", "Borrow_Device_Switch_List" };
                    break;
                }
                DGVset.Refresh(this);
                DGVset.Set(this);
            }
            else
            {
                Borrow_button.Enabled       = false;
                Return_button.Enabled       = false;
                Not_Returned_button.Enabled = false;
                Returned_log_button.Enabled = false;
                Add_User_linkLabel.Visible  = true;
            }
        }
示例#2
0
        private void Return_button_Click(object sender, EventArgs e)
        {
            string Identifier      = Identifier_r_textBox.Text;
            string Return_data     = Returen_datatextBox.Text;
            string Into_table_Name = "Log_Borrow_" + Account_n;

            if (Identifier == "" || Return_data == "")
            {
                MessageBox.Show("Identifier and Return_data can not be empty!");
                return;
            }
            string Id_f    = Identifier.Substring(0, 1);
            char   Id_need = Convert.ToChar(Id_f);
            string Table   = "";

            if (Identifier.Substring(0, 2) == "SP")
            {
                Table = "Borrow_Device_Audio_List";
                goto Testc;
            }
            if (Identifier.Substring(0, 2) == "IP")
            {
                Table = "Borrow_Device_CellPhoneTablet_List";
                goto Testc;
            }
            if (Identifier.Substring(0, 2) == "MC")
            {
                Table = "Borrow_Device_MediaCard_List";
                goto Testc;
            }
            if (Identifier.Substring(0, 2) == "CA")
            {
                Table = "Borrow_Device_DongleCable_List";
                goto Testc;
            }
            if (Identifier.Substring(0, 2) == "TV")
            {
                Table = "Borrow_Device_DisplayTV_List";
                goto Testc;
            }
            if (Identifier.Substring(0, 2) == "SW")
            {
                Table = "Borrow_Device_Switch_List";
                goto Testc;
            }
            if (Identifier.Substring(0, 2) == "CD")
            {
                Table = "Borrow_Device_Others_List";
                goto Testc;
            }
            switch (Id_need)
            {
            case 'K':
                Table = "Borrow_Device_Input_List";
                break;

            case 'M':
                Table = "Borrow_Device_Input_List";
                break;

            case 'G':
                Table = "Borrow_Device_Input_List";
                break;

            case 'F':
                Table = "Borrow_Device_FlashStorage_List";
                break;

            case 'S':
                Table = "Borrow_Device_FlashStorage_List";
                break;

            case 'O':
                Table = "Borrow_Device_ODD_List";
                break;

            case 'C':
                Table = "Borrow_Device_CardReader_List";
                break;

            case 'P':
                Table = "Borrow_Device_PrinterScanner_List";
                break;

            case 'H':
                Table = "Borrow_Device_HUB_List";
                break;

            case 'W':
                Table = "Borrow_Device_AccessPointStation_List";
                break;

            case 'A':
                Table = "Borrow_Device_Adapter_List";
                break;

            default:
                Table = "Borrow_Device_Others_List";
                break;
            }
Testc:
            DBHelper db = new DBHelper();
            string  Test_Table = Table.Remove(0, 7);
            string  SqlText    = "select * from " + Test_Table + " where Identifier = '" + Identifier + "'";
            DataSet data       = db.DBselect(SqlText, null);

            if (data.Tables[0].Rows.Count <= 0)
            {
                MessageBox.Show("This device does not exist.", "Prompt", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            db      = new DBHelper();
            SqlText = "select * from " + Table + " where Identifier = '" + Identifier + "'";
            data    = db.DBselect(SqlText, null);
            if (data.Tables[0].Rows.Count <= 0)
            {
                MessageBox.Show("The device has returned or does not exist.", "Prompt", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            db      = new DBHelper();
            SqlText = "update " + Table + " set Return_data=N'" + Return_data + "' where Identifier = N'" + Identifier + "'";
            data    = db.DBselect(SqlText, null);
            SqlText = "insert into " + Into_table_Name + "(Identifier,Borrower,Extension,Date_of_borrowing,Return_data,Remake) select * from " + Table + " where Identifier = '" + Identifier + "'";
            db.DBselect(SqlText, null);
            SqlText = "Delete from " + Table + " where Identifier='" + Identifier + "'";
            db.DBselect(SqlText, null);
            DGVset.Refresh(this);
            DGVset.Set(this);
        }
示例#3
0
        private void Borrow_button_Click(object sender, EventArgs e)
        {
            string Identifier        = Identifier_textBox.Text;
            string Borrower          = Borrower_textBox.Text;
            string Extension         = Extension_textBox.Text;
            string Date_of_borrowing = Date_of_borrowing_textBox.Text;
            string Remake            = Remake_textBox.Text;

            if (Identifier == "" || Borrower == "" || Date_of_borrowing == "")
            {
                MessageBox.Show("Identifier, Borrower, Date_of_borrowing and Return_data can not be empty!", "Prompt", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            string Id_f    = Identifier.Substring(0, 1);
            char   Id_need = Convert.ToChar(Id_f);
            string Table   = "";

            if (Identifier.Substring(0, 2) == "SP")
            {
                Table = "Borrow_Device_Audio_List";
                goto Testc;
            }
            if (Identifier.Substring(0, 2) == "IP")
            {
                Table = "Borrow_Device_CellPhoneTablet_List";
                goto Testc;
            }
            if (Identifier.Substring(0, 2) == "MC")
            {
                Table = "Borrow_Device_MediaCard_List";
                goto Testc;
            }
            if (Identifier.Substring(0, 2) == "CA")
            {
                Table = "Borrow_Device_DongleCable_List";
                goto Testc;
            }
            if (Identifier.Substring(0, 2) == "TV")
            {
                Table = "Borrow_Device_DisplayTV_List";
                goto Testc;
            }
            if (Identifier.Substring(0, 2) == "SW")
            {
                Table = "Borrow_Device_Switch_List";
                goto Testc;
            }
            if (Identifier.Substring(0, 2) == "CD")
            {
                Table = "Borrow_Device_Others_List";
                goto Testc;
            }
            switch (Id_need)
            {
            case 'K':
                Table = "Borrow_Device_Input_List";
                break;

            case 'M':
                Table = "Borrow_Device_Input_List";
                break;

            case 'G':
                Table = "Borrow_Device_Input_List";
                break;

            case 'F':
                Table = "Borrow_Device_FlashStorage_List";
                break;

            case 'S':
                Table = "Borrow_Device_FlashStorage_List";
                break;

            case 'O':
                Table = "Borrow_Device_ODD_List";
                break;

            case 'C':
                Table = "Borrow_Device_CardReader_List";
                break;

            case 'P':
                Table = "Borrow_Device_PrinterScanner_List";
                break;

            case 'H':
                Table = "Borrow_Device_HUB_List";
                break;

            case 'W':
                Table = "Borrow_Device_AccessPointStation_List";
                break;

            case 'A':
                Table = "Borrow_Device_Adapter_List";
                break;

            default:
                Table = "Borrow_Device_Others_List";
                break;
            }
Testc:
            DBHelper db = new DBHelper();
            string  SqlText = "select * from " + Table + " where Identifier = '" + Identifier + "'";
            DataSet data    = db.DBselect(SqlText, null);

            if (data.Tables[0].Rows.Count > 0)
            {
                MessageBox.Show("The device has been borrowed.", "Prompt", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            bool exists = ((IList)TableArr).Contains(Table);

            if (!exists)
            {
                MessageBox.Show("This device does not belong to " + Account_n + " management.", "Prompt", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            db = new DBHelper();
            string Test_Table = Table.Remove(0, 7);

            SqlText = "select * from " + Test_Table + " where Identifier = '" + Identifier + "'";
            data    = db.DBselect(SqlText, null);
            if (data.Tables[0].Rows.Count <= 0)
            {
                MessageBox.Show("This device does not exist.", "Prompt", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //label1.Text = Table;
            db      = new DBHelper();
            SqlText = "insert into " + Table + " values(N\'" + Identifier + "\',N\'" + Borrower + "',N\'" + Extension + "\',N\'" + Date_of_borrowing + "\',null,N\'" + Remake + "')";
            data    = db.DBselect(SqlText, null);
            DGVset.Refresh(this);
            DGVset.Set(this);
        }