Пример #1
0
        public void loadRepairs()
        {
            clsDBRepair      dbRepair = new clsDBRepair();
            List <clsRepair> repairs  = dbRepair.RepairList();

            Int32 Index = 0;

            lstRepairJobs.Items.Clear();
            while (Index < repairs.Count)
            {
                clsRepair    repair  = repairs[Index];
                ListViewItem NewItem = new ListViewItem();
                NewItem.Text = repair.CustomerName;
                NewItem.SubItems.Add(repair.PhoneModel);
                NewItem.SubItems.Add(repair.SerialNo_IMEI);
                NewItem.SubItems.Add(repair.Fault);
                NewItem.SubItems.Add("£" + repair.Balance.ToString("F"));
                NewItem.SubItems.Add(repair.CollectionDate.ToShortDateString());


                NewItem.Tag = repair;
                lstRepairJobs.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                lstRepairJobs.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                lstRepairJobs.Items.Add(NewItem); //Add the item to ListView


                Index++; //move the index to the next record
            }
        }
Пример #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (isValid())
            {
                clsRepair repair = new clsRepair();
                repair.CustomerName    = txtCustomerName.Text;
                repair.CustomerPhoneNo = txtCustomerPhoneNo.Text;
                repair.Date            = dateTime.Value;
                clsDevice clsDevice = (clsDevice)cmbPhoneModel.SelectedItem;
                if (clsDevice != null)
                {
                    repair.PhoneModel = clsDevice.Model.ToString();
                }
                repair.SerialNo_IMEI  = txtSerialNo_IMEI.Text;
                repair.Fault          = txtFault.Text;
                repair.Password       = txtPassword.Text;
                repair.Cost           = Convert.ToDecimal(txtCost.Text);
                repair.Deposit        = Convert.ToDecimal(txtDeposit.Text);
                repair.Balance        = Convert.ToDecimal(txtBalance.Text);
                repair.CollectionDate = dateTimePicker1.Value;
                repair.Comment        = txtComment.Text;

                clsDBRepair fbs   = new clsDBRepair();
                Int32       added = 0;
                if (txtID.Text.Length > 0)
                {
                    repair.ID = Convert.ToInt32(txtID.Text);
                    added     = fbs.UpdateRepair(repair);
                }
                else
                {
                    added = fbs.InsertRepair(repair);
                }

                if (added > 0)
                {
                    frmListRepair.loadRepairs();
                    Close();
                }
                else
                {
                    txtErrorMessage.Text    = "Could not added Repair.";
                    txtErrorMessage.Visible = true;
                }
            }
            else
            {
                txtErrorMessage.Text    = "Specify valid values";
                txtErrorMessage.Visible = true;
            }
        }
Пример #3
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (lstRepairJobs.SelectedItems.Count > 0)
     {
         ListViewItem selectedItem = lstRepairJobs.SelectedItems[0];
         clsRepair    repair       = (clsRepair)selectedItem.Tag;
         // Display a message box asking users if they
         // want to delete the selected Repair.
         if (MessageBox.Show("Are you sure to Delete this RepairJob", "Delete Repair",
                             MessageBoxButtons.YesNo, MessageBoxIcon.Question)
             == DialogResult.Yes)
         {
             // code for deleting the record goes here
             clsDBRepair dbRepair = new clsDBRepair();
             dbRepair.DeleteRepair(repair.ID);
             loadRepairs();
         }
     }
 }