예제 #1
0
 private void btnAddPost_Click(object sender, EventArgs e)
 {
     mylib ml = new mylib();
     string postname = tbPostName.Text;
     int insertResult = ml.insert("INSERT INTO Posts (post) VALUES ('" + postname + "')");
     this.Close();
 }
예제 #2
0
        private void btnAddRecord_Click(object sender, EventArgs e)
        {
            ArrayList alObjects = new ArrayList();
            mylib ml = new mylib();

            int post, UserID, PhtoID;
            byte[] imageData;

            foreach (DataGridViewRow row in dataGridView1.Rows) {
                if (Convert.ToBoolean(row.Cells[0].Value) == true) {
                    DataGridViewCell cell = row.Cells[2];
                    alObjects.Add(cell.Value.ToString());
                    string val = alObjects[(alObjects.Count - 1)].ToString();
                }
            }

            string cbVal = cbPosts.SelectedValue.ToString();
            string typeSecureVal = typeSecure.SelectedValue.ToString();
            int typeSecureInt = Convert.ToInt32(typeSecureVal);
            //if (cbVal != null) MessageBox.Show(cbVal);
            //else MessageBox.Show("Должность не выбрана.", "Ошибка заполнения формы");
            //if (alObjects.Count == 0)	MessageBox.Show("Ни один объект допуска не выбран", "Ошибка заполнения формы");

             			imageData = File.ReadAllBytes(pictureBox1.ImageLocation);
            post = Convert.ToInt32(cbVal);

            string prns = "'" + tbFirstName.Text + "','" + tbLastName.Text + "','" + tbFatherName.Text + "','" + tbTabelNum.Text + "','" + post + "'";

            UserID = ml.insert("INSERT INTO users (fname,lname,ftname,tabnum,post) VALUES (" + prns + ")", "Yes");
            PhtoID = ml.insert_image(imageData, UserID, "Yes");

            ml.insert("INSERT INTO UsersPosts (postid,userid) VALUES ('" + cbVal + "','" + UserID + "')");

            //string card_column_prns = null;
            string card_values_prns = "'" + UserID + "','" + typeSecureInt + "','" + PhtoID  + "'";

            int CID = ml.insert("INSERT INTO cards (uid,type,photo) VALUES (" + card_values_prns + ")","Yes");

            int i = 1;
            foreach (var obj in alObjects) {
                int objID = Convert.ToInt32(obj);
                ml.insert("INSERT INTO UsersObjects (uid,oid,cid) VALUES ('" + UserID  + "','" + objID + "','" + CID + "')");
                //card_column_prns += ",obj0" + i.ToString();
                //card_values_prns += ",'" + objID.ToString() + "'";
                i++;
            }
        }
예제 #3
0
        private void btnAddObject_Click(object sender, EventArgs e)
        {
            mylib ml = new mylib();

            string objectname = (tbObjectName.Text).ToString();
            ml.insert("Insert into Objects (object) values ('" + objectname + "');");
            this.Close();
        }
예제 #4
0
        private void mainMenuPrintChk_Click(object sender, EventArgs e)
        {
            //listBox1.Items.Clear();
            /*if (listView1.CheckedItems.Count != 0) {
                listchecked();
                if (listView1.CheckedItems.Count != 0) labelResult.Text = ": " + listView1.CheckedItems.Count.ToString();
                else labelResult.Text = ": ";
            } else {labelResult.Text = ": ";}*/

            ArrayList alMembers = new ArrayList();
            ArrayList alPrintSelect = new ArrayList();
            mylib ml = new mylib();

            ml.delete("DELETE FROM PrintTable");
            bool print = false;
            foreach (DataGridViewRow row in dgMembers.Rows) {
                if (Convert.ToBoolean(row.Cells[0].Value) == true) {
                    print = true;
                    DataGridViewCell cell = row.Cells[1];
                    alMembers.Add(cell.Value.ToString());
                    string val = alMembers[(alMembers.Count - 1)].ToString();
                    //MessageBox.Show(val);

                    string cmd1 = "SELECT * FROM cards WHERE uid = '" + val + "'";
                    alPrintSelect = (ArrayList)ml.select(cmd1);
                    if (alPrintSelect.Count != 0) {
                        foreach (object[] myTargetArray in alPrintSelect) {
                            string cid = myTargetArray[0].ToString();
                            string uid = myTargetArray[1].ToString();
                            string tip = myTargetArray[2].ToString();
                            string phid = myTargetArray[3].ToString();
                            ml.insert("INSERT INTO PrintTable (cid,phid,uid,tip) VALUES ('" + cid + "','" + phid + "','" + uid + "','" + tip + "')");
                        }
                    }
                }
            }

            if (print) {
                //report1.Load();
                //report1.RegisterData();

                report1.Show();
            }
        }