Ejemplo n.º 1
0
 private void CarrierInfo_Load(object sender, EventArgs e)
 {
     if (cno != "")
     {
         textBox1.ReadOnly = true;
         this.Text         = "  Edit carrier " + cno;
         Model.Carrier carrier = new Model.Carrier(cno);
         carrier.Fetch();
         textBox1.Text = carrier.CarrierNo;
         textBox2.Text = carrier.CarrierName;
         textBox3.Text = carrier.Country;
     }
 }
Ejemplo n.º 2
0
        // delete rows
        private void button_Delete_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                return;
            }

            // collect ids to delete
            string carrierNos = "(";

            for (int i = 0; i < dataGridView1.SelectedRows.Count; i++)
            {
                carrierNos += "'" + dataGridView1.SelectedRows[i].Cells[0].Value.ToString() + "'";
                if (i != dataGridView1.SelectedRows.Count - 1)
                {
                    carrierNos += ",";
                }
            }
            carrierNos += ")";

            if (MessageBox.Show("Sure to delete carriers whose no. in " + carrierNos + "?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
            {
                return;
            }

            // call the model's delete method
            Model.Carrier carrier = new Model.Carrier();
            if (carrier.Delete(carrierNos))
            {
                Log.Add(Program.user.ID, "Delete carrier " + carrierNos + ".");
                // delete from datagridview
                foreach (DataGridViewRow dataGridView1Row in dataGridView1.SelectedRows)
                {
                    dataGridView1.Rows.Remove(dataGridView1Row);
                }
            }
        }
Ejemplo n.º 3
0
 private void button_Save_Click(object sender, EventArgs e)
 {
     Model.Carrier carrier = new Model.Carrier(
         textBox1.Text, textBox2.Text, textBox3.Text
         );
     if (cno != "")
     {
         if (carrier.Update())
         {
             MessageBox.Show("Successful!", "Information", MessageBoxButtons.OK);
             Log.Add(Program.user.ID, "Update carrier " + cno + ".");
             this.Close();
         }
     }
     else
     {
         if (carrier.Add())
         {
             MessageBox.Show("Successful!", "Information", MessageBoxButtons.OK);
             Log.Add(Program.user.ID, "Add a carrier.");
             this.Close();
         }
     }
 }