private void searchItmCategorynameBtn_Click(object sender, EventArgs e) { ItemDAO itemsDAORef = new ItemDAOImpl(); Items itemsRef = new Items(); Category c = new Category(); c.categoryName = ItmcategorynameTxt.Text; itemsRef.category = c; itemsRef.itemName = null; List <string> listNm = new List <string>(); listNm.Add("Item Name"); listNm.Add("Category Name"); listNm.Add("Item Desciption"); listNm.Add("Item Type"); listNm.Add("Stock"); listNm.Add("Unit Price"); List <ArrayList> itemList = new List <ArrayList>(); itemList = itemsDAORef.getItemsListSample(itemsRef); dataGridViewItems.DataSource = CreateDataTable(listNm, itemList); // dataGridViewItems.SelectedCells[0].ReadOnly = true; dataGridViewItems.Columns[0].ReadOnly = true; dataGridViewItems.Columns[1].ReadOnly = true; dataGridViewItems.Columns[2].ReadOnly = false; dataGridViewItems.Columns[3].ReadOnly = false; dataGridViewItems.Columns[4].ReadOnly = false; dataGridViewItems.Columns[5].ReadOnly = false; }
private void findAllBtn_Click(object sender, EventArgs e) { ItemDAO itemsDAORef = new ItemDAOImpl(); // List<Items> itemList = new List<Items>(); // itemList = itemsDAORef.getItemsList(null); List <string> listNm = new List <string>(); listNm.Add("Item Name"); listNm.Add("Category Name"); listNm.Add("Item Desciption"); listNm.Add("Item Type"); listNm.Add("Stock"); listNm.Add("Unit Price "); //List<List<string>> itemList = new List<List<string>>(); List <ArrayList> itemList = new List <ArrayList>(); itemList = itemsDAORef.getItemsListSample(null); dataGridViewItems.DataSource = CreateDataTable(listNm, itemList); // dataGridView1.DataBindings() dataGridViewItems.Columns[0].ReadOnly = true; dataGridViewItems.Columns[1].ReadOnly = true; dataGridViewItems.Columns[2].ReadOnly = false; dataGridViewItems.Columns[3].ReadOnly = false; dataGridViewItems.Columns[4].ReadOnly = false; dataGridViewItems.Columns[5].ReadOnly = false; deleteBtn.Visible = true; }
private void dataGridViewItems_CellValueChanged(object sender, DataGridViewCellEventArgs e) { Console.WriteLine("\n++++++++++ cell changed+++++++++++++++++\n"); var row = dataGridViewItems.Rows[e.RowIndex]; var col = dataGridViewItems.Columns[e.ColumnIndex]; var changedValue = (string)row.Cells[e.ColumnIndex].Value; Console.WriteLine("************row index:{0}\t col: {1}", e.RowIndex, e.ColumnIndex); Console.WriteLine(" *******************************Row value :{0} \n", row.Cells["Item Desciption"].Value); Console.WriteLine(" ^^^^^^^^^^^^^^^^^^Row value :{0} \n", Convert.ToString(row.Cells["Item Desciption"].Value)); Items itemRef = new Items(); itemRef.itemName = Convert.ToString(row.Cells["Item Name"].Value);; if (e.ColumnIndex == 2) { itemRef.description = changedValue; itemRef.unitprice = Convert.ToDouble(row.Cells[5].Value);; itemRef.itemType = Convert.ToString(row.Cells["Item Type"].Value);; itemRef.stock = Convert.ToInt16(row.Cells["Stock"].Value); Console.WriteLine("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\ndescription={0}\t item type:{1}", itemRef.description, itemRef.itemType); } else if (e.ColumnIndex == 3) { itemRef.itemType = changedValue; itemRef.description = Convert.ToString(row.Cells["Item Desciption"].Value); itemRef.unitprice = Convert.ToDouble(row.Cells[5].Value); itemRef.stock = Convert.ToInt32(row.Cells["Stock"].Value); } else if (e.ColumnIndex == 4) { itemRef.stock = int.Parse(changedValue); itemRef.itemType = Convert.ToString(row.Cells["Item Type"].Value);; itemRef.description = Convert.ToString(row.Cells["Item Desciption"].Value); itemRef.unitprice = Convert.ToDouble(row.Cells[5].Value);; } else if (e.ColumnIndex == 5) { itemRef.unitprice = double.Parse(changedValue); itemRef.itemType = Convert.ToString(row.Cells["Item Type"].Value);; itemRef.description = Convert.ToString(row.Cells["Item Desciption"].Value); itemRef.stock = Convert.ToInt32(row.Cells["Stock"].Value); } //listNm.Add("Item Desciption"); //listNm.Add("Item Type"); ItemDAO itemDAORef = new ItemDAOImpl(); itemDAORef.updateItems(itemRef); dataGridViewItems.Update(); dataGridViewItems.Refresh(); }
private void deleteBtn_Click(object sender, EventArgs e) { int rowIndex = dataGridViewItems.CurrentCell.RowIndex; var row = dataGridViewItems.Rows[rowIndex]; var changedValue = (string)row.Cells[rowIndex].Value; Console.WriteLine("$$$$$$$$$$$$$$$$$ values:{0}", (string)row.Cells[rowIndex].Value); // dataGridViewTest.Rows.RemoveAt(rowIndex); Items itemsRef1 = new Items(); itemsRef1.itemName = Convert.ToString(row.Cells["Item Name"].Value); // itemsRef1.categoryDesc = changedValue; ItemDAO categoryDAORef = new ItemDAOImpl(); categoryDAORef.deleteItems(itemsRef1); dataGridViewItems.Update(); dataGridViewItems.Refresh(); }
private void addItemSubmitbtn_Click(object sender, EventArgs e) { if (itemNameTxt.Text == "" || itemDescTxt.Text == "" || categoryTxt.Text == "" || stockTxt.Text == "" || unitPriceTxt.Text == "") { MessageBox.Show("enter all the values", "error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { ItemDAO itemsDAORef = new ItemDAOImpl(); Items itemsRef = new Items(); Category cRef = new Category(); itemsRef.itemName = itemNameTxt.Text; itemsRef.description = itemDescTxt.Text; cRef.categoryName = categoryTxt.Text; itemsRef.stock = int.Parse(stockTxt.Text); itemsRef.unitprice = float.Parse(unitPriceTxt.Text); itemsRef.category = cRef; bool isChecked = vegRadioBtn.Checked; bool ischeckednonVeg = nonVegRadioBtn.Checked; if (isChecked) { itemsRef.itemType = "Veg"; } else if (ischeckednonVeg) { itemsRef.itemType = "non-Veg"; } else { MessageBox.Show("please mention the type"); } itemsDAORef.inseritems(itemsRef); clearFeilds(); } }
private void searchBtn_Click(object sender, EventArgs e) { if (flagForSearch > 0 && flagForReset == 0) { Console.WriteLine("search called :{0}", flagForSearch); clear(); } ItemDAO itemsDAORef = new ItemDAOImpl(); Items itemsRef = new Items(); Category c = new Category(); c.categoryName = categorynameCmb.Text; itemsRef.category = c; itemsRef.itemName = null; List <string> listNm = new List <string>(); listNm.Add("Item Name"); listNm.Add("Category Name"); listNm.Add("Item Desciption"); listNm.Add("Item Type"); listNm.Add("Quantity"); listNm.Add("Price"); List <ArrayList> itemList = new List <ArrayList>(); dataGridViewItemsList.ColumnHeadersVisible = true; itemList = itemsDAORef.getItemsListSample(itemsRef); dataGridViewItemsList.DataSource = CreateDataTable(listNm, itemList); for (int i = 0; i < itemList.Count; i++) { double d = Convert.ToDouble(itemList[i][5]); price.Add(d); } for (int i = 0; i < price.Count; i++) { Console.WriteLine("p[{0}]={1}", i, price[i]); } // dataGridViewItemsList.SelectedCells[0].ReadOnly = true; //dataGridViewItemsList.Columns[0].ReadOnly = true; //dataGridViewItemsList.Columns[1].ReadOnly = true; //dataGridViewItemsList.Columns[2].ReadOnly = false; //dataGridViewItemsList.Columns[3].ReadOnly = false; //dataGridViewItemsList.Columns[4].ReadOnly = false; //dataGridViewItemsList.Columns[5].ReadOnly = false; // flag is used to ensure that the following buttons are added only once even if the search button pressed for number of times. if (flag == 0) { DataGridViewButtonColumn col1 = new DataGridViewButtonColumn(); col1.UseColumnTextForButtonValue = true; col1.Text = "+"; col1.Name = "+"; dataGridViewItemsList.Columns.Add(col1); DataGridViewButtonColumn col2 = new DataGridViewButtonColumn(); col2.UseColumnTextForButtonValue = true; col2.Text = "-"; col2.Name = "-"; dataGridViewItemsList.Columns.Add(col2); DataGridViewButtonColumn col = new DataGridViewButtonColumn(); col.UseColumnTextForButtonValue = true; col.Text = "Add to Cart"; col.Name = "Add to Cart"; dataGridViewItemsList.Columns.Add(col); dataGridViewItemsList.Columns[6].Width = 20; dataGridViewItemsList.Columns[7].Width = 20; dataGridViewItemsList.Columns[8].Width = 120; flag++; } //else { //// to make the column to fixed to right corner position .changing the display index value will shuffle position of the column in between the other columns //dataGridViewItemsList.Columns["Item Name"].DisplayIndex = 0; //dataGridViewItemsList.Columns["Category Name"].DisplayIndex = 1; //dataGridViewItemsList.Columns["Item Desciption"].DisplayIndex = 2; //dataGridViewItemsList.Columns["Item Type"].DisplayIndex = 3; //dataGridViewItemsList.Columns["Quantity"].DisplayIndex = 4; //dataGridViewItemsList.Columns["Price"].DisplayIndex = 5; //dataGridViewItemsList.Columns["+"].DisplayIndex = 6; //dataGridViewItemsList.Columns["-"].DisplayIndex = 7; //dataGridViewItemsList.Columns["Add to Cart"].DisplayIndex = 8; } flagForSearch++; }