Пример #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;
            }
        }
Пример #3
0
        public bool updateservice(string seno, string date, string machno, string serper, string sercost, string serstat)
        {
            bool status = false;

            if (conn.State.ToString() == "Closed")
            {
                conn.Open();
            }
            SqlCommand newCmd3 = conn.CreateCommand();
            btn_demo   md      = new btn_demo();

            newCmd3.Connection  = conn;
            newCmd3.CommandType = CommandType.Text;
            newCmd3.CommandText = "update MachineServices set  ServiceDate='" + date + "',MachineID='" + machno + "',ServiceTimePeriod='" + serper + "',Cost='" + sercost + "',ServiceStation='" + serstat + "' where ServiceNO='" + seno + "' ;";

            newCmd3.ExecuteNonQuery();

            status = true;

            return(status);
        }
Пример #4
0
        public bool updateparts(string id, string type, string purprice, int qty, string indate, string purcom, string purdate)
        {
            bool status = false;

            if (conn.State.ToString() == "Closed")
            {
                conn.Open();
            }
            SqlCommand newCmd3 = conn.CreateCommand();
            btn_demo   md      = new btn_demo();

            newCmd3.Connection  = conn;
            newCmd3.CommandType = CommandType.Text;
            newCmd3.CommandText = "update Part set  Type='" + type + "',PurchasePrice='" + purprice + "',Quantity='" + qty + "',InstallDate='" + indate + "',PurchaseCompany='" + purcom + "',PurchaseDate='" + purdate + "' where PartID='" + id + "' ;";

            newCmd3.ExecuteNonQuery();

            status = true;

            return(status);
        }
Пример #5
0
        public bool updatemachine(string mid, string type, string insdate, string serdate, string purprice, string purcom, int life)
        {
            bool status = false;

            if (conn.State.ToString() == "Closed")
            {
                conn.Open();
            }
            SqlCommand newCmd3 = conn.CreateCommand();
            btn_demo   md      = new btn_demo();

            newCmd3.Connection  = conn;
            newCmd3.CommandType = CommandType.Text;
            newCmd3.CommandText = "update Machines set Type='" + type + "',InstallDate='" + insdate + "',ServiceDate='" + serdate + "',PurchasePrice='" + purprice + "',PurchaseCompany='" + purcom + "',EstimatedLife='" + life + "' where  MachineID='" + mid + "';";


            newCmd3.ExecuteNonQuery();

            status = true;

            return(status);
        }