private void btnAdd_Click(object sender, EventArgs e) { orderGenerateId(); Purchase_Order purchaseorder = new Purchase_Order(this, CommonConstant.DB_INSERT); purchaseorder.txtOrderNo.Text = orderID; purchaseorder.Show(); }
private void orderviewDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { int i; i = orderviewDataGridView.CurrentRow.Index; if (orderviewDataGridView.Rows[i].Cells[3].Value.ToString() == "Progress") { Purchase_Order purchaseorder = new Purchase_Order(this, CommonConstant.DB_UPDATE); String Orderid = orderviewDataGridView.Rows[i].Cells[0].Value.ToString(); purchaseorder.cbPublisher.Text = orderviewDataGridView.Rows[i].Cells[2].Value.ToString(); String strODT = "SELECT OD.BOOK_ID,B.BK_TITLE,B.BK_PURCHASE_PRICE,OD.QUANTITY FROM ORDER_DETAIL OD INNER JOIN BOOK B ON OD.BOOK_ID =B.BOOK_ID WHERE ORDER_ID = '" + Orderid + "'"; connection(); SqlDataAdapter ODTad = new SqlDataAdapter(strODT, consql); DataSet ODTds = new DataSet(); ODTad.Fill(ODTds, "OrderDT"); DataTable ODTtable; ODTtable = ODTds.Tables["OrderDT"]; int totamt = 0; for (int j = 0; j < ODTtable.Rows.Count; j++) { ListViewItem odtlistviewitem = new ListViewItem(ODTtable.Rows[j].ItemArray[0].ToString()); for (int k = 1; k < ODTtable.Columns.Count; k++) { odtlistviewitem.SubItems.Add(ODTtable.Rows[j].ItemArray[k].ToString()); } int Amount = (int.Parse(ODTtable.Rows[j].ItemArray[2].ToString())) * (int.Parse(ODTtable.Rows[j].ItemArray[3].ToString())); totamt += Amount; odtlistviewitem.SubItems.Add(Amount.ToString()); purchaseorder.purorderList.Items.Add(odtlistviewitem); } purchaseorder.pubid = orderviewDataGridView.Rows[i].Cells[1].Value.ToString(); purchaseorder.txtTotalAmount.Text = totamt.ToString(); purchaseorder.bookname = ODTtable.Rows[0].ItemArray[1].ToString(); purchaseorder.txtQty.Text = ODTtable.Rows[0].ItemArray[3].ToString(); purchaseorder.txtOrderNo.Text = orderviewDataGridView.Rows[i].Cells[0].Value.ToString(); purchaseorder.Show(); } else { MessageBox.Show("This Order is not on Progress."); } }