public Stock_Update(StockReturn form, int pid, int sid) { InitializeComponent(); this.Resizable = false; this.Movable = false; this.TopMost = true;; this.MaximizeBox = false; this.ControlBox = false; stock_id = sid; gForm = form; ProdID = pid; inititalis(); txtAdjustedQuantity.Enabled = false; }
private void tblProduct_CellClick(object sender, DataGridViewCellEventArgs e) { try { int rw = e.RowIndex; int cl = e.ColumnIndex; if (cl == 6) { foreach (Form form in Application.OpenForms) { if (form.GetType().Name == "StockReturn") { MetroMessageBox.Show(this, "Form is already opened", "System Message!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); return; } } if (Convert.ToString(tblProduct.Rows[rw].Cells[0].Value) == string.Empty) { MessageBox.Show("No Stock data found"); return; } int sid = Convert.ToInt32(tblProduct.Rows[rw].Cells[0].Value.ToString()); //getting relevant product list of the selected stock stock_product stpr = new stock_product(); stpr.stock_id = sid; stock_product_list = stpr.Get_stock_by_sid(con); if (stock_product_list.Count == 0) { MetroMessageBox.Show(this, "No products were found for this purchase data ", "System Message!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); return; } foreach (var productlist in ProductList) { foreach (var PSlist in stock_product_list) { if (productlist.ID == PSlist.pid) { PSlist.p_name = productlist.name; } } } //MessageBox.Show(sid.ToString()); using (StockReturn sr = new StockReturn(this, sid)) { sr.ShowDialog(); } } else if (cl == 5) { if (Convert.ToString(tblProduct.Rows[rw].Cells[0].Value) == string.Empty) { MessageBox.Show("No Stock data found"); return; } if (Convert.ToString(tblProduct.Rows[rw].Cells[0].Value) != string.Empty) { txtStockID.Text = tblProduct.Rows[rw].Cells[0].Value.ToString(); } if (Convert.ToString(tblProduct.Rows[rw].Cells[2].Value) != string.Empty) { txtSupName.Text = tblProduct.Rows[rw].Cells[2].Value.ToString(); } if (Convert.ToString(tblProduct.Rows[rw].Cells[1].Value) != string.Empty) { txtInvoiceNo.Text = tblProduct.Rows[rw].Cells[1].Value.ToString(); } if (Convert.ToString(tblProduct.Rows[rw].Cells[3].Value) != string.Empty) { cmbDate.Text = tblProduct.Rows[rw].Cells[3].Value.ToString(); } enableContent(); } else if (cl == 2) { if (Convert.ToString(tblProduct.Rows[rw].Cells[0].Value) == string.Empty) { MessageBox.Show("No Stock data found"); return; } foreach (Form form in Application.OpenForms) { if (form.GetType().Name == "V_Supplier") { MetroMessageBox.Show(this, "Form is already opened", "System Message!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); return; } } int stid = Convert.ToInt32(tblProduct.Rows[rw].Cells[0].Value.ToString()); using (V_Supplier ms = new V_Supplier(stid)) { ms.ShowDialog(); } } } catch (Exception ex) { MetroMessageBox.Show(this, "System Error " + ex.Message, "System Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }