private void btnPreview_Click(object sender, EventArgs e) { try { string vWhere = string.Empty; string criteria = string.Empty; Reports.RptReportViewer vForm = new Reports.RptReportViewer(); if (!string.IsNullOrEmpty(this.txt_ProductID.Text)) { vWhere += " AND StockWastageBody.ProductID=" + this.txt_ProductID.Text; } if (optRange.Checked == true) { vWhere += " AND convert(datetime,Convert(varchar,StockWastage.EntryDate,1)) Between Convert(Datetime,(convert(varchar,convert(Datetime,'" + this.dt_From.Text + " 00:00:00',102),1))) AND Convert(Datetime,(convert(varchar,convert(Datetime,'" + this.dt_ToDate.Text + " 00:00:00',102),1)))"; criteria += "From: " + dt_From.Value.ToString("dd-MMM-yyyy") + " To: " + dt_ToDate.Value.ToString("dd-MMM-yyyy"); } else { criteria += " Till Date: " + dt_ToDate.Value.ToString("dd-MMM-yyyy"); } DataTable dt = objDAL.getRecord(vWhere); if (dt.Rows.Count == 0) { MessageBox.Show("No Data To Display", "No Data"); return; } vForm.ProductWiseWaste(criteria, dt); vForm.ShowDialog(); } catch (Exception exc) { MessageBox.Show(exc.Message, "Error"); } }
private void OpenInvoice(Int64 vID) { try { btnClear_Click(null, null); DataTable dt = objDAL.getRecord(" AND StockWastage.WasteID=" + vID); if (dt.Rows.Count > 0) { txtInvNo.Text = dt.Rows[0]["WasteID"].ToString(); dtEntryDate.Text = dt.Rows[0]["EntryDate"].ToString(); txtRemarks.Text = dt.Rows[0]["Remarks"].ToString(); //Grid.DataSource = dt; foreach (DataRow dr in dt.Rows) { Grid.Rows.Add(dr["ProductID"].ToString(), dr["ProductName"].ToString(), decimal.Parse(dr["UnitID"].ToString()).ToString("0"), dr["UnitTitle"].ToString(), dr["Units"].ToString(), decimal.Parse(dr["Qty"].ToString()).ToString("G29"), decimal.Parse(dr["Cost"].ToString()).ToString("G29")); } SetMode(true); } else { MessageBox.Show("Invalid ID.", "Invalid Information"); SetMode(false); } } catch (Exception exc) { MessageBox.Show(exc.Message.ToString(), "Error"); } }