コード例 #1
0
        private void button11_Click(object sender, EventArgs e) //set datagrid values to a different type of forms
        {
            if (dataGridView1.ColumnCount <= 0)
            {
                MessageBox.Show("please select the table");
            }

            else if (dataGridView1.Columns[0].HeaderText == "MachineID")
            {
                btn_demo add = new btn_demo();

                add.btnadd.Visible    = false;
                add.btnupdate.Visible = true;

                add.lbl_mach_id.Text      = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                add.cmbtype.Text          = dataGridView1.CurrentRow.Cells[1].Value.ToString();
                add.txtinstall_date.Value = Convert.ToDateTime(dataGridView1.CurrentRow.Cells[2].Value);
                add.txtser_date.Value     = Convert.ToDateTime(dataGridView1.CurrentRow.Cells[3].Value);
                add.txtpur_price.Text     = dataGridView1.CurrentRow.Cells[4].Value.ToString();
                add.cmbpurcom.Text        = dataGridView1.CurrentRow.Cells[5].Value.ToString();
                add.txt_estlife.Text      = dataGridView1.CurrentRow.Cells[6].Value.ToString();



                add.ShowDialog();
            }
            else if (dataGridView1.Columns[0].HeaderText == "PartID")
            {
                parts add = new parts();

                add.btnpart_add.Visible    = false;
                add.btnpart_update.Visible = true;

                add.lbl_part_id.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();

                add.cmbtype.Text      = this.dataGridView1.CurrentRow.Cells[1].Value.ToString();
                add.txtpur_price.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString();
                add.txtqty.Text       = this.dataGridView1.CurrentRow.Cells[3].Value.ToString();
                add.txtins_date.Value = Convert.ToDateTime(dataGridView1.CurrentRow.Cells[4].Value);
                add.cmbpurcom.Text    = this.dataGridView1.CurrentRow.Cells[5].Value.ToString();
                add.ShowDialog();
            }
            else if (dataGridView1.Columns[0].HeaderText == "ServiceNO")
            {
                service up = new service();

                up.btnADD.Visible    = false;
                up.btnupdate.Visible = true;

                up.lbl_service_no.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
                up.txtmach_no.Text     = this.dataGridView1.CurrentRow.Cells[1].Value.ToString();
                up.txtser_date.Value   = Convert.ToDateTime(dataGridView1.CurrentRow.Cells[2].Value);
                up.txtser_per.Text     = this.dataGridView1.CurrentRow.Cells[3].Value.ToString();
                up.txtser_cost.Text    = this.dataGridView1.CurrentRow.Cells[4].Value.ToString();
                up.cmbstation.Text     = this.dataGridView1.CurrentRow.Cells[5].Value.ToString();
                up.ShowDialog();
            }
        }
コード例 #2
0
        private void button9_Click(object sender, EventArgs e) //go to diferent form from the same button considering the heder text
        {
            btn_demo btn = new btn_demo();

            if (dataGridView1.ColumnCount <= 0)
            {
                MessageBox.Show("please select the table");
            }

            else if (dataGridView1.Columns[0].HeaderText == "MachineID")
            {
                btn_demo add = new btn_demo();


                add.Visible = true;
                //this.Visible = false;


                add.btnadd.Visible    = true;
                add.btnupdate.Visible = false;
            }
            else if (dataGridView1.Columns[0].HeaderText == "PartID")
            {
                parts add = new parts();
                add.Visible  = true;
                this.Visible = false;

                add.btnpart_add.Visible    = true;
                add.btnpart_update.Visible = false;
            }
            else if (dataGridView1.Columns[0].HeaderText == "ServiceNO")
            {
                service add = new service();
                add.Visible  = true;
                this.Visible = false;

                add.btnADD.Visible    = true;
                add.btnupdate.Visible = false;
            }
            else if (dataGridView1.Columns[0].HeaderText == "RepaireNO")
            {
                Repaire add = new Repaire();
                add.Visible  = true;
                this.Visible = false;
            }
        }