Exemplo n.º 1
0
        public List <clsDevice> DeviceList()
        {
            //create an array list of type lstDevices
            List <clsDevice> lstDevices = new List <clsDevice>();
            //var to store the count of records
            Int32 RecordCount;
            //var to store the index for the loop
            Int32 Index = 0;

            //get the count of records
            db.Execute("sproc_tblDevice_SelectAll");

            RecordCount = db.Count;
            //keep looking till all records are processed
            while (Index < RecordCount)
            {
                //create a blank device
                clsDevice device = new clsDevice();
                //copy the data from the table to the RAM
                device.ID          = Convert.ToInt32(db.DataTable.Rows[Index]["DeviceID"]);
                device.Manufacture = Convert.ToString(db.DataTable.Rows[Index]["Manufacture"]);
                device.Model       = Convert.ToString(db.DataTable.Rows[Index]["Model"]);
                //add the blank page to the array list
                lstDevices.Add(device);
                //increase the index
                Index++;
            }
            //return the list as the return value of the function
            return(lstDevices);
        }
Exemplo n.º 2
0
 public Int32 InsertDevice(clsDevice device)
 {
     //add the parameters
     db.AddParameter("@Manufacture", device.Manufacture);
     db.AddParameter("@Model", device.Model);
     //execute the stored procedure returning the primary key value of the new record
     return(db.Execute("sproc_tblDevice_Insert"));
 }
Exemplo n.º 3
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (lstDevices.SelectedItems.Count > 0)
            {
                ListViewItem selectedItem = lstDevices.SelectedItems[0];
                clsDevice    device       = (clsDevice)selectedItem.Tag;

                frmAddDevice showForm = new frmAddDevice(this, device);
                showForm.Show();
            }
        }
Exemplo n.º 4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (isValid())
            {
                clsProductRecord productRecord = new clsProductRecord();
                productRecord.SerialNo_IMEI = txtSerialNo_IMEI.Text;
                clsDevice clsDevice = (clsDevice)cmbDeviceName.SelectedItem;
                if (clsDevice != null)
                {
                    productRecord.DeviceId = clsDevice.ID;
                }

                clsSupplier clsSupplier = (clsSupplier)cmbSupplierName.SelectedItem;
                if (clsSupplier != null)
                {
                    productRecord.SupplierId = clsSupplier.ID;
                }

                productRecord.Price       = Convert.ToDecimal(txtPrice.Text);
                productRecord.DateBought  = dateTimePicker1.Value;
                productRecord.Description = txtDescription.Text;
                productRecord.Status      = txtStatus.Text;
                productRecord.Returned    = chkReturned.Checked;

                clsDBProductRecord fbs = new clsDBProductRecord();
                Int32 added            = 0;
                if (txtID.Text.Length > 0)
                {
                    productRecord.ID = Convert.ToInt32(txtID.Text);
                    added            = fbs.UpdateProductRecord(productRecord);
                }
                else
                {
                    added = fbs.InsertProductRecord(productRecord);
                }

                if (added > 0)
                {
                    frmListProductRecord.loadProductRecords();
                    Close();
                }
                else
                {
                    txtErrorMessage.Text    = "Could not added ProductRecord.";
                    txtErrorMessage.Visible = true;
                }
            }
            else
            {
                txtErrorMessage.Text    = "Specify valid values";
                txtErrorMessage.Visible = true;
            }
        }
Exemplo n.º 5
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;
            }
        }
Exemplo n.º 6
0
        public frmAddDevice(frmDevices frmSup, clsDevice device)
        {
            InitializeComponent();
            frmDevices = frmSup;

            if (device != null)
            {
                txtID.Text          = Convert.ToString(device.ID);
                txtManufacture.Text = device.Manufacture;
                txtModel.Text       = device.Model;

                btnAdd.Text = "Edit";
            }
        }
Exemplo n.º 7
0
        public void loadDevices(clsRepair repair)
        {
            clsDBDevice      dbDevice = new clsDBDevice();
            List <clsDevice> devices  = dbDevice.DeviceList();

            Int32 Index = 0;

            cmbPhoneModel.DisplayMember = "Model";
            cmbPhoneModel.ValueMember   = "ID";
            while (Index < devices.Count)
            {
                clsDevice device = devices[Index];
                cmbPhoneModel.Items.Add(device);
                if (repair != null && (repair.PhoneModel == device.Model.ToString()))
                {
                    cmbPhoneModel.SelectedItem = device;
                }
                Index++;   //move the index to the next record
            }
        }
Exemplo n.º 8
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            if (lstDevices.SelectedItems.Count > 0)
            {
                ListViewItem selectedItem = lstDevices.SelectedItems[0];
                clsDevice    device       = (clsDevice)selectedItem.Tag;

                // Display a message box asking users if they
                // want to delete the selected Device.
                if (MessageBox.Show("Are you sure to Delete this Device " + device.Model + "?", "Delete Device",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                    == DialogResult.Yes)
                {
                    // code for deleting the record goes here
                    clsDBDevice dbDevice = new clsDBDevice();
                    dbDevice.DeleteDevice(device.ID);
                    loadDevices();
                }
            }
        }
Exemplo n.º 9
0
        public void loadDevices(clsProductRecord productRecord)
        {
            clsDBDevice      dbDevice = new clsDBDevice();
            List <clsDevice> devices  = dbDevice.DeviceList();

            Int32 Index = 0;

            cmbDeviceName.DisplayMember = "Model";
            cmbDeviceName.ValueMember   = "ID";
            while (Index < devices.Count)
            {
                clsDevice device = devices[Index];
                cmbDeviceName.Items.Add(device);
                if (productRecord != null && (productRecord.DeviceId == device.ID))
                {
                    cmbDeviceName.SelectedItem = device;
                }


                Index++; //move the index to the next record
            }
        }
Exemplo n.º 10
0
        public void loadDevices()
        {
            clsDBDevice      dbDevice = new clsDBDevice();
            List <clsDevice> devices  = dbDevice.DeviceList();

            Int32 Index = 0;

            lstDevices.Items.Clear();
            while (Index < devices.Count)
            {
                clsDevice    device  = devices[Index];
                ListViewItem NewItem = new ListViewItem();
                NewItem.Text = device.Manufacture;
                NewItem.SubItems.Add(device.Model);

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

                Index++;                       //move the index to the next record
            }
        }
Exemplo n.º 11
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (isValid())
            {
                clsDevice device = new clsDevice();
                device.Manufacture = txtManufacture.Text;
                device.Model       = txtModel.Text;

                clsDBDevice fbs   = new clsDBDevice();
                Int32       added = 0;
                if (txtID.Text.Length > 0)
                {
                    device.ID = Convert.ToInt32(txtID.Text);
                    added     = fbs.UpdateDevice(device);
                }
                else
                {
                    added = fbs.InsertDevice(device);
                }

                if (added > 0)
                {
                    frmDevices.loadDevices();
                    Close();
                }
                else
                {
                    txtErrorMessage.Text    = "Could not added Device.";
                    txtErrorMessage.Visible = true;
                }
            }
            else
            {
                txtErrorMessage.Text    = "Specify valid values";
                txtErrorMessage.Visible = true;
            }
        }