private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex == 9) // for print { BillEL objBillEL = new BillEL(); objBillEL.Bill_Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Bill_Id"].Value); BillReportViewer objBillReportViewer = new BillReportViewer(companyEL, objBillEL); objBillReportViewer.ShowDialog(); objBillReportViewer.Dispose(); } if (e.ColumnIndex == 10) //For Delete { if (Common.MessageConfim("Are You Want To Delete This ")) { SQLHelper objSQLHelper = new SQLHelper(); SqlTransaction objSqlTransaction = objSQLHelper.BeginTrans(); BillDL objBillDL = new BillDL(); BillEL objBillEL = new BillEL(); objBillEL.Bill_Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Bill_Id"].Value); BillDetailDL objBillDetailDL = new BillDetailDL(); List <BillDetailEL> lstBillDetail = objBillDetailDL.GetBillDetailByBillId(objBillEL.Bill_Id); BillItemDL objBillItemDL = new BillItemDL(); List <BillItemEL> lstBillItemEL = objBillItemDL.GetBillItemByBillId(objBillEL.Bill_Id); BillItemNarrationDL _BillItemNarrationDL = new BillItemNarrationDL(); List <BillItemNarrationEL> lstBillItemNarration = new List <BillItemNarrationEL>(); try { lstBillItemEL.ForEach(r => lstBillItemNarration.AddRange(_BillItemNarrationDL.GetBillItemNarrationBy_BillItemId(r.Bill_Item_Id))); lstBillItemNarration.ForEach(n => _BillItemNarrationDL.Delete(objSqlTransaction, n)); lstBillDetail.ForEach(r => objBillDetailDL.Delete(objSqlTransaction, r)); lstBillItemEL.ForEach(r => objBillItemDL.Delete(objSqlTransaction, r)); objBillDL.Delete(objSqlTransaction, objBillEL); objSqlTransaction.Commit(); Common.MessageDelete(); GridBind(); } catch (Exception) { objSqlTransaction.Rollback(); } } } if (e.ColumnIndex == 11)//For bill Edit { BillDL _BillDL = new BillDL(); BillEL objBillEL = _BillDL.GetBillById(Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Bill_Id"].Value)); CreateBill objCreateBill = new CreateBill(companyEL, objBillEL); objCreateBill.ControlBox = true; objCreateBill.MinimizeBox = false; objCreateBill.ShowDialog(); GridBind(); } } catch { } }
void CreateReport(string billType) { DisposeReport(); string PurchasesOrderNo = ""; string PurchasesOrderDate = ""; string DeliveryNo = ""; string DeliveryDate = ""; BillDetailDL objBillDetailDL = new BillDetailDL(); List <BillDetailEL> lstBillDetail = objBillDetailDL.GetBillDetailByBillId(billEL.Bill_Id); var qurPurchases = from b in lstBillingDelivertDetail join bd in lstBillDetail on b.Delivery_Detail_Id equals bd.Delivery_Detail_Id select new { b.Purchases_Order_Id, b.PURCHASES_ORDER_Date, b.Purchases_Order_No }; var qurDelivary = from b in lstBillingDelivertDetail join bd in lstBillDetail on b.Delivery_Detail_Id equals bd.Delivery_Detail_Id select new { b.Delivery_Id, b.Delivery_Date, b.Delivery_No }; foreach (var item in qurDelivary.Distinct()) { DeliveryNo += ", " + item.Delivery_No.Trim(); DeliveryDate += ", " + item.Delivery_Date.ToString("dd/MM/yyyy").Trim(); } foreach (var item in qurPurchases.Distinct()) { PurchasesOrderNo += ", " + item.Purchases_Order_No.Trim(); PurchasesOrderDate += ", " + item.PURCHASES_ORDER_Date.ToString("dd/MM/yyyy").Trim(); } if (qurDelivary.Distinct().Count() > 10) { DeliveryNo = ",As per attach challan copy"; DeliveryDate = ",As per attach challan copy"; } try { BillDL objBillDL = new BillDL(); DataSet ds = objBillDL.GetBillReportData(companyEL, billEL); //if ((int)ds.Tables["GetBillReportHeader"].Rows[0]["Bill_Type_Id"] == (int)enumBillType.RetailInvoice_Jobwork // || (int)ds.Tables["GetBillReportHeader"].Rows[0]["Bill_Type_Id"] == (int)enumBillType.TaxInvoice_Jobwork) //{ // objRpt = new CR_Bill(); // objRpt.SetDataSource(ds); // objRpt.SetParameterValue("Order_No", PurchasesOrderNo.Substring(1)); // objRpt.SetParameterValue("Order_Date", PurchasesOrderDate.Substring(1)); // objRpt.SetParameterValue("Challan_NO", DeliveryNo.Substring(1)); // objRpt.SetParameterValue("Challan_Date", DeliveryDate.Substring(1)); // objRpt.SetParameterValue("Bill_Type", billType); // if (companyEL.Company_Type_Id == (int)enumCompanyType.Delhi) // { // objRpt.SetParameterValue("Tin_No", " 07050294694"); // } // else if (companyEL.Company_Type_Id == (int)enumCompanyType.Noida) // { // objRpt.SetParameterValue("Tin_No", " 09165703716"); // } // crystalReportViewer1.ReportSource = objRpt; //} //else //{ objRptSale = new CR_Bill_Sale(); objRptSale.SetDataSource(ds); objRptSale.SetParameterValue("Order_No", PurchasesOrderNo.Substring(1)); objRptSale.SetParameterValue("Order_Date", PurchasesOrderDate.Substring(1)); objRptSale.SetParameterValue("Challan_NO", DeliveryNo.Substring(1)); objRptSale.SetParameterValue("Challan_Date", DeliveryDate.Substring(1)); objRptSale.SetParameterValue("Bill_Type", billType); if (companyEL.Company_Type_Id == (int)enumCompanyType.Delhi) { objRptSale.SetParameterValue("Tin_No", " 07050294694"); } else if (companyEL.Company_Type_Id == (int)enumCompanyType.Noida) { objRptSale.SetParameterValue("Tin_No", " 09165703716"); } crystalReportViewer1.ReportSource = objRptSale; //} } catch (Exception ex) { string dt = ex.Message; } }