Wednesday, 6 November 2024
Send OTP Using C# MVC5
Wednesday, 8 November 2023
Success Pending order chart
Welcome, This post will help you to make a chart for Success Pending order count datewise. This Sales chart shows the business summary of a month date-wise in just a glimpse. It takes a few seconds the get an idea of the whole month's business, It is a better choice to written business summary.
Developer Information
Database Table
Let's get Start
Google Chart
data.addRows([
[1, 0, 0],
[2, 2, 0],
[3, 0, 3],
[4, 18, 10]
]);
Requirement
with str1 as
(
select day(orderdate) as day,case when status=1 then sum(status) end as success,case when status=0 then count(status) end as pending from [Order]
group by (OrderDate),status having month(OrderDate)=month(getdate())
) select * from str1
I have saved query in CTE to output in str1 variable, which will be used output for next query.
Now we have the list of success and pending order list datewise. We have to combine this in a single row for datewise.
2. Now it is time to sum the pending and success order datewise by combining the above query output to other CTE variable str2
(
select day(orderdate) as day,case when status=1 then sum(status) end as success,case when status=0 then count(status) end as pending from [Order]
group by (OrderDate),status
having month(OrderDate)=month(getdate())
),
str2 as
(
select day,sum(success) as success,count(pending) as pending from str1 group by day,success,pending
) select * from str2
with str1 as
(
select day(orderdate) as day,case when status=1 then sum(status) end as success,case when status=0 then count(status) end as pending from [Order]
group by (OrderDate),status
having month(OrderDate)=month(getdate())
),
str2 as
(
select day,sum(success) as success,count(pending) as pending from str1 group by day,success,pending
)
select day,max(success) s,max(pending) as p from (
select day,isnull(success,'') as success,isnull(pending,'') as pending from str2 group by day,success,pending) tbl
group by day
Friday, 22 September 2023
Cart Management | C# ASP.Net MVC
Cart Management | C# ASP.Net MVC
Monday, 21 August 2023
CaptchaMvc Mvc5 | C# ASP.Net
CaptchaMvc Mvc5 Using C# ASP.Net Visual Studio 2019
CAPTCHA stands for "Completely Automated Public Turing test to tell Computers and Humans Apart". It is a test used to distinguish between humans and computers. CAPTCHAs are often used to prevent automated spam and abuse.
Thursday, 15 December 2022
FormsAuthentication C# ASP.NET MVC
FormsAuthentication
FormsAuthentication class from System.Web.Security is used to authenticate a user whether login or not. FormsAuthentication class has many functions to check the user login and it's very easy to implement. Follow the code given below
Views
<h2>Login</h2>
<form method="post">
<input type="text" name="UserName" placeholder="User Name" required /><br /><br />
<input type="password" name="Password" placeholder="Password" required /><br /><br />
<input type="submit" value="Login" />
@if
(Request.QueryString["msg"] != null)
{
<br /><br />
<span style="color:red">@Request.QueryString["msg"]</span>
}
</form>
Thursday, 10 November 2022
Make PDF from hyperlink | ASP.NET C#
This post will help you to create a PDF file from a URL in ASP.Net C#. Follow the steps given below. We will save a PDF file on the server then after viewing the PDF file, the file will be deleted.
Step 1 :
Download Select.HtmlToPdf.NetCore package from NuGet.
Goto Tools Menu>Nuget Package Manager > Manage Nuget Package for Solution
Step 2 :
Step 3
function createPDF(pageurl)
{
$.ajax({
url: '/Common/htmltopdf/',
async: true,
dataType: "json",
type: "GET",
contentType: 'application/json; charset=utf-8',
data: { url: pageurl},
success: function (data) {
DelPDF('/upload/print/' + $.trim(invid) + '.pdf');
window.location.href = '/upload/print/' + $.trim(invid) + '.pdf';
}
});
}
function DelPDF(path)
{
$.ajax({
url: '/Common/DeleteCommonFile?path=' + path,
type: "POST",
contentType: false, // Not to
set any content header
processData: false, // Not to process data
success: function (result) {
//Update Extension
if (result.sMessage == "1")
{
}
else
alert(result.sMessage);
},
error: function (abc) {
alert(abc.statusText);
}
});
}
Step 4
Controller C# code
public JsonResult htmltopdf(string url,string inv)
{
// instantiate
a html to pdf converter object
HtmlToPdf converter = new HtmlToPdf();
// create a new
pdf document converting an url
PdfDocument doc =
converter.ConvertUrl(url);
// save pdf
document
doc.Save(Server.MapPath("~/upload/print/" + inv + ".pdf"));
// close pdf
document
doc.Close();
return Json(new { sMessage = "11"}, JsonRequestBehavior.AllowGet);
}
[HttpPost]
public JsonResult DeleteCommonFile(string path)
{
try
{
string filename = Server.MapPath(path);
if (System.IO.File.Exists(filename))
{
System.IO.File.Delete(filename);
}
return Json(new {
sMessage = "1",
JsonRequestBehavior.AllowGet });
}
catch (Exception ex)
{
return Json(new {
sMessage = ex.Message, JsonRequestBehavior.AllowGet });
}
}
Monday, 12 September 2022
Aggregate Function Entity Framework C#
Sum
Get Sum of amount by a select filter using C# MVC Entity Framework
First Method
dbConnection db = new dbConnection();
int InvoiceAmount = db.Bill.Where(x => x.CID == 123).Select(i => i.Amount).Sum();
Second Method
data.Where(x => x.msg == "paid").Sum(y => Convert.ToInt32(y.Amount));
Monday, 11 July 2022
Google Recaptcha Integration | PHP , ASP.NET C# , Codeiginater 4
Monday, 23 May 2022
Multiple Condition Entity framework toList Method | ASP.Net C# MVC
Hi, This post will show you, How to apply multiple or complicated condition with Entity framwork dbContext toList method using the where clause. If you are coming first time to this post, please read my post for Entity Framework Introduction. Example of this post-based Entity Framework Introduction.
Friday, 20 May 2022
Introduction Entity Framework for Begina record display | ASP.NET MVC C#
Entity Framework (EF)
Entity Framework (EF) is developed by Microsoft which automates the database insert,Update,select and delete (CRUD) operations without manually coding. ER increase the development time because database-related task is done without long code.
This post will help you understand ER operation. This post is designed for beginners as well as experts both. Step by step instruction is given to display records from SQL Server.
Saturday, 26 February 2022
Force to Refresh Javascript and CSS files on page load
To force Javascript and CSS files on every time while page load is good practice when working on live operation because when you made any change in CSS and Javascript files then updated content reflects when cntl + f5 pressed otherwise system get file from cash to save to reload time. Given code below help you to force reload file on every page load in C# ASP.Net MVC.
@{
Random ob = new Random();
int ran = ob.Next();
}
<script src="~/AppJs/product.js?v=@
<link href="~/AppCss/gcss.css?v=@ran" rel="stylesheet" type="text/css">
Thursday, 13 January 2022
Multiple file upload by form post ASP.NET C# MVC
Multiple file upload by form post ASP.NET C# MVC
This post will let you upload multiple image files through a single form post using the C# ASP.Net MVC platform.
Key Point
- Upload multiple image files with a new name
- Save a associate record and file name will be newly created record identity field value
- No need to save the image name in the database because the file name will start with a record ID and end with a text.
- Best for putting student, employee documents without any hassle.
HTML Code :
<form method="post" enctype="multipart/form-data">
@Html.AntiForgeryToken()
<p class="m-0">
Photo
<input type="file" name="Photo" id="Photo" accept="image/x-png,image/jpeg" />
<br />
Adhaar
<input type="file" name="Adhaar" id="Adhaar" accept="image/x-png,image/jpeg" />
<br />
Pan
<input type="file" name="Pan" id="Pan" accept="image/x-png,image/jpeg" />
<br />
<input type="checkbox" id="chkconfirm" /> I
provide my consent. I will follow the Tangentweb term condition and policy.
<br /> <br />
<input type="submit" value="Save" class="button
button-primary button-wide-mobile" onclick="return filecheck()" />
</p>
</form>