private void btnEdit_Click(object sender, EventArgs e) { ComputerPartsEdit cp = new ComputerPartsEdit(); int index = this.gridComputerParts.Rows.IndexOf((GridViewDataRowInfo)this.gridComputerParts.CurrentRow); if (index < 0) { return; } BO.ComputerParts computerParts = (BO.ComputerParts)gridComputerParts.Rows[index].DataBoundItem; if (computerParts != null) { cp.txtPartID.Text = gridComputerParts.CurrentRow.Cells[0].Value.ToString(); cp.txtCase.Text = gridComputerParts.CurrentRow.Cells[1].Value.ToString(); cp.txtMouse.Text = gridComputerParts.CurrentRow.Cells[2].Value.ToString(); cp.txtKeyboard.Text = gridComputerParts.CurrentRow.Cells[3].Value.ToString(); cp.txtHeadSets.Text = gridComputerParts.CurrentRow.Cells[4].Value.ToString(); cp.txtMonitor.Text = gridComputerParts.CurrentRow.Cells[5].Value.ToString(); cp.txtMousePad.Text = gridComputerParts.CurrentRow.Cells[6].Value.ToString(); cp.txtProcessor.Text = gridComputerParts.CurrentRow.Cells[7].Value.ToString(); cp.txtGrahpicCard.Text = gridComputerParts.CurrentRow.Cells[8].Value.ToString(); cp.txtMotherBoard.Text = gridComputerParts.CurrentRow.Cells[9].Value.ToString(); cp.txtRam.Text = gridComputerParts.CurrentRow.Cells[10].Value.ToString(); cp.txtSsd.Text = gridComputerParts.CurrentRow.Cells[11].Value.ToString(); cp.txtHDD.Text = gridComputerParts.CurrentRow.Cells[12].Value.ToString(); cp.txtPsu.Text = gridComputerParts.CurrentRow.Cells[13].Value.ToString(); cp.txtCooler.Text = gridComputerParts.CurrentRow.Cells[14].Value.ToString(); count++; cp.txtUpdateNo.Text = count.ToString(); cp.ShowDialog(); } }
private void btnsave_Click(object sender, EventArgs e) { BO.ComputerParts parts = new BO.ComputerParts(); parts.PartID = int.Parse(txtPartID.Text); parts.ComputerCase = txtCase.Text; parts.ComputerMouse = txtMouse.Text; parts.ComputerKeyboard = txtKeyboard.Text; parts.ComputerHeadSet = txtHeadSets.Text; parts.ComputerMonitor = txtMonitor.Text; parts.ComputerMousePad = txtMousePad.Text; parts.ComputerCPU = txtProcessor.Text; parts.ComputerGraphicCard = txtGrahpicCard.Text; parts.ComputerMotherboard = txtMotherBoard.Text; parts.ComputerRAM = txtRam.Text; parts.ComputerSSD = txtSsd.Text; parts.ComputerHDD = txtHDD.Text; parts.ComputerPSU = txtPsu.Text; parts.ComputerCooler = txtCooler.Text; parts.UpdatedBy = txtUpdateBy.Text; parts.UpdateDate = DateTime.Parse(txtUpdateDate.Text); parts.LastUpdate = int.Parse(txtUpdateNo.Text); var result = computerParts.Modify(parts); if (result != null) { ComputerParts cp = new ComputerParts(); cp.InitData(); this.Close(); } }
private void btnDelete_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Are you sure you wanna delete this? ", "Computer Parts", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { int index = this.gridComputerParts.Rows.IndexOf((GridViewDataRowInfo)this.gridComputerParts.CurrentRow); if (index < 0) { return; } BO.ComputerParts computerparts = (BO.ComputerParts)gridComputerParts.Rows[index].DataBoundItem; if (index != null) { _computerPartsBll.Remove(computerparts.PartID); } } else if (dialogResult == DialogResult.No) { this.Hide(); ManageComputers mg = new ManageComputers(); mg.ShowDialog(); } }
private void ValidateFields() { if (txtSsd.Text == "") { erpSSD.SetError(txtSsd, "This cannot be blank"); } if (txtHDD.Text == "") { erpHDD.SetError(txtHDD, "This cannot be blank"); } if (txtCooler.Text == "") { erpCooler.SetError(txtCooler, "This cannot be blank"); } if (txtGrahpicCard.Text == "") { erpGraphicCard.SetError(txtGrahpicCard, "This cannot be blank"); } if (txtKeyboard.Text == "") { erpKeyboard.SetError(txtKeyboard, "This cannot be blank"); } if (txtHeadSets.Text == "") { erpHeadSets.SetError(txtHeadSets, "This cannot be blank"); } if (txtMonitor.Text == "") { erpMonitor.SetError(txtMonitor, "This cannot be blank"); } if (txtMousePad.Text == "") { erpMousePad.SetError(txtMousePad, "This cannot be blank"); } if (txtMouse.Text == "") { erpMouse.SetError(txtMouse, "This cannot be blank"); } //if (txtPricePerHOur.Text == "") //{ // erpPricePerhour.SetError(txtPricePerHOur,"This cannot be blank"); //} if (txtPsu.Text == "") { erpPSU.SetError(txtPsu, "This cannot be blank"); } if (txtRam.Text == "") { erpRam.SetError(txtRam, "This cannot be blank"); } if (txtMotherBoard.Text == "") { erpMotherBoard.SetError(txtMotherBoard, "This cannot be blank"); } if (txtProcessor.Text == "") { erpProcessor.SetError(txtProcessor, "This cannot be blank"); } if (txtCase.Text == "") { erpCase.SetError(txtCase, "This cannot be blank"); } else { BO.ComputerParts computerParts = new BO.ComputerParts(); computerParts.ComputerSSD = txtSsd.Text; computerParts.ComputerHeadSet = txtHeadSets.Text; computerParts.ComputerCPU = txtProcessor.Text; computerParts.ComputerMonitor = txtMonitor.Text; computerParts.ComputerGraphicCard = txtGrahpicCard.Text; computerParts.ComputerMouse = txtMouse.Text; computerParts.ComputerMousePad = txtMousePad.Text; computerParts.ComputerRAM = txtRam.Text; computerParts.ComputerCase = txtCase.Text; computerParts.ComputerHDD = txtHDD.Text; computerParts.ComputerKeyboard = txtKeyboard.Text; computerParts.ComputerPSU = txtPsu.Text; computerParts.ComputerCooler = txtCooler.Text; computerParts.ComputerCase = txtCase.Text; computerParts.ComputerMotherboard = txtMotherBoard.Text; computerParts.Insertby = txtInsertBy.Text; computerParts.InserDate = DateTime.Parse(txtInsertDate.Text); _computerPartsBll.ADD(computerParts); ComputerParts computerPartss = new ComputerParts(); computerPartss.InitData(); this.Close(); } }