コード例 #1
0
        private void btnContactModify_Click(object sender, EventArgs e)
        {
            if ((dataGridVendors.CurrentRow == null) || (dataGridContacts.CurrentRow == null))
            {
                return;
            }

            ContactAdd frmContactModify = new ContactAdd();

            frmContactModify.Text               = btnContactModify.Text;
            frmContactModify.btnSave.Text       = "수 정";
            frmContactModify.ckBoxIsUse.Enabled = true;

            int curVendorRow = dataGridVendors.CurrentRow.Index;
            int curRow       = dataGridContacts.CurrentRow.Index;

            //frmContactModify.txtBoxVendorName.Text = dataGridVendors[5, curVendorRow].Value.ToString();
            frmContactModify.ckBoxIsUse.Checked = (Convert.ToBoolean(dataGridContacts[1, curRow].Value)) ? true : false;
            frmContactModify.txtBoxName.Text    = dataGridContacts["성명", curRow].Value.ToString();
            frmContactModify.txtBoxTitle.Text   = dataGridContacts["직책", curRow].Value.ToString();
            frmContactModify.txtBoxTel.Text     = dataGridContacts["Tel.", curRow].Value.ToString();
            frmContactModify.txtBoxCell.Text    = dataGridContacts["Mobile.", curRow].Value.ToString();
            frmContactModify.txtBoxFax.Text     = dataGridContacts["Fax.", curRow].Value.ToString();
            frmContactModify.txtBoxEmail.Text   = dataGridContacts["Email", curRow].Value.ToString();

            if (frmContactModify.ShowDialog() == DialogResult.OK)
            {
                ((MainForm)MdiParent).dbCtrl.SendQuery("UPDATE [Contacts] SET " +
                                                       "[ContactModifyDate] = GETDATE() " +
                                                       ",[ContactName] = '" + frmContactModify.txtBoxName.Text + "'" +
                                                       ",[ContactTitle] = '" + frmContactModify.txtBoxTitle.Text + "'" +
                                                       ",[ContactTel] = '" + frmContactModify.txtBoxTel.Text + "'" +
                                                       ",[ContactCell] = '" + frmContactModify.txtBoxCell.Text + "'" +
                                                       ",[ContactFax] = '" + frmContactModify.txtBoxFax.Text + "'" +
                                                       ",[ContactMail] = '" + frmContactModify.txtBoxEmail.Text + "'" +
                                                       ",[ContactIsUse] = " + ((frmContactModify.ckBoxIsUse.Checked) ? 1 : 0).ToString() + " " +
                                                       "WHERE [ContactID] = " + dataGridContacts[0, curRow].Value.ToString());

                LoadContactTable(Convert.ToInt16(dataGridVendors[0, curVendorRow].Value));
            }
        }
コード例 #2
0
        private void btnContactAdd_Click(object sender, EventArgs e)
        {
            if (dataGridVendors.CurrentRow == null)
            {
                return;
            }

            ContactAdd frmContactAdd = new ContactAdd();

            frmContactAdd.Text               = btnContactAdd.Text;
            frmContactAdd.btnSave.Text       = "저 장";
            frmContactAdd.ckBoxIsUse.Enabled = false;

            int curVendorRow = dataGridVendors.CurrentRow.Index;

            //frmContactAdd.txtBoxVendorName.Text = dataGridVendors[5, curVendorRow].Value.ToString();

            if (frmContactAdd.ShowDialog() == DialogResult.OK)
            {
                ((MainForm)MdiParent).dbCtrl.SendQuery("INSERT INTO [Contacts] (" +
                                                       "[ContactVendorID] " +
                                                       ",[ContactName] " +
                                                       ",[ContactTitle] " +
                                                       ",[ContactTel] " +
                                                       ",[ContactCell] " +
                                                       ",[ContactFax] " +
                                                       ",[ContactMail]) VALUES ( " +
                                                       dataGridVendors[0, curVendorRow].Value.ToString() + "," +
                                                       "'" + frmContactAdd.txtBoxName.Text + "'," +
                                                       "'" + frmContactAdd.txtBoxTitle.Text + "'," +
                                                       "'" + frmContactAdd.txtBoxTel.Text + "'," +
                                                       "'" + frmContactAdd.txtBoxCell.Text + "'," +
                                                       "'" + frmContactAdd.txtBoxFax.Text + "'," +
                                                       "'" + frmContactAdd.txtBoxEmail.Text + "'" +
                                                       " )");

                LoadContactTable(Convert.ToInt16(dataGridVendors[0, curVendorRow].Value));
            }
        }