private void tsbAddItem_Click(object sender, EventArgs e) { frmAddEditInventory frm = new frmAddEditInventory(); if (frm.ShowDialog(this) == DialogResult.OK) { InventoryItem objItem = frm.item; BSInventoryItem bs = new BSInventoryItem(); Boolean result = false; result = bs.InsertInventoryItem(objItem.ItemName, objItem.CategoryId, objItem.Quantity, objItem.Price, objItem.Available, objItem.Remarks, this.userinfo.EmployeeID); if (result) { MessageBox.Show(VJConstants.MSG_ITEM_SUCCESSFULLY_ADDED, VJConstants.MESSAGEBOX_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Information); LoadInventory(); } else { MessageBox.Show(VJConstants.MSG_ERROR_ENCOUNTERED, VJConstants.MESSAGEBOX_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); } } frm.Dispose(); }
//private void dgvData_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) //{ // for (Int32 i = 0; i < this.dgvData.ColumnCount; i++) // { // if (this.dgvData.Rows[e.RowIndex].Cells[i].ValueType == typeof(Int32)) // { // this.dgvData.Rows[e.RowIndex].Cells[i].Style.Alignment = DataGridViewContentAlignment.MiddleCenter; // } // else if (this.dgvData.Rows[e.RowIndex].Cells[i].ValueType == typeof(decimal)) // { // this.dgvData.Rows[e.RowIndex].Cells[i].Style.Alignment = DataGridViewContentAlignment.MiddleRight; // } // if (this.dgvData.Columns[i].HeaderText.ToUpper() == VJColumnName.CONST_AVAILABLE.ToUpper()) // { // DataGridViewCell cell = this.dgvData.Rows[e.RowIndex].Cells[i]; // DataGridViewCellStyle style = new DataGridViewCellStyle(); // style.Font = new Font(dgvData.Font, FontStyle.Bold); // cell.Style.ApplyStyle(style); // cell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; // if (cell.Value.ToString().ToUpper() == VJConstants.CONST_YES.ToUpper()) // { // cell.Style.ForeColor = Color.Green; // } // else // { // cell.Style.ForeColor = Color.Red; // } // } // } //} private void dgvData_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) { int id = Convert.ToInt32(dgvData.Rows[e.RowIndex].Cells["ItemId"].Value); frmAddEditInventory frm = new frmAddEditInventory(); frm.item.ItemId = id; frm.isEdit = true; frm.ShowDialog(); } else if (e.ColumnIndex == 1 || e.ColumnIndex == 15) { if (MessageBox.Show("Are you wure you want to delete the record?",VJConstants.MESSAGEBOX_TITLE ,MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { int id = Convert.ToInt32(dgvData.Rows[e.RowIndex].Cells["ItemId"].Value); if (DeleteInventoryItem(id)) { util.ShowMessage("Item successfully deleted", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadInventory(); } else { util.ShowMessage("There something wrong while deleting the record", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }