private void btnSave_Click(object sender, EventArgs e) { try { if (ReturnGrid.Rows.Count == 0 || TransGrid.Rows.Count == 0) { FrmMessage.Show("No items were selected for return."); } else if (string.IsNullOrEmpty(txtReason.Text.Trim())) { FrmMessage.Show("Please Enter the reason for return."); } else { if (DialogResult.Yes == FrmMessage.Show("Are You Sure You want to return these items.", caption, YesNoButton, QuestionIcon)) { bool result = false; for (int i = 0; i < ReturnGrid.Rows.Count; i++) { result = sqlhelp.ExecuteNonQuery("insert into RETURNTOSUPPLIER (StockID,SUPPLIERID,CATEGORYID,ITEMID,Barcode,RETURNQTY,ITEMPRICE,TOTALAMOUNT,Reason,CREATEDBY) Values " + "(" + ReturnGrid.Rows[i].Cells["StockID"].Value.ToString() + "," + ReturnGrid.Rows[i].Cells["SupplierID"].Value.ToString() + "," + ReturnGrid.Rows[i].Cells["CategoryID"].Value.ToString() + "," + "" + ReturnGrid.Rows[i].Cells["ItemID"].Value.ToString() + ",'" + ReturnGrid.Rows[i].Cells["Barcode"].Value.ToString() + "'," + ReturnGrid.Rows[i].Cells["Quantity"].Value.ToString() + "," + "" + ReturnGrid.Rows[i].Cells["Item Price"].Value.ToString() + "," + ReturnGrid.Rows[i].Cells["Total Amount"].Value.ToString() + ",'" + txtReason.Text.Trim() + "'," + GlobalData.UserID + ")"); result = sqlhelp.ExecuteNonQuery("update Stock set StockQuantity= (StockQuantity-" + int.Parse(ReturnGrid.Rows[i].Cells["Quantity"].Value.ToString()) + ")" + " where SUPPLIERID=" + ReturnGrid.Rows[i].Cells["SupplierID"].Value.ToString() + " and CATEGORYID=" + ReturnGrid.Rows[i].Cells["CategoryID"].Value.ToString() + "" + " and ITEMID=" + ReturnGrid.Rows[i].Cells["ItemID"].Value.ToString() + " and StockID=" + ReturnGrid.Rows[i].Cells["StockID"].Value.ToString() + ""); } if (result == true) { FrmMessage.Show("Returned Items to Supplier Successfully"); ReturnToSupplier form = new ReturnToSupplier { MdiParent = this.MdiParent, Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))), Dock = DockStyle.Fill }; form.Show(); } } } } catch (Exception ex) { } finally { } }
private void button1_Click(object sender, EventArgs e) { try { if (dataGridView1.Rows.Count == 0 || dataGridView2.Rows.Count == 0) { FrmMessage.Show("No items were selected for return."); } else if (string.IsNullOrEmpty(textBox1.Text.Trim())) { FrmMessage.Show("Please Enter the reason for return."); } else { if (DialogResult.Yes == FrmMessage.Show("Are You Sure You want to return these items to Supplier.", caption, YesNoButton, QuestionIcon)) { bool result = false; for (int i = 0; i < dataGridView2.Rows.Count; i++) { result = sqlhelp.ExecuteNonQuery("insert into RETURNITEMSTOSUPPLIER (POID,SUPPLIERID,CATEGORYID,ITEMNAME,RETURNQTY,ITEMPRICE,TOTALAMOUNT,Reason,CREATEDBY) Values " + "(" + dataGridView2.Rows[i].Cells["POID"].Value.ToString() + "," + dataGridView2.Rows[i].Cells["SupplierID"].Value.ToString() + "," + dataGridView2.Rows[i].Cells["CategoryID"].Value.ToString() + "," + "'" + dataGridView2.Rows[i].Cells["ItemName"].Value.ToString() + "'," + dataGridView2.Rows[i].Cells["Qty"].Value.ToString() + "," + "" + dataGridView2.Rows[i].Cells["UnitPrice"].Value.ToString() + "," + dataGridView2.Rows[i].Cells["AfterVat"].Value.ToString() + ",'" + textBox1.Text.Trim() + "'," + GlobalData.UserID + ")"); result = sqlhelp.ExecuteNonQuery("update SupplierOrder set Qty= (Qty-" + dataGridView2.Rows[i].Cells["Qty"].Value + "),TotalAmount = (TotalAmount-" + dataGridView2.Rows[i].Cells["BeforeVat"].Value + ")" + " where SUPPLIERID=" + dataGridView2.Rows[i].Cells["SupplierID"].Value.ToString() + " and CATEGORYID=" + dataGridView2.Rows[i].Cells["CategoryID"].Value.ToString() + "" + " and POID=" + dataGridView2.Rows[i].Cells["POID"].Value.ToString() + " and ItemName='" + dataGridView2.Rows[i].Cells["ItemName"].Value.ToString() + "'"); } if (result == true) { FrmMessage.Show("Returned Items to Supplier Successfully Make Sure you Return the Items from Stock for this Item !!"); ReturnToSupplier form = new ReturnToSupplier { MdiParent = this.MdiParent, Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))), Dock = DockStyle.Fill }; form.Show(); } } } } catch (Exception ex) { } finally { } }
private void btnSrchItems_Click(object sender, EventArgs e) { try { dtTran = new DataTable(); dtTran1 = new DataTable(); dtTran = sqlhelp.ExecuteTables("Select GS.*,(SH.InvoiceAmount/SH.Qty) as [ItemPrice] from GetStock GS, StockHistory SH where GS.StockID=SH.StockID and GS.SupplierID like'" + ddlsrchsupp.SelectedValue + "' and GS.CategoryID like'" + ddlSrchCat.SelectedValue + "' and GS.ItemID like'" + ddlsrchitem.SelectedValue + "'"); if (dtTran.Rows.Count > 0) { dtTran1 = sqlhelp.ExecuteTables("Select * from ItemSplit where SupplierID like'" + ddlsrchsupp.SelectedValue + "' and CategoryID like'" + ddlSrchCat.SelectedValue + "' and ItemName ='" + ddlsrchitem.Text + "'"); if (dtTran1.Rows.Count > 0) { FrmMessage.Show("You can not return this Item, Beacuse This Item Has Splited to lesser Qty !!!"); } else { TransGrid.DataSource = dtTran; TransGrid.Columns["ItemPrice"].HeaderText = "Item Price"; TransGrid.Columns["StockID"].Visible = false; TransGrid.Columns["SupplierID"].Visible = false; TransGrid.Columns["ItemID"].Visible = false; TransGrid.Columns["CategoryID"].Visible = false; TransGrid.Columns["ImageName"].Visible = false; TransGrid.Columns["ReOrder Qty"].Visible = false; TransGrid.Columns["StockDescription"].Visible = false; } } else { FrmMessage.Show("No Records Found !!!"); ReturnToSupplier rtnStock = new ReturnToSupplier { MdiParent = this, Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))), Dock = DockStyle.Fill }; rtnStock.Show(); } } catch (Exception ex) { } finally { } }