public bool Update_SIR_Detail(string IssueNO, string JobCardNO, string ItemCode, double IssueQty, ref SqlTransaction Trans) { string strSIRNo = string.Empty; string strSQL = string.Empty; bool result = false; try { strSIRNo = SysFunc.GetStringValuesAgainstCodes("IssueNO", IssueNO, "SIRNo", "StockIssue", "", Session["DealerCode"].ToString()); dt = SysFunc.GetData("Select * From SIRDetail Where SIRNo = '" + strSIRNo + "' AND DealerCode IN( '" + Session["DealerCode"].ToString() + "','COMON') And ItemCode='" + ItemCode + "' "); Session["strSIRNo"] = strSIRNo; strSQL = "Update SIRDetail SET RecQty = RecQty - " + IssueQty.ToString() + " Where DealerCode = '" + Session["DealerCode"].ToString() + "' And SIRNo = '" + strSIRNo + "' And ItemCode = '" + ItemCode + "' "; result = SysFunc.ExecuteQuery(strSQL, Trans); strSQL = "Update StockIssueDetail SET RetQty = RetQty + " + IssueQty.ToString() + " Where DealerCode = '" + Session["DealerCode"].ToString() + "' And IssueNo = '" + IssueNO + "' And ItemCode = '" + ItemCode + "' "; if (SysFunc.ExecuteQuery(strSQL, Trans) == true) { return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
private void LoadPOInfo(string PONo) { string mPONo = ddPONumber.Text; if (mPONo == "") { mPONo = this.Session["PONumber"].ToString(); } DataTable dt = new DataTable(); string sql = "select PO.POno,po.PODate,po.VendorCode,v.VendorDesc, po.VendorDCNo from POMaster PO left outer join Vendor V on po.VendorCode = v.VendorCode where PO.PONo='" + mPONo + "'"; dt = myFunc.GetData(sql); if (dt.Rows.Count == 0) { return; } dpPODate.Date = Convert.ToDateTime(dt.Rows[0]["PODate"].ToString()); txtVendorCode.Text = dt.Rows[0]["VendorCode"].ToString(); txtVendorName.Text = dt.Rows[0]["VendorDesc"].ToString(); //txtVendorDCNo.Text = dt.Rows[0]["VendorDCNo"].ToString(); ///Commented by Akram //dpDCDate.Date = Convert.ToDateTime( myFunc.GetServerTime()); ///Ended dt.Dispose(); }
protected void txtRegNo_ButtonClick(object source, DevExpress.Web.ASPxEditors.ButtonEditClickEventArgs e) { string sql = "SELECT Distinct cv.EngineNo AS [Engine No], cv.RegNo AS [Reg No], cv.ChassisNo AS [Chassis No],"; sql += " c.CusDesc + ' ' + c.FatherHusName AS Customer FROM CustomerVehicle cv INNER JOIN "; sql += " Customer c ON cv.CusCode = c.CusCode AND cv.DealerCode=c.DealerCode "; sql += " where cv.DealerCode IN ('AAAAA','" + Session["DealerCode"].ToString() + "') "; DataTable dt = new DataTable(); dt = myFunc.GetData(sql); }
protected void SelectedPartDetail(string item) { try { DataTable dt = new DataTable(); dt = myFunc.GetData("select ItemDesc,PartItemNo from Item where DealerCode in('" + Session["DealerCode"].ToString() + "','COMON') And ItemCode='" + item + "'"); if (btnValue == 1) { txtFromItemCode.Text = item; txtFromItemDesc.Text = dt.Rows[0]["ItemDesc"].ToString().Trim(); txtToItemCode.Text = item; txtToItemDesc.Text = dt.Rows[0]["ItemDesc"].ToString().Trim(); } else if (btnValue == 2) { txtToItemCode.Text = item; txtToItemDesc.Text = dt.Rows[0]["ItemDesc"].ToString().Trim(); } } catch (Exception ex) { myFunc.UserMsg(lblMsg, Color.Red, ex.Message); } }
protected void ddlDCno_SelectedIndexChanged(object sender, EventArgs e) { lblMode.Text = "Edit Mode"; string sql = "select * from DCMaster where DealerCode='" + Session["DealerCode"].ToString() + "' And DCNo='" + ddlDCno.SelectedValue + "'"; DataTable dt = myFunc.GetData(sql); if (dt.Rows.Count > 0) { txtDCDate.Text = dt.Rows[0]["DCDate"].ToString(); //ddlPONo.Text = dt.Rows[0]["PONo"].ToString(); ddlPONo.Visible = false; lblPONo.Visible = true; lblPONo.Text = dt.Rows[0]["PONo"].ToString(); this.Session["PONumber"] = dt.Rows[0]["PONo"].ToString(); txtVendorDCn0.Text = dt.Rows[0]["VendorDCNo"].ToString(); txtRemarks.Text = dt.Rows[0]["Remarks"].ToString(); this.Session["DCNumber"] = ddlDCno.SelectedValue; LoadPOInfo(lblPONo.Text); //btnPOSelect_Click(btnPOSelect, EventArgs.Empty); // loading details of DC DataTable dtTable = new DataTable(); dtTable = (DataTable)this.Session["DCTable"]; dtTable.Rows.Clear(); dt = myFunc.GetData("select * from DCDetail where DealerCode='" + Session["DealerCode"].ToString() + "' And DCNo='" + ddlDCno.SelectedValue + "'"); if (dt.Rows.Count != 0) { foreach (DataRow dRow in dt.Rows) { DataRow row = dtTable.NewRow(); row["Sno"] = dtTable.Rows.Count + 1; row["PartItemNo"] = myFunc.GetPartItemNoByItemCode(dRow["ItemCode"].ToString()); row["PartItemName"] = myFunc.GetItemDescByItemCode(dRow["ItemCode"].ToString()); row["unit"] = myFunc.GetUnitDescByPartItemNo(row["PartItemNo"].ToString()); row["POQuantity"] = dRow["POQty"].ToString(); row["BalanceQuantity"] = dRow["BalQty"].ToString(); row["DCQuantity"] = dRow["DCQty"].ToString(); //row["Selected"] = true; dtTable.Rows.Add(row); } } Session["DCTable"] = dtTable; gv_DC.DataSource = dtTable; gv_DC.DataBind(); txtStatus.Text = "OLD"; //btnDelete.Enabled = true; } else { return; } }
protected void btnSelectCustomer_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); try { if (ddCustomerCode.Text == "") { return; } if (myFunc.CodeExists("Customer", "CusCode", ddCustomerCode.Text, Session["DealerCode"].ToString())) { string sql = "select * from Customer where CusCode='" + ddCustomerCode.Text.Trim() + "' and DealerCode='" + Session["DealerCode"].ToString() + "'"; dt = myFunc.GetData(sql); if (dt.Rows.Count > 0) { btnDelete.Enabled = true; //ddCustomerCode.Enabled = false; txtCustomerName.Text = dt.Rows[0]["CusDesc"].ToString(); txtAddress1.Text = dt.Rows[0]["Address1"].ToString(); txtAddress2.Text = dt.Rows[0]["Address2"].ToString(); txtAddress3.Text = dt.Rows[0]["Address3"].ToString(); txtNICNo.Text = dt.Rows[0]["NIC"].ToString(); txtNTNNo.Text = dt.Rows[0]["NTNno"].ToString(); if (dt.Rows[0]["DOB"].ToString() != "") { dpDOB.Date = Convert.ToDateTime(dt.Rows[0]["DOB"].ToString()); //dpDOB.Date = Convert.ToDateTime( dt.Rows[0]["DOB"].ToString() ).ToString("yyyy/MM/dd")); } txtPhoneNumber.Text = dt.Rows[0]["Phone1"].ToString(); txtPhoneNumber2.Text = dt.Rows[0]["Phone2"].ToString(); txtFaxNumber.Text = dt.Rows[0]["FaxNo"].ToString(); txtEmail.Text = dt.Rows[0]["Email"].ToString(); txtURL.Text = dt.Rows[0]["URL"].ToString(); spnCreditDays.Text = dt.Rows[0]["CreditDays"].ToString(); txtCreditLimit.Text = dt.Rows[0]["CreditLimit"].ToString(); txtContactPerson.Text = dt.Rows[0]["ContPerson"].ToString(); txtSaleTaxRegNo.Text = dt.Rows[0]["SalesTaxRegNo"].ToString(); txtFatherHusband.Text = dt.Rows[0]["FatherHusName"].ToString(); txtCellNumber.Text = dt.Rows[0]["CellNo"].ToString(); txtDistance.Text = dt.Rows[0]["Distance"].ToString(); cmbCustomerType.Text = dt.Rows[0]["CusTypeCode"].ToString(); } } } catch (Exception ex) { SendAlert("Error:" + ex.ToString()); } }
protected void SelectedPartDetail(string item) { //DataTable dt = new DataTable(); //dt = myFunc.GetData("select ItemDesc,PartItemNo from Item where DealerCode='" + Session["DealerCode"].ToString() + "' And ItemCode='" + item + "'"); txtCustomer.Text = item; string sql = "Select CusDesc from Customer where CusCode='" + item + "' and DealerCode='" + Session["DealerCode"].ToString() + "'"; DataTable dt = new DataTable(); dt = myFunc.GetData(sql); if (dt.Rows.Count > 0) { txtCustomerDesc.Text = dt.Rows[0]["CusDesc"].ToString(); } }
protected void btnSaveSubLoc_Click(object sender, EventArgs e) { string sql = ""; if (txtSubCodeDesc.Text == "") { lblMSG.Text = "Please enter sub description"; PopupControlMSG.ShowOnPageLoad = true; txtSubCodeDesc.Focus(); return; } string msg = ""; // saving sub location code if (!myFunc.isSubLocCodeExist(txtLocCode.Text, txtSubLocCode.Text)) { sql = "insert into PartsSubLocation (DealerCode,PartsLocCode, PartsSubLocCode, PartsSubLocDesc, UpdUser, UpdDate, UpdTime, UpdTerm)"; sql += " Values('" + this.Session["DealerCode"].ToString() + "','" + txtLocCode.Text.Trim().ToUpper() + "','" + txtSubLocCode.Text.Trim().ToUpper() + "','" + txtSubCodeDesc.Text.Trim().ToUpper() + "','"; sql += this.Session["UserName"].ToString() + "',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,'" + Environment.MachineName + "')"; msg = "Saved"; } else { sql = "update PartsSubLocation Set PartsSubLocDesc='" + txtSubCodeDesc.Text.Trim().ToUpper().ToUpper() + "' where PartsSubLocCode='" + txtSubLocCode.Text.Trim().ToUpper() + "' and PartsLocCode='" + txtLocCode.Text.Trim().ToUpper() + "'"; msg = "Update"; } myFunc.GetData(sql); lblMSG.Text = "Record Has Been " + msg; PopupControlMSG.ShowOnPageLoad = true; txtSubCodeDesc.Enabled = false; txtSubLocCode_TextChanged(txtSubLocCode, EventArgs.Empty); }
protected void Page_Load(object sender, System.EventArgs e) { try { if (!Page.IsPostBack) { ColumnsName = Session["ColumnsName"].ToString(); AppendWhere = Session["AppendInWhere"].ToString(); if (Request.QueryString.Count > 0) { LookUpPageId = int.Parse(Request.QueryString.Get("lpi").ToString()); //SqlParameter[] param = { // new SqlParameter("@LookUpId",SqlDbType.Int) }; //param[0].Value = LookUpPageId; DataTable dt = new DataTable(); string sql = "exec sp_LookUp_Select '" + LookUpPageId + "'"; dt = objMBL.GetData(sql); //rdblColumns.DataSource = objMBL.FillDataSet("sp_LookUp_Select", param); rdblColumns.DataSource = dt; rdblColumns.DataTextField = "DisplayText"; rdblColumns.DataValueField = "ColumnValue"; rdblColumns.DataBind(); if (rdblColumns.Items.Count != 0) { rdblColumns.ClearSelection(); rdblColumns.SelectedIndex = 0; } getData(); } } txtSearch.Focus(); } catch (Exception ex) { lblMsg.Text = ex.Message; } }
private void createLubDT() { DataSet ds = new DataSet(); DataTable dt = new DataTable(); SysFunction sysfun = new SysFunction(); string sql = "exec SP_CRM_PostSales_NextDueMaintenance_Select '" + Session["DealerCode"].ToString() + "'"; ds = myFunc.GetData(sql, "CRM_PostSales_NextDueMaintenance"); if (ds.Tables[0].Rows.Count > 0) { grdNextDueMaintenance.DataSource = ds.Tables[0]; grdNextDueMaintenance.DataBind(); } Session["NextDueMaintenance"] = ds; }
protected void ddlReceiptNo_SelectedIndexChanged(object sender, EventArgs e) { if (RbtnType.SelectedValue == "Customer") { dt = SysFunc.GetData("SP_GEt_AdvancePaymentReceipt_refund '" + Session["DealerCode"] + "','" + ddlReceiptNo.SelectedValue + "'"); if (dt.Rows.Count > 0) { lblType.Text = "Customer"; txtCusVenCode.Text = dt.Rows[0]["CusCode"].ToString(); txtCUSVen.Text = dt.Rows[0]["CusDesc"].ToString(); txtInvType.Text = dt.Rows[0]["InvoiceType"].ToString(); txtBalance.Text = dt.Rows[0]["AdvanceBalanceAmount"].ToString(); } } else { lblType.Text = "Vendor"; } }
private void ViewData() { DataTable dt = new DataTable(); try { string sql = "Select * from Dealer where DealerCode = '" + Session["DealerCode"].ToString().Trim() + "'"; dt = SysFunc.GetData(sql); txtDealerCode.Text = dt.Rows[0]["DealerCode"].ToString(); txtDealerName.Text = dt.Rows[0]["DealerDesc"].ToString(); txtAddress1.Text = dt.Rows[0]["Address1"].ToString(); txtAddress2.Text = dt.Rows[0]["Address2"].ToString(); txtAddress3.Text = dt.Rows[0]["Address3"].ToString(); txtPhone1.Text = dt.Rows[0]["Phone1"].ToString(); txtPhone2.Text = dt.Rows[0]["Phone2"].ToString(); txtFax.Text = dt.Rows[0]["Fax"].ToString(); txtTaxReg.Text = dt.Rows[0]["SaleTaxNo"].ToString(); txtEmail1.Text = dt.Rows[0]["Email"].ToString(); txtNTN.Text = dt.Rows[0]["NTN"].ToString(); txtCreditLimit.Text = dt.Rows[0]["CreditLimit"].ToString(); txtPSTPerc.Text = dt.Rows[0]["PST"].ToString(); txtHandling.Text = dt.Rows[0]["HandlingCharges"].ToString(); txtOpAs.Text = dt.Rows[0]["OperatedBy"].ToString(); txtDealerRefC.Text = dt.Rows[0]["DealerRefCode"].ToString(); txtVehicleCategory.Text = dt.Rows[0]["VehicleCategory"].ToString(); if (dt.Rows[0]["Logo"].ToString() == "") { Image1.ImageUrl = "~/Images/BlankProfile.jpg"; } else { Image1.ImageUrl = "../../" + dt.Rows[0]["Logo"].ToString(); } } catch (Exception ex) { lblmsg.Visible = true; lblmsg.ForeColor = System.Drawing.Color.Red; lblmsg.Text = ex.Message; } }
protected void btnLookup_Click(object sender, EventArgs e) { DataTable dtSMSApplic = new DataTable(); DataTable dtQuery = new DataTable(); DataTable dtMessage = new DataTable(); string DealerCode = "00249"; string squery = "Select * from BMS_SMSApplicable where IsActive = 'Y'"; dtSMSApplic = myFunc.GetData(squery); DataRow[] dr = dtSMSApplic.Select(); for (int j = 0; j < dr.Length; j++) { string squery1 = dtSMSApplic.Rows[j]["squery"].ToString().Trim() + "and A.DealerCode = '" + DealerCode + "'"; dtQuery = myFunc.GetData(squery1); DataRow[] drr = dtQuery.Select(); for (int i = 0; i < drr.Length; i++) { SqlParameter[] param3 = { new SqlParameter("@DealerCode", SqlDbType.Char, 5), new SqlParameter("@DMSRefNo", SqlDbType.Char, 8), new SqlParameter("@CustomerCode", SqlDbType.VarChar, 8), new SqlParameter("@CustomerDes", SqlDbType.VarChar, 50), new SqlParameter("@Module", SqlDbType.VarChar, 10), new SqlParameter("@ModuleType", SqlDbType.VarChar, 10), new SqlParameter("@SMSApplicCode", SqlDbType.Char, 5), }; if (dtQuery.Rows[i]["DMSRefNo"].ToString() != "") { param3[0].Value = Session["DealerCode"].ToString(); param3[1].Value = dtQuery.Rows[i]["DMSRefNo"].ToString(); param3[2].Value = dtQuery.Rows[i]["CustomerCode"].ToString(); param3[3].Value = dtQuery.Rows[i]["CustomerDes"].ToString(); param3[4].Value = dtQuery.Rows[i]["Module"].ToString(); param3[5].Value = dtQuery.Rows[i]["ModuleType"].ToString(); param3[6].Value = dtSMSApplic.Rows[j]["SMSApplicCode"].ToString(); myFunc.ExecuteSP_NonQuery("SP_Insert_BMS_SMSTransMaster", param3); } } //string query3 = "exec SP_SMSMessage '" + Session["DealerCode"].ToString() + "' , '" + dtSMSApplic.Rows[j]["SMSApplicCode"].ToString().Trim() + "'"; //string AutoNum = ""; //dtMessage = myFunc.GetData(query3); //drr = dtMessage.Select(); //for (int i = 0; i < drr.Length; i++) //{ // string username = "******"; // string password = "******"; // string from = "MasterMotor"; // if (dtMessage.Rows[i]["CellNo"].ToString().StartsWith("0")) // { // AutoNum = "92" + dtMessage.Rows[i]["CellNo"].ToString().Substring(dtMessage.Rows[i]["CellNo"].ToString().Length - (dtMessage.Rows[i]["CellNo"].ToString().Length - 1)); // } // string to = AutoNum; // string message = dtMessage.Rows[i]["Message"].ToString(); // //string urlString = string.Format("http://weblogin.premiumsms.pk/sendsms_url.html?Username={0}&Password={1}&From={2}&To={3}&Message={4}", username, password, from, to, message); // //Uri URI = new Uri(urlString); // //WebClient wc = new WebClient(); // //string res = wc.DownloadString(URI); // string qry = "Update BMS_SMSTransMaster set SMSText = '" + message + "' ,"+ // " SMSApplicCode = '" + dtSMSApplic.Rows[j]["SMSApplicCode"].ToString() + "' ,"+ // " SMSTo = '" + to + "', SMSFrom = '" + from + "' , "+ // " SendDate ='" + myFunc.SaveDate(DateTime.Now.ToString("dd/MM/yyyy")) + "',"+ // " where SMSTransID = '"+ dtMessage.Rows[i]["SMSTransID"].ToString() + "'"; // myFunc.ExecuteQuery_NonQuery(qry); //} } }
//protected void btnPrint_Click(object sender, EventArgs e) //{ // ScriptManager.RegisterStartupScript(this, GetType(), "Print", "Print()", true); //} protected void btnPrint_Click(object sender, EventArgs e) { ReportDocument RD = new ReportDocument(); string FDate = SysFunc.SaveDate(txtFromDate.Text).ToString(); string TDate = SysFunc.SaveDate(txtToDate.Text).ToString(); DataSet dsRpt = new DataSet(); DXBMS.Data.DSReports objDsReports = new Data.DSReports(); DataTable dt = new DataTable(); string sql; if (ViewState["Name"].ToString() == "DCR") { if (!sec.UserRight("2561", "006")) { Response.Redirect("~/Test.aspx"); } sql = "exec sp_DailyCollectionSP '" + Session["DealerCode"].ToString() + "','" + FDate + "','" + TDate + "'"; RD.Load(Server.MapPath("../../ServiceReports/ptIncommingPaymentDetail2.rpt")); RD.DataDefinition.FormulaFields["ReportTitle"].Text = "\"" + "INCOMING PAYMENTS DETAIL" + "\""; } else if (ViewState["Name"].ToString() == "ASI") { if (!sec.UserRight("2563", "006")) { Response.Redirect("~/Test.aspx"); } sql = "exec SP_vw_AfterSaleInvoiceDetail_New '" + Session["DealerCode"].ToString() + "','" + FDate + "','" + TDate + "' , '" + txtCusCode.Text + "'"; RD.Load(Server.MapPath("../../ServiceReports/rptAfterSaleInvoice.rpt")); RD.DataDefinition.FormulaFields["ReportTitle"].Text = "\"" + "AFTER SALE INVOICE DETAIL" + "\""; } else { if (!sec.UserRight("2562", "006")) { Response.Redirect("~/Test.aspx"); } sql = "exec SP_Aging_Select '" + Session["DealerCode"].ToString() + "','" + FDate + "','" + TDate + "', '" + txtCusCode.Text + "'"; RD.Load(Server.MapPath("../../ServiceReports/rptAging.rpt")); RD.DataDefinition.FormulaFields["ReportTitle"].Text = "\"" + "AGING DETAIL" + "\""; } dt = SysFunc.GetData(sql); RD.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4; RD.DataDefinition.FormulaFields["DealerPhone"].Text = "'" + Session["DealerPhone"].ToString() + "'"; RD.DataDefinition.FormulaFields["DealerEmail"].Text = "'" + Session["DealerEmail"].ToString() + "'"; RD.DataDefinition.FormulaFields["DealerFax"].Text = "'" + Session["DealerFax"].ToString() + "'"; RD.DataDefinition.FormulaFields["DealerDesc"].Text = "'" + Session["DealerDesc"].ToString() + "'"; RD.DataDefinition.FormulaFields["DealerAddress"].Text = "'" + Session["DealerAddress"].ToString() + "'"; RD.DataDefinition.FormulaFields["UserID"].Text = "'" + Session["UserID"].ToString() + "'"; RD.DataDefinition.FormulaFields["Terminal"].Text = "'" + Environment.MachineName + "'"; RD.DataDefinition.FormulaFields["CompanyName"].Text = "'" + Session["DealerDesc"].ToString() + "'"; RD.DataDefinition.FormulaFields["Pic"].Text = "'" + Server.MapPath("~") + Session["Logo"] + "'"; //RD.DataDefinition.FormulaFields["Pic"].Text = "'C:\\Users\\u_ahm\\OneDrive\\Documents\\Visual Studio 2010\\Projects\\WebApplication1\\WebApplication1\\Images\\havoline.png'"; //RD.DataDefinition.FormulaFields["DealershipName"].Text = "'Authorised " + Session["ParentDesc"].ToString() + " Dealership'"; RD.Database.Tables[0].SetDataSource(dt); string FilePath = Server.MapPath("~") + "\\Download\\"; string FileName = "Report.pdf"; string File = FilePath + FileName; PdfDocument outputDocument = new PdfDocument(); Stream stream = RD.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); DirectoryInfo info = new DirectoryInfo(FilePath); if (!info.Exists) { info.Create(); } string path = Path.Combine(FilePath, FileName); using (FileStream outputFileStream = new FileStream(path, FileMode.Create)) { stream.CopyTo(outputFileStream); } stream.Dispose(); stream.Close(); stream = null; string URL = "../../../../Download/PrintReport.aspx"; string fullURL = "window.open('" + URL + "', '_blank', 'height=800,width=1000,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no');"; ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true); Session["RD"] = RD; //crviewer.ReportSource = RD; //convert and show //string FilePath = Server.MapPath("~") + "\\Download\\"; //string FileName = "JobCardDetail" + this.Session["DealerCode"].ToString() + DateTime.Now.ToString("ddMMyyyy") + ".pdf"; //string File = FilePath + FileName; //Session["RD"] = RD; //string URL = "../../../../Download/rptViewerService.aspx?ReportID=StockBalance"; //string fullURL = "window.open('" + URL + "', '_blank', 'height=800,width=10200,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no');"; //ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true); }
protected void BtnHistory_Click(object sender, EventArgs e) { if (!sec.UserRight("2565", "006")) { Response.Redirect("~/Test.aspx"); } if (ddlRegNo.SelectedIndex == 0 || ddlEngineNo.SelectedIndex == 0 || ddlChassisNo.SelectedIndex == 0) { lblMSG.Text = "Please select Engine Number, Chassis Number and Registration Number"; return; } ReportDocument RD = new ReportDocument(); DataSet dsRpt = new DataSet(); DXBMS.Data.DataSet1 objDsReports = new Data.DataSet1(); SqlParameter[] param = { new SqlParameter("@DealerCode", SqlDbType.Char, 5), new SqlParameter("@EngNo", SqlDbType.VarChar,30), //1 new SqlParameter("@ChasNo", SqlDbType.VarChar,30), //2 new SqlParameter("@RegNo", SqlDbType.VarChar,15), //3 }; param[0].Value = Session["DealerCode"].ToString(); param[1].Value = ddlEngineNo.Text; param[2].Value = ddlChassisNo.Text; param[3].Value = ddlRegNo.Text; //if (myFunc.ExecuteSPDMIS("sp2W_Spare_InvoiceDetail", param, ref rder)) //if(myFunc.ExecuteSP("sp2W_Spare_InvoiceDetail",param,ref rder)) //{ // objDsReports.sp2W_Spare_InvoiceDetail.Load(rder); //} DataTable dt = new DataTable(); string sql = "exec sp_JobcardHistory '" + Session["DealerCode"].ToString() + "','" + ddlEngineNo.Text + "','" + ddlChassisNo.Text + "','" + ddlRegNo.Text + "'"; dt = myFunc.GetData(sql); RD.PrintOptions.PaperSize = PaperSize.PaperA4; //RD.Load(Server.MapPath("../../SpareReports/rptInvoices.rpt")); RD.Load(Server.MapPath("../rptJobHistory.rpt")); RD.DataDefinition.FormulaFields["DealerPhone"].Text = "'" + Session["DealerPhone"].ToString() + "'"; RD.DataDefinition.FormulaFields["DealerEmail"].Text = "'" + Session["DealerEmail"].ToString() + "'"; RD.DataDefinition.FormulaFields["DealerName"].Text = "'" + Session["DealerDesc"].ToString() + "'"; RD.DataDefinition.FormulaFields["DealerAddress"].Text = "'" + Session["DealerAddress"].ToString() + "'"; RD.DataDefinition.FormulaFields["NTN"].Text = "'" + Session["DealerNTN"].ToString() + "'"; RD.DataDefinition.FormulaFields["SalesTaxNo"].Text = "'" + Session["DealerSaleTaxNo"].ToString() + " '"; RD.DataDefinition.FormulaFields["UserID"].Text = "'" + Session["UserID"].ToString() + "'"; //RD.DataDefinition.FormulaFields["FromCode"].Text = "'" + FDate + "'"; //RD.DataDefinition.FormulaFields["ToCode"].Text = "'" + TDate + "'"; RD.DataDefinition.FormulaFields["Terminal"].Text = "'" + Environment.MachineName + "'"; RD.DataDefinition.FormulaFields["ReportTitle"].Text = "\"" + "Jobcard History" + "\""; RD.DataDefinition.FormulaFields["CompanyName"].Text = "'" + Session["DealerDesc"].ToString() + "'"; //RD.DataDefinition.FormulaFields["DealershipName"].Text = "'Authorised " + Session["ParentDesc"].ToString() + " Dealership'"; //RD.DataDefinition.FormulaFields["Pic"].Text = "'C:\\Users\\u_ahm\\OneDrive\\Documents\\Visual Studio 2010\\Projects\\WebApplication1\\WebApplication1\\" + Session["Logo"] + "'"; RD.DataDefinition.FormulaFields["Pic"].Text = "'" + Server.MapPath("~") + Session["Logo"] + "'"; //RD.Database.Tables[0].SetDataSource(objDsReports); RD.Database.Tables[0].SetDataSource(dt); string FilePath = Server.MapPath("~") + "\\Download\\"; string FileName = "Report.pdf"; string File = FilePath + FileName; PdfDocument outputDocument = new PdfDocument(); Stream stream = RD.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); DirectoryInfo info = new DirectoryInfo(FilePath); if (!info.Exists) { info.Create(); } string path = Path.Combine(FilePath, FileName); using (FileStream outputFileStream = new FileStream(path, FileMode.Create)) { stream.CopyTo(outputFileStream); } stream.Dispose(); stream.Close(); string URL = "../../../../Download/PrintReport.aspx"; string fullURL = "window.open('" + URL + "', '_blank', 'height=800,width=1000,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no');"; ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true); //// convert and show //string FilePath = Server.MapPath("~") + "\\Download\\"; //string FileName = "JobcardHistory" + this.Session["DealerCode"].ToString() + DateTime.Now.ToString("ddMMyyyy") + ".pdf"; //string File = FilePath + FileName; //Session["RD"] = RD; //string URL; //URL = "../../../../Download/rptViewerService.aspx?FileName=" + FileName; //string fullURL = "window.open('" + URL + "', '_blank', 'height=800,width=1200,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no');"; //ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true); //string URL = "../../Service/ServiceReports/rptViewerService.aspx?ReportID=History&EngineNo=" + ddlEngineNo.SelectedItem.Text; //string fullURL = "window.open('" + URL + "', '_blank', 'height=800,width=1000,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no');"; //ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true); }
protected void Print(object sender, EventArgs e) { if (!sec.UserRight("2575", "006")) { Response.Redirect("~/Test.aspx"); } Data.DSReports data = new Data.DSReports(); ReportDocument RD = new ReportDocument(); SqlDataReader rder = null; DateTime fromDate = DateTime.ParseExact(txtFromDate.Text, "dd-MM-yyyy", null); DateTime toDate = DateTime.ParseExact(txtToDate.Text, "dd-MM-yyyy", null); if (ddlType.SelectedValue == "Cus") { SqlParameter[] param = { new SqlParameter("@DealerCode", SqlDbType.Char, 5), //0 new SqlParameter("@FromDate", SqlDbType.DateTime), //1 new SqlParameter("@ToDate", SqlDbType.DateTime), //2 new SqlParameter("@CusCode", SqlDbType.VarChar) }; param[0].Value = Session["DealerCode"].ToString(); param[1].Value = sysFunc.SaveDate(txtFromDate.Text); param[2].Value = sysFunc.SaveDate(txtToDate.Text); if (txtCusCode.Text == "") { param[3].Value = ""; } else { param[3].Value = txtCusCode.Text; } string sql = "exec SP_PartyLedger_Report '" + Session["DealerCode"].ToString() + "','" + sysFunc.SaveDate(txtFromDate.Text) + "','" + sysFunc.SaveDate(txtToDate.Text) + "','" + param[3].Value + "'"; dt = sysFunc.GetData(sql); RD.Load(Server.MapPath("../partyLedgerReport.rpt")); } else { SqlParameter[] param = { new SqlParameter("@DealerCode", SqlDbType.Char, 5), //0 new SqlParameter("@FromDate", SqlDbType.DateTime), //1 new SqlParameter("@ToDate", SqlDbType.DateTime), //2 new SqlParameter("@InsCompCode", SqlDbType.VarChar), new SqlParameter("@InsBrCode", SqlDbType.VarChar) }; param[0].Value = Session["DealerCode"].ToString(); param[1].Value = sysFunc.SaveDate(txtFromDate.Text); param[2].Value = sysFunc.SaveDate(txtToDate.Text); param[3].Value = txtInsCompCode.Text; param[4].Value = txtInsBrCode.Text; string sql = "exec SP_PartyLedger_ReportIns '" + Session["DealerCode"].ToString() + "','" + sysFunc.SaveDate(txtFromDate.Text) + "','" + sysFunc.SaveDate(txtToDate.Text) + "','" + param[3].Value + "','" + param[4].Value + "'"; dt = sysFunc.GetData(sql); RD.Load(Server.MapPath("../partyLedgerReportIns.rpt")); } //if (sysFunc.ExecuteSP("SP_PartyLedger_Report", param, ref rder)) //{ // data.SP_PartyLedger_Report.Load(rder); //} //rder.Close(); RD.DataDefinition.FormulaFields["FromDate"].Text = "'" + sysFunc.SaveDate(txtFromDate.Text) + "'"; RD.DataDefinition.FormulaFields["ToDate"].Text = "'" + sysFunc.SaveDate(txtToDate.Text) + "'"; RD.DataDefinition.FormulaFields["DealerDesc"].Text = "'" + Session["DealerDesc"].ToString() + "'"; RD.DataDefinition.FormulaFields["DealerAddress"].Text = "'" + Session["DealerAddress"].ToString() + "'"; RD.DataDefinition.FormulaFields["DealerPhone"].Text = "'" + Session["DealerPhone"].ToString() + "'"; RD.DataDefinition.FormulaFields["DealerEmail"].Text = "'" + Session["DealerEmail"].ToString() + "'"; RD.DataDefinition.FormulaFields["DealerFax"].Text = "'" + Session["DealerFax"].ToString() + "'"; RD.DataDefinition.FormulaFields["ReportTitle"].Text = "'Party Ledger'"; RD.DataDefinition.FormulaFields["UserID"].Text = "'" + Session["UserName"].ToString() + "'"; RD.DataDefinition.FormulaFields["Terminal"].Text = "'" + Request.ServerVariables["REMOTE_ADDR"].ToString() + "'"; RD.DataDefinition.FormulaFields["CompanyName"].Text = "'" + Session["DealerDesc"].ToString() + "'"; //RD.DataDefinition.FormulaFields["DealershipName"].Text = "'Authorised " + Session["ParentDesc"].ToString() + " Dealership'"; //RD.DataDefinition.FormulaFields["Pic"].Text = "'C:\\Users\\u_ahm\\OneDrive\\Documents\\Visual Studio 2010\\Projects\\WebApplication1\\WebApplication1\\" + Session["Logo"] + "'"; RD.DataDefinition.FormulaFields["Pic"].Text = "'" + Server.MapPath("~") + Session["Logo"] + "'"; RD.SetDataSource(dt); string FilePath = Server.MapPath("~") + "\\Download\\"; string FileName = "Report.pdf"; string File = FilePath + FileName; PdfDocument outputDocument = new PdfDocument(); Stream stream = RD.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); DirectoryInfo info = new DirectoryInfo(FilePath); if (!info.Exists) { info.Create(); } string path = Path.Combine(FilePath, FileName); using (FileStream outputFileStream = new FileStream(path, FileMode.Create)) { stream.CopyTo(outputFileStream); } stream.Dispose(); stream.Close(); string URL = "../../../../Download/PrintReport.aspx"; string fullURL = "window.open('" + URL + "', '_blank', 'height=800,width=1500,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no');"; ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true); //// convert and show //string FilePath = Server.MapPath("~") + "\\Download\\"; //string FileName = "crtPartyLedger" + this.Session["DealerCode"].ToString() + DateTime.Now.ToString("ddMMyyyy") + ".pdf"; //string File = FilePath + FileName; //Session["RD"] = RD; ////RD.ExportToDisk(ExportFormatType.PortableDocFormat, File); //string URL; //URL = "../../../../Download/rptViewerService.aspx?FileName=" + FileName; //string fullURL = "window.open('" + URL + "', '_blank', 'height=800,width=1200,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no');"; //ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true); }
protected void btnShowReport_Click(object sender, EventArgs e) { if (dtFrom.Text == "" || dtTo.Text == "") { lblMSG.Text = "Please select dates"; return; } SqlDataReader rder; ReportDocument RD = new ReportDocument(); DateTime FromDate; DateTime ToDate; string FDate = dtFrom.Date.ToString("yyyy/MM/dd"); string TDate = dtTo.Date.ToString("yyyy/MM/dd"); FromDate = Convert.ToDateTime(FDate); ToDate = Convert.ToDateTime(TDate); //ReportDocument RD = new ReportDocument(); //DataSet dsRpt = new DataSet(); DXBMS.Data.DataSet1 objDsReports = new Data.DataSet1(); SqlParameter[] param = { new SqlParameter("@DealerCode", SqlDbType.Char, 5), //0 new SqlParameter("@FromDate", SqlDbType.DateTime), //0 new SqlParameter("@ToDate", SqlDbType.DateTime), //0 new SqlParameter("@Status", SqlDbType.VarChar, 10) //0 }; param[0].Value = Session["DealerCode"].ToString(); param[1].Value = FromDate.ToString("yyyy-MM-dd"); param[2].Value = ToDate.ToString("yyyy-MM-dd"); param[2].Value = rbStatus.SelectedItem.Value.ToString(); //if (myFunc.ExecuteSPDMIS("sp2W_Spare_InvoiceDetail", param, ref rder)) //if(myFunc.ExecuteSP("sp2W_Spare_InvoiceDetail",param,ref rder)) //{ // objDsReports.sp2W_Spare_InvoiceDetail.Load(rder); //} DataTable dt = new DataTable(); string sql = "exec sp_JobCardDetailReport '" + Session["DealerCode"].ToString() + "','" + FromDate.ToString("yyyy-MM-dd") + "','" + ToDate.ToString("yyyy-MM-dd") + "','" + rbStatus.SelectedItem.Value.ToString() + "'"; dt = myFunc.GetData(sql); RD.PrintOptions.PaperSize = PaperSize.PaperA4; //RD.Load(Server.MapPath("../../SpareReports/rptJobCardDateWise.rpt")); RD.Load(Server.MapPath("../rptJobCardDateWise.rpt")); //RD.DataDefinition.FormulaFields["DealerPhone"].Text = "'" + myFunc.GetStringValuesAgainstCodes("DealerCode", Session["DealerCode"].ToString(), "Phone1", "Dealer") + "'"; //RD.DataDefinition.FormulaFields["DealerEmail"].Text = "'" + myFunc.GetStringValuesAgainstCodes("DealerCode", Session["DealerCode"].ToString(), "Email", "Dealer") + "'"; //RD.DataDefinition.FormulaFields["DealerName"].Text = "'" + myFunc.GetStringValuesAgainstCodes("DealerCode", Session["DealerCode"].ToString(), "DealerDesc", "Dealer") + "'"; //RD.DataDefinition.FormulaFields["DealerAddress"].Text = "'" + myFunc.GetStringValuesAgainstCodes("DealerCode", Session["DealerCode"].ToString(), "Address1", "Dealer") + "" + // myFunc.GetStringValuesAgainstCodes("DealerCode", Session["DealerCode"].ToString(), "Address2", "Dealer") + "" + // myFunc.GetStringValuesAgainstCodes("DealerCode", Session["DealerCode"].ToString(), "Address3", "Dealer") + " (" + // myFunc.GetStringValuesAgainstCodes("DealerCode", Session["DealerCode"].ToString(), "Phone1", "Dealer") + ") '"; RD.DataDefinition.FormulaFields["UserID"].Text = "'" + Session["UserID"].ToString() + "'"; RD.DataDefinition.FormulaFields["FromCode"].Text = "'" + FDate + "'"; RD.DataDefinition.FormulaFields["ToCode"].Text = "'" + TDate + "'"; RD.DataDefinition.FormulaFields["Terminal"].Text = "'" + Environment.MachineName + "'"; RD.DataDefinition.FormulaFields["ReportTitle"].Text = "\"" + "Jobcard Detail Report" + "\""; RD.DataDefinition.FormulaFields["CompanyName"].Text = "'" + Session["DealerDesc"].ToString() + "'"; //RD.DataDefinition.FormulaFields["DealershipName"].Text = "'Authorised " + Session["ParentDesc"].ToString() + " Dealership'"; //RD.Database.Tables[0].SetDataSource(objDsReports); RD.DataDefinition.FormulaFields["Pic"].Text = "'C:\\Users\\u_ahm\\OneDrive\\Documents\\Visual Studio 2010\\Projects\\WebApplication1\\WebApplication1\\" + Session["Logo"] + "'"; RD.Database.Tables[0].SetDataSource(dt); // convert and show string FilePath = Server.MapPath("~") + "\\Download\\"; string FileName = "JobCardDetail" + this.Session["DealerCode"].ToString() + DateTime.Now.ToString("ddMMyyyy") + ".pdf"; string File = FilePath + FileName; RD.ExportToDisk(ExportFormatType.PortableDocFormat, File); string URL; URL = "../../../../Download/OpenPdf.aspx?FileName=" + FileName; string fullURL = "window.open('" + URL + "', '_blank', 'height=800,width=1000,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no');"; ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true); }