public void ProcessRequest(HttpContext context) { MyClass Fn = new MyClass(); string[] dataID = Fn.CleanSQL(HttpUtility.UrlDecode(context.Request.QueryString["id"])).Split('ǁ'); { try { context.Response.ContentType = "text/HTML"; switch (Convert.ToInt32(dataID[0])) { case 0: string formdata = HttpUtility.UrlDecode(context.Request.Form["vls"]); string formcost = HttpUtility.UrlDecode(context.Request.Form["rt1"]); string Case0ID = "0"; if (formdata.Contains('½')) { Case0ID = Fn.ExenID(@"INSERT INTO VehicleProblem (Problem, Date, WorkshopID, Vehicle_id, DriverEmpID, Description) VALUES ('" + formdata.Split('½')[0] + @"','" + formdata.Split('½')[1] + @"','" + formdata.Split('½')[2] + @"','" + formdata.Split('½')[3] + @"','" + formdata.Split('½')[4] + @"','" + formdata.Split('½')[5] + @"'); select SCOPE_IDENTITY()"); if (formcost.Contains('¼')) { foreach (string item in formcost.Split('¼')) { if (item.Contains('½')) { Fn.Exec(@"INSERT INTO VehicleProblemCost (VehicleProblemID, CostFor, Descrtiption, CostAmount) VALUES ('" + Case0ID + @"','" + item.Split('½')[0] + @"','" + item.Split('½')[1] + @"','" + item.Split('½')[2] + @"')"); } } } } context.Response.Write(Case0ID); break; case 1: context.Response.Write(Fn.HTMLTableWithID_TR_Tag(@"SELECT VehicleProblem.VehicleProblemID, VehicleProblem.Problem, VehicleProblem.Date, Vehicle.Number Vehicle, Workshop.Workshop_Name Workshop, ISNULL(tblEmployee.FName,'')+' '+ ISNULL(tblEmployee.LName,'') AS Driver FROM VehicleProblem INNER JOIN Vehicle ON VehicleProblem.Vehicle_id = Vehicle.Vehicle_id INNER JOIN Workshop ON VehicleProblem.WorkshopID = Workshop.Workshop_Id INNER JOIN tblEmployee ON VehicleProblem.DriverEmpID = tblEmployee.EmpID", "tblReq")); break; default: context.Response.Write("<p>Contents not available</p>"); break; } } catch { context.Response.ContentType = "text/HTML"; context.Response.Write("<p>Contents not available</p>"); } } }
public void ProcessRequest(HttpContext context) { MyClass Fn = new MyClass(); string[] dataID = Fn.CleanSQL(HttpUtility.UrlDecode(context.Request.QueryString["id"])).Split('ǁ'); string[] fdata = new string[500]; if (context.Request.Form["ourformData"] != null) { //string testing = context.Request.Form["ourformData"]; fdata = Fn.CleanSQL(HttpUtility.UrlDecode(context.Request.Form["ourformData"])).Split('½'); } { try { context.Response.ContentType = "text/HTML"; switch (Convert.ToInt32(dataID[0])) { case 0: var x0 = context.Request.Form["frmData"]; var Id01 = HttpUtility.UrlDecode(Convert.ToString(x0)); if (Id01.Split('ǁ')[12] == "0") { context.Response.Write(Fn.ExenID(@"INSERT INTO tblJobRequirement (Post, GradeBPS, PostJobStatus, DutyStation, TotalPositions, Gender, MinAge, MaxAge, Purpose, QualificationRequired, ExperienceRequired, JobDuties, dtDateTime, EnterByEmpID, Status) VALUES ('" + Id01.Split('ǁ')[0] + @"','" + Id01.Split('ǁ')[1] + @"','" + Id01.Split('ǁ')[2] + @"','" + Id01.Split('ǁ')[3] + @"','" + Id01.Split('ǁ')[4] + @"','" + Id01.Split('ǁ')[5] + @"','" + Id01.Split('ǁ')[6] + @"','" + Id01.Split('ǁ')[7] + @"','" + WebUtility.HtmlEncode(Id01.Split('ǁ')[8]) + @"','" + WebUtility.HtmlEncode(Id01.Split('ǁ')[9]) + @"','" + WebUtility.HtmlEncode(Id01.Split('ǁ')[10]) + @"','" + WebUtility.HtmlEncode(Id01.Split('ǁ')[11]) + @"',GETDATE(),'" + Convert.ToString(Convert.ToString(((HttpCookie)HttpContext.Current.Request.Cookies["Emp_Id"]).Value)) + @"','Sent'); select SCOPE_IDENTITY()")); } else { context.Response.Write(Fn.ExenID(@"UPDATE tblJobRequirement SET Post ='" + Id01.Split('ǁ')[0] + @"', GradeBPS ='" + Id01.Split('ǁ')[1] + @"', PostJobStatus ='" + Id01.Split('ǁ')[2] + @"', DutyStation ='" + Id01.Split('ǁ')[3] + @"', TotalPositions ='" + Id01.Split('ǁ')[4] + @"', Gender ='" + Id01.Split('ǁ')[5] + @"', MinAge ='" + Id01.Split('ǁ')[6] + @"', MaxAge ='" + Id01.Split('ǁ')[7] + @"', Purpose ='" + WebUtility.HtmlEncode(Id01.Split('ǁ')[8]) + @"', QualificationRequired ='" + WebUtility.HtmlEncode(Id01.Split('ǁ')[9]) + @"', ExperienceRequired ='" + WebUtility.HtmlEncode(Id01.Split('ǁ')[10]) + @"', JobDuties ='" + WebUtility.HtmlEncode(Id01.Split('ǁ')[11]) + @"', Status ='Sent' ,Remarks ='' WHERE (tblJobRequirementID = '" + Id01.Split('ǁ')[12] + @"'); select SCOPE_IDENTITY()")); } break; case 1: context.Response.Write(Fn.HTMLTableWithID_TR_Tag(@"SELECT tblJobRequirementID, Post, PostJobStatus [Post JobS tatus], DutyStation [Duty Station], TotalPositions [Total Positions], Gender, MinAge [Min Age], MaxAge [Max Age], Status, Remarks FROM tblJobRequirement order by dtDateTime", "tblReq")); break; case 2: context.Response.Write(Fn.Data2Json(@"SELECT Post, GradeBPS, PostJobStatus, DutyStation, TotalPositions, Gender, MinAge, MaxAge, Purpose, QualificationRequired, ExperienceRequired, JobDuties, tblJobRequirementID FROM tblJobRequirement WHERE tblJobRequirementID=" + dataID[1])); break; case 3: context.Response.Write(Fn.HTMLTableWithID_TR_Tag(@"SELECT tblJobRequirementID, Post, GradeBPS [Grade/BPS], PostJobStatus [Post JobS tatus], DutyStation [Duty Station], TotalPositions [Total Positions], Gender, MinAge [Min Age], MaxAge [Max Age], Status FROM tblJobRequirement where status = 'Sent' order by dtDateTime", "tblReq")); break; case 4: var x4 = context.Request.Form["frmData"]; var Id41 = HttpUtility.UrlDecode(Convert.ToString(x4)); if (Id41.Split('ǁ')[12] == "0") { context.Response.Write(Fn.ExenID(@"INSERT INTO tblJobRequirement (Post, GradeBPS, PostJobStatus, DutyStation, TotalPositions, Gender, MinAge, MaxAge, Purpose, QualificationRequired, ExperienceRequired, JobDuties, dtDateTime, EnterByEmpID, Status) VALUES ('" + Id41.Split('ǁ')[0] + @"','" + Id41.Split('ǁ')[1] + @"','" + Id41.Split('ǁ')[2] + @"','" + Id41.Split('ǁ')[3] + @"','" + Id41.Split('ǁ')[4] + @"','" + Id41.Split('ǁ')[5] + @"','" + Id41.Split('ǁ')[6] + @"','" + Id41.Split('ǁ')[7] + @"','" + WebUtility.HtmlEncode(Id41.Split('ǁ')[8]) + @"','" + WebUtility.HtmlEncode(Id41.Split('ǁ')[9]) + @"','" + WebUtility.HtmlEncode(Id41.Split('ǁ')[10]) + @"','" + WebUtility.HtmlEncode(Id41.Split('ǁ')[11]) + @"',GETDATE(),'" + Convert.ToString(Convert.ToString(((HttpCookie)HttpContext.Current.Request.Cookies["Emp_Id"]).Value)) + @"','Sent'); select SCOPE_IDENTITY()")); } else { context.Response.Write(Fn.ExenID(@"UPDATE tblJobRequirement SET Post ='" + Id41.Split('ǁ')[0] + @"', GradeBPS ='" + Id41.Split('ǁ')[1] + @"', PostJobStatus ='" + Id41.Split('ǁ')[2] + @"', DutyStation ='" + Id41.Split('ǁ')[3] + @"', TotalPositions ='" + Id41.Split('ǁ')[4] + @"', Gender ='" + Id41.Split('ǁ')[5] + @"', MinAge ='" + Id41.Split('ǁ')[6] + @"', MaxAge ='" + Id41.Split('ǁ')[7] + @"', Purpose ='" + WebUtility.HtmlEncode(Id41.Split('ǁ')[8]) + @"', QualificationRequired ='" + WebUtility.HtmlEncode(Id41.Split('ǁ')[9]) + @"', ExperienceRequired ='" + WebUtility.HtmlEncode(Id41.Split('ǁ')[10]) + @"', JobDuties ='" + WebUtility.HtmlEncode(Id41.Split('ǁ')[11]) + @"' , Remarks ='" + WebUtility.HtmlEncode(Id41.Split('ǁ')[14]) + @"' , LastDateToApply=CONVERT(DATETIME,'" + WebUtility.HtmlEncode(Id41.Split('ǁ')[15]) + @"',103), Status='" + WebUtility.HtmlEncode(Id41.Split('ǁ')[16]) + @"' WHERE (tblJobRequirementID = '" + Id41.Split('ǁ')[12] + @"'); select SCOPE_IDENTITY()")); } break; case 5: context.Response.Write(Fn.HTMLTableWithID_TR_Tag(@"Select tblJobRequirementID, 'FRDP-B4-'+RIGHT('00000' + CAST(tblJobRequirementID AS VARCHAR(50)),5) +'/'+CAST(DATEPART(YYYY, dtDateTime) AS VARCHAR(50))+'-R' AS [Case No], Post, GradeBPS [Grade/BPS], PostJobStatus [Job Status], DutyStation [Duty Station], TotalPositions [Total Positions] , convert(varchar(50), CONVERT(DATETIME,ISNULL(LastDateToApply,'01/01/1990'),103), 106) as [Last Date] from tblJobRequirement where LastDateToApply > GetDATE() order by dtDateTime desc", "tblJl")); break; //Select tblJobRequirementID, 'PPHI-B4-'+RIGHT('00000' + CAST(tblJobRequirementID AS VARCHAR(50)),5) +'/'+CAST(DATEPART(YYYY, dtDateTime) AS VARCHAR(50))+'-R' AS [Case No] from tblJobRequirement case 6: context.Response.Write(Fn.Data2Json(@"SELECT tblJobRequirementID, 'FRDP-B4-' + RIGHT('00000' + CAST(tblJobRequirementID AS VARCHAR(50)), 5) + '/' + CAST(DATEPART(YYYY, dtDateTime) AS VARCHAR(50)) + '-R' +' [ '+ Post +' ]' as Post FROM tblJobRequirement ORDER BY dtDateTime DESCs")); break; case 7: context.Response.Write(Fn.HTMLTableWithID_TR_Tag(@"SELECT tblCandidate_tblJobRequirement.tblCandidate_tblJobRequirementID, tblCandidate.Name, tblCandidate.FatherName [Father Name], Convert(varchar(50),tblCandidate.dtDOB,103) as [DOB], tblCandidate.CNIC, tblCandidate.City, tblCandidate.District, tblCandidate.Phone, tblCandidate.Mobile, CONVERT(varchar(50), tblCandidate_tblJobRequirement.dtDateTime, 103) AS [Date Applied], Case When tblCandidate_tblJobRequirement.bIsShortListed=1 Then '<button title=''Select Candidate...'' class=''btnEdit btn btn-success'' customtooltip=''Select Candidate''>s</button>' else '<button title=''Select Candidate...'' class=''btnEdit btn btn-info'' customtooltip=''Select Candidate''>s</button>' END as [ ] FROM tblCandidate_tblJobRequirement INNER JOIN tblCandidate ON tblCandidate_tblJobRequirement.tblCandidateID = tblCandidate.tblCandidateID WHERE tblCandidate_tblJobRequirement.tblJobRequirementID =" + dataID[1], "tblJl")); break; case 8: context.Response.Write(Fn.Exec("UPDATE tblCandidate_tblJobRequirement SET bIsShortListed=" + dataID[2] + " WHERE tblCandidate_tblJobRequirementID='" + dataID[1] + "'")); break; case 9: context.Response.Write(Fn.HTMLTableWithID_TR_Tag(@"SELECT tblCandidate_tblJobRequirement.tblCandidate_tblJobRequirementID, tblCandidate.Name, tblCandidate.FatherName AS [Father Name], CONVERT(varchar(50), tblCandidate.dtDOB, 103) AS DOB, tblCandidate.CNIC, tblCandidate.City, tblCandidate.District, tblCandidate.Phone, tblCandidate.Mobile, CONVERT(varchar(50), tblCandidate_tblJobRequirement.dtDateTime, 103) AS [Date Applied], '<input class=''btnEdit Integer'' type=''text'' value='''+CAST(ISNULL(tblCandidate_tblJobRequirement.InterviewMarks,'0') AS VARCHAR(50))+''' style=''width: 60px;''>' AS [Interview Marks] FROM tblCandidate_tblJobRequirement INNER JOIN tblCandidate ON tblCandidate_tblJobRequirement.tblCandidateID = tblCandidate.tblCandidateID WHERE tblCandidate_tblJobRequirement.bIsShortListed = 1 and tblCandidate_tblJobRequirement.tblJobRequirementID =" + dataID[1], "tblJl")); break; case 10: context.Response.Write(Fn.Exec("UPDATE tblCandidate_tblJobRequirement SET InterviewMarks='" + dataID[2] + "' WHERE tblCandidate_tblJobRequirementID='" + dataID[1] + "'")); break; case 11: context.Response.Write(Fn.HTMLTableWithID_TR_Tag(@"SELECT tblCandidate_tblJobRequirement.tblCandidate_tblJobRequirementID, tblCandidate.Name, tblCandidate.FatherName AS [Father Name], CONVERT(varchar(50), tblCandidate.dtDOB, 103) AS DOB, tblCandidate.CNIC, tblCandidate.City, tblCandidate.District, tblCandidate.Phone, tblCandidate.Mobile, CONVERT(varchar(50), tblCandidate_tblJobRequirement.dtDateTime, 103) AS [Date Applied], ISNULL(tblCandidate_tblJobRequirement.InterviewMarks,0) AS [Interview Marks] FROM tblCandidate_tblJobRequirement INNER JOIN tblCandidate ON tblCandidate_tblJobRequirement.tblCandidateID = tblCandidate.tblCandidateID WHERE tblCandidate_tblJobRequirement.bIsShortListed = 1 and tblCandidate_tblJobRequirement.tblJobRequirementID =" + dataID[1] + " ORDER BY ISNULL(tblCandidate_tblJobRequirement.InterviewMarks,0) ", "tblJl")); break; case 12: context.Response.Write(Fn.HTMLTableWithID_TR_Tag(@"SELECT Login.LoginID,'' [Sr#], Login.UserName, tblDtl.Name, tblDtl.[Emp No], tblDtl.[Service Type], tblDtl.Father, tblDtl.CNIC, tblDtl.BPS, tblDtl.Designation, User_Groups.User_Group_Name [Group Name] FROM Login INNER JOIN (SELECT User_ID, Full_Name AS Name, '' AS [Emp No], '' AS [Service Type], FatherName AS Father, CNIC, '' AS BPS, Designation, 'TblHResources' AS TableName FROM TblHResources UNION SELECT tblEmployee.EmpID, ISNULL(tblEmployee.FName, '') + ' ' + ISNULL(tblEmployee.LName, '') AS Name, 'FRDP-EMP-' + RIGHT('00000' + CAST(ISNULL(tblEmployee.EmpNo, 0) AS VARCHAR(50)), 5) AS EMPNO, tblEmployee.PostTyp, ISNULL(tblEmployee.Father, '') AS Father, tblEmployee.CNIC, CASE WHEN tblEmployee.BPS = 0 THEN 'N/A' ELSE 'BPS' + CAST(tblEmployee.BPS AS VARCHAR(50)) END AS BPS, tblDesig.NAME AS Designation, 'tblEmployee' AS TableName FROM tbl_Company INNER JOIN tblDept INNER JOIN Shift INNER JOIN tblEmployee INNER JOIN TblDistrict ON tblEmployee.Domicile = TblDistrict.DistrictID ON Shift.Shift_ID = tblEmployee.tblEmpShiftID INNER JOIN tblDesig ON tblEmployee.tblDesigID = tblDesig.ID ON tblDept.ID = tblEmployee.tblDept ON tbl_Company.CompanyID = tblEmployee.tblCompanyID) AS tblDtl ON Login.Emp_Id = tblDtl.User_ID AND Login.TableName = tblDtl.TableName INNER JOIN User_Groups ON Login.User_Group_Id = User_Groups.User_Group_Id order by Login.UserName", "tblJl")); break; default: context.Response.Write("<p>Contents not available</p>"); break; } } catch { context.Response.ContentType = "text/HTML"; context.Response.Write("<p>Contents not available</p>"); } } }
public static String PostFeedback(string name, string email, string subject, string feedback) { string tomail = Fn.GetRecords("SELECT Email FROM TblHResources WHERE (User_ID = 1)")[0]; Fn.Exec("INSERT INTO TblFeedback(fUser, fEmail, fSubject, fComments)VALUES ('" + Fn.CleanSQL(name) + "', '" + Fn.CleanSQL(email) + "', '" + Fn.CleanSQL(subject) + "', '" + Fn.CleanSQL(feedback) + "')"); Fn.SendEmail(tomail, subject + " - " + name, feedback, email); return("Thanks for feedback"); }
public void ProcessRequest(HttpContext context) { MyClass Fn = new MyClass(); string[] dataID = Fn.CleanSQL(HttpUtility.UrlDecode(context.Request.QueryString["id"])).Split('ǁ'); string[] fdata = new string[500]; if (context.Request.Form["ourformData"] != null) { //string testing = context.Request.Form["ourformData"]; fdata = HttpUtility.UrlDecode(context.Request.Form["ourformData"]).Split('½'); } { try { context.Response.ContentType = "text/HTML"; switch (Convert.ToInt32(dataID[0])) { case 0: context.Response.Write(Fn.Data2Json("Select * from [dbo].[tblInventoryDefault] where tblInventoryDefaultID=1")); break; case 1: context.Response.Write(Fn.Exec(@"UPDATE tblInventoryDefault SET MaxLevels =" + dataID[1] + @" WHERE (tblInventoryDefaultID = 1)")); break; case 2: // context.Response.Write(Fn.Data2Json(@"SELECT tblPlaceID, Code, Name, Branch= ( // //Select count(*) from tblPlace as B where B.ParentId= M.tblPlaceID //) //FROM tblPlace AS M //WHERE ParentId IS NULL order by Code")); context.Response.Write(Fn.Data2Json(@"Select M.CompanyID AS tblPlaceID, M.Code , M.CompanyName AS Name, 0 bIsHead, Branch= ( Select count(*) from tbl_Company AS B Where B.ParentId=M.CompanyID ) from tbl_Company as M WHERE M.ParentId IS NULL order by M.CompanyID, M.Code")); break; case 3: // context.Response.Write(Fn.Data2Json(@" SELECT tblPlaceID, Code, Name, Branch= ( // //Select count(*) from tblPlace as B where B.ParentId= M.tblPlaceID //) //FROM tblPlace AS M //WHERE ParentId =" + dataID[1] + " order by Code")); context.Response.Write(Fn.Data2Json(@" SELECT M.CompanyID AS tblPlaceID, Code, M.CompanyName Name, 0 bIsHead, Branch= ( Select count(*) from tbl_Company as B where B.ParentId= M.CompanyID ) FROM tbl_Company AS M WHERE ParentId =" + dataID[1] + " order by Code")); break; case 4: // context.Response.Write(Fn.Exec(@"UPDATE tblPlace //SET Name = '" + dataID[1] + @"' //WHERE (tblPlaceID = " + dataID[2] + ")")); context.Response.Write(Fn.Exec(@"UPDATE tbl_Company SET CompanyName = '" + dataID[1] + @"' WHERE (CompanyID = " + dataID[2] + ")")); break; case 5: decimal?tblid = 0; int? tblcode = 0; using (DBDataContext db = new DBDataContext()) { db.sp_tblPlace_Insert(dataID[1], dataID[2], ref tblid, ref tblcode); } string sssssss = Convert.ToString(tblid) + "½" + Convert.ToString(tblcode); context.Response.Write(sssssss); break; default: context.Response.Write("<p>Contents not available</p>"); break; } } catch { context.Response.ContentType = "text/HTML"; context.Response.Write("<p>Contents not available</p>"); } } }
public void ProcessRequest(HttpContext context) { MyClass Fn = new MyClass(); string[] dataID = Fn.CleanSQL(HttpUtility.UrlDecode(context.Request.QueryString["id"])).Split('ǁ'); { try { context.Response.ContentType = "text/HTML"; switch (Convert.ToInt32(dataID[0])) { case 0: using (DBDataContext db = new DBDataContext()) { if (db.tblElecticityMeters.Where(vv => vv.MeterNo.ToUpper() == dataID[4].ToUpper()).Count() > 0) { context.Response.Write("Meter No Already Registered"); break; } } if (dataID[2] == "WAPDA In") { context.Response.Write(Fn.Exec(@"INSERT INTO dbo.tblElecticityMeter (tbl_Company_LocationID, MeterType, MeterPlacedAt, MeterNo, MeterReading, OwnerName, OwnerType, Emp_Id, dtDateTime, MultipleFactor) VALUES ('" + dataID[1] + "','" + dataID[2] + "','" + dataID[3] + "','" + dataID[4] + "','" + dataID[5] + "','" + dataID[6] + "','" + dataID[7] + "','" + Convert.ToString(Convert.ToString(((HttpCookie)HttpContext.Current.Request.Cookies["Emp_Id"]).Value)) + "',GETDATE() , '" + dataID[8] + "')")); } else if (dataID[2] == "Main Meter") { context.Response.Write(Fn.Exec(@"INSERT INTO dbo.tblElecticityMeter (tbl_Company_LocationID, MeterType, WapdaMeterID, MeterPlacedAt, MeterNo, MeterReading, OwnerName, OwnerType, Emp_Id, dtDateTime, MultipleFactor) VALUES ('" + dataID[1] + "','" + dataID[2] + "','" + dataID[3] + "','" + dataID[4] + "','" + dataID[5] + "','" + dataID[6] + "','" + dataID[7] + "','" + dataID[8] + "','" + Convert.ToString(Convert.ToString(((HttpCookie)HttpContext.Current.Request.Cookies["Emp_Id"]).Value)) + "',GETDATE() , '" + dataID[9] + "')")); } else if (dataID[2] == "Sub Meter") { context.Response.Write(Fn.Exec(@"INSERT INTO dbo.tblElecticityMeter (tbl_Company_LocationID, MeterType, WapdaMeterID, MainMeterID, MeterPlacedAt, MeterNo, MeterReading, OwnerName, OwnerType, Emp_Id, dtDateTime, MultipleFactor) VALUES ('" + dataID[1] + "','" + dataID[2] + "','" + dataID[3] + "','" + dataID[4] + "','" + dataID[5] + "','" + dataID[6] + "','" + dataID[7] + "','" + dataID[8] + "','" + dataID[9] + "','" + Convert.ToString(Convert.ToString(((HttpCookie)HttpContext.Current.Request.Cookies["Emp_Id"]).Value)) + "',GETDATE() , '" + dataID[10] + "')")); } break; case 1: context.Response.Write(Fn.Data2Json(@"SELECT tblElecticityMeter.MeterNo, tblElecticityMeter.tblElecticityMeterID, tblElecticityMeter.MeterType, tblElecticityMeter.OwnerName, tblElecticityMeter.tbl_Company_LocationID, tblElecticityMeter.MeterReading, tblElecticityMeter.Emp_Id, tblElecticityMeter.dtDateTime, tbl_Company.CompanyName FROM tblElecticityMeter INNER JOIN tbl_Company ON tblElecticityMeter.tbl_Company_LocationID = tbl_Company.CompanyID")); break; case 2: context.Response.Write(Fn.Exec(@"DELETE FROM tblElecticityMeter WHERE tblElecticityMeterID = " + dataID[1])); break; case 3: context.Response.Write(Fn.Data2Json(@"SELECT tblElecticityMeter.MeterNo, tblElecticityMeter.tblElecticityMeterID, tblElecticityMeter.MeterType, tblElecticityMeter.OwnerName, tblElecticityMeter.tbl_Company_LocationID, tblElecticityMeter.MeterReading, tblElecticityMeter.Emp_Id, tblElecticityMeter.dtDateTime, tbl_Company.CompanyName FROM tblElecticityMeter INNER JOIN tbl_Company ON tblElecticityMeter.tbl_Company_LocationID = tbl_Company.CompanyID where tblElecticityMeter.tblElecticityMeterID =" + dataID[1])); break; case 4: context.Response.Write(Fn.Exec(@"UPDATE tblElecticityMeter SET MeterNo ='" + dataID[1] + "', MeterType ='" + dataID[2] + "', OwnerName ='" + dataID[3] + "', tbl_Company_LocationID ='" + dataID[4] + "', MeterReading ='" + dataID[5] + "' WHERE tblElecticityMeterID=" + dataID[6])); break; case 5: context.Response.Write(Fn.Data2Json(@"SELECT tblElecticityMeterID, MeterNo FROM tblElecticityMeter WHERE (tbl_Company_LocationID =" + dataID[1] + ") ORDER BY MeterNo")); break; case 6: string[] d6 = dataID[3].Split('-'); DateTime dt6 = new DateTime(Convert.ToInt32(d6[2]), Convert.ToInt32(d6[1]), Convert.ToInt32(d6[0])); context.Response.Write(Fn.Exec(@"INSERT INTO tblElecticityMeterReading (tblElecticityMeterID, dtDate, reading, OffPeakReading, OnPeakReading) VALUES ('" + dataID[2] + "','" + dt6 + "','" + dataID[4] + "', '" + dataID[5] + "', '" + dataID[6] + "')")); break; case 7: context.Response.Write(Fn.Data2Json(@"SELECT tblElecticityMeterReading.tblElecticityMeterReadingID, CONVERT(VARCHAR(50),tblElecticityMeterReading.dtDate,103) AS dtDate, tblElecticityMeterReading.reading, tblElecticityMeterReading.tblElecticityMeterID, tblElecticityMeter.MeterNo FROM tblElecticityMeterReading INNER JOIN tblElecticityMeter ON tblElecticityMeterReading.tblElecticityMeterID = tblElecticityMeter.tblElecticityMeterID ORDER BY tblElecticityMeterReading.dtDate , tblElecticityMeter.MeterNo ")); break; case 8: context.Response.Write(Fn.Exec(@"DELETE FROM tblElecticityMeterReading WHERE tblElecticityMeterReadingID = " + dataID[1])); break; ////////////////////////////////////////// case 9: context.Response.Write(Fn.Data2Json(@"SELECT tblGeneratorMaintinanceID, CONVERT(VARCHAR(50), dtDateTime, 103) AS dtDateTime, MeterReading, HoursValue,Parts, Description, tblGeneratorID FROM tblGeneratorMaintinance WHERE tblGeneratorID=" + dataID[1] + "ORDER BY dtDateTime")); break; case 10: string[] d10 = dataID[1].Split('-'); DateTime dt10 = new DateTime(Convert.ToInt32(d10[2]), Convert.ToInt32(d10[1]), Convert.ToInt32(d10[0])); context.Response.Write(Fn.Exec(@"INSERT INTO tblGeneratorOnOff (dtDate, DipVlue, MeterReading, OnTime, OffTime, Description, tblGeneratorID) VALUES ('" + dt10 + "','" + dataID[5] + "','" + dataID[4] + "','" + d10[2] + '-' + d10[1] + '-' + d10[0] + ' ' + dataID[2] + "','" + d10[2] + '-' + d10[1] + '-' + d10[0] + ' ' + dataID[3] + "','" + dataID[6] + "', " + dataID[7] + ")")); break; case 11: context.Response.Write(Fn.Data2Json(@"SELECT tblGeneratorID AS ID, ISNULL(Modal,'') +' '+ ISNULL(Brand,'') AS Modal FROM tblGenerator WHERE LocationID =" + dataID[1])); break; case 12: context.Response.Write(Fn.Data2Json(@"SELECT tblGenerator.tblGeneratorID, tblGenerator.LocationID, tblGenerator.EnterbyEmp, tblGenerator.dtEnteredDate, tblGenerator.Modal, tblGenerator.Brand, tblGenerator.Capacity, tblGenerator.FuleTankSize, tblGenerator.FuleFilterModal, tblGenerator.OilFilterModal, tblGenerator.WaterFilterModal, tblGenerator.AirFilterModal, tblGenerator.OilQuantity, tblGenerator.coolentQuantity, tblGenerator.ServiceDurationHours, tblGenerator.MinFuleLevelLiter, tblGenerator.CurrentMeterReading, tblGenerator.GeneratorLifeHours, tbl_Company.CompanyName AS LocationName FROM tblGenerator INNER JOIN tbl_Company ON tblGenerator.LocationID = tbl_Company.CompanyID where tblGenerator.tblGeneratorID=" + dataID[1])); break; case 13: context.Response.Write(Fn.Data2Json(@"Select tblElecticityMeterID , MeterNo from tblElecticityMeter where tbl_Company_LocationID='" + dataID[1] + "' AND MeterType='WAPDA In'")); break; case 14: context.Response.Write(Fn.Data2Json(@"Select tblElecticityMeterID , MeterNo from tblElecticityMeter where tbl_Company_LocationID='" + dataID[1] + "' AND WapdaMeterID='" + dataID[2] + "' AND MeterType='Main Meter'")); break; case 15: context.Response.Write(Fn.Data2Json(@"Select Distinct MeterPlacedAt from tblElecticityMeter Where MeterPlacedAt is not NULL AND tbl_Company_LocationID=" + dataID[1])); break; case 16: context.Response.Write(Fn.Data2Json(@"Select Distinct OwnerName from tblElecticityMeter Where OwnerName is not NULL AND tbl_Company_LocationID=" + dataID[1])); break; case 17: context.Response.Write(Fn.Data2Json(@"SELECT tblElecticityMeterReading.tblElecticityMeterReadingID, CONVERT(VARCHAR(50), tblElecticityMeterReading.dtDate, 103) AS dtDate, tblElecticityMeterReading.reading, tblElecticityMeterReading.tblElecticityMeterID, tblElecticityMeter.MeterNo, ISNULL(tblElecticityMeterReading.OffPeakReading, '0') AS OffPeakReading, ISNULL(tblElecticityMeterReading.OnPeakReading, '0') AS OnPeakReading FROM tblElecticityMeterReading INNER JOIN tblElecticityMeter ON tblElecticityMeterReading.tblElecticityMeterID = tblElecticityMeter.tblElecticityMeterID WHERE (tblElecticityMeterReading.tblElecticityMeterID = " + dataID[1] + @") and (DATEPART(MM,tblElecticityMeterReading.dtDate) = " + dataID[2].Split('-')[1] + @") AND (DATEPART(YYYY,tblElecticityMeterReading.dtDate) = " + dataID[2].Split('-')[2] + @") ORDER BY tblElecticityMeterReading.dtDate , tblElecticityMeter.MeterNo")); break; case 18: context.Response.Write(Fn.Data2Json(@"SELECT tblElecticityMeter.MeterNo, tblElecticityMeter.tblElecticityMeterID, tblElecticityMeter.MeterType, tblElecticityMeter.OwnerName, tblElecticityMeter.tbl_Company_LocationID, tblElecticityMeter.MeterReading, tblElecticityMeter.Emp_Id, tblElecticityMeter.dtDateTime, tbl_Company.CompanyName FROM tblElecticityMeter INNER JOIN tbl_Company ON tblElecticityMeter.tbl_Company_LocationID = tbl_Company.CompanyID WHERE tblElecticityMeter.tbl_Company_LocationID = " + dataID[1])); break; // case 13: //context.Response.Write(Fn.Data2Json(@"")); //break; // case 13: //context.Response.Write(Fn.Data2Json(@"")); //break; default: context.Response.Write("<p>Contents not available</p>"); break; } } catch { context.Response.ContentType = "text/HTML"; context.Response.Write("<p>Contents not available</p>"); } } }