Showing posts with label C#.. Show all posts
Showing posts with label C#.. Show all posts

Tuesday, 11 July 2023

Accelerate Your Business with Expert ASP.NET MVC Application Development Services

Introduction: In today's digitally-driven world, businesses need a strong online presence to stay competitive. If you're looking to enhance your brand's visibility, engage customers, and streamline your operations, a powerful ASP.NET MVC application can be a game-changer. In this blog post, we'll delve into the benefits of ASP.NET MVC development and showcase how Mozammal, a seasoned web development expert, can help you unlock the full potential of this technology through their exceptional services on Fiverr.
đŸŽ¯ #ASPNET #MVC #WebDevelopment #FiverrGig 🚀 1. Harness the Power of ASP.NET MVC: ASP.NET MVC is a versatile and robust framework that empowers businesses to build scalable, secure, and high-performing web applications. It allows for clean separation of concerns, making maintenance and testing a breeze. By leveraging ASP.NET MVC, you can develop dynamic, feature-rich web applications tailored to your specific business needs. 2. Meet Mozammal: Your Expert ASP.NET MVC Developer: When it comes to ASP.NET MVC application development, Mozammal is a trusted professional who excels in creating innovative and custom solutions. With a proven track record and extensive experience, Mozammal possesses the skills and expertise needed to transform your vision into a reality. Their Fiverr Gig offers a range of services to meet your unique requirements, delivering top-notch results that propel your business forward. 👨‍đŸ’ģ Expert Developer | Custom ASP.NET MVC Solutions | Fiverr Seller | Satisfaction Guaranteed 👍
3. Customized Solutions for Your Business: Mozammal understands that every business has distinct needs. Whether you require an e-commerce platform, a customer relationship management system, or a content management solution, Mozammal's ASP.NET MVC application development services can be tailored to meet your specific goals. By collaborating closely with you, they ensure that the end product aligns perfectly with your vision and drives tangible results. 4. Unleash Innovation with Cutting-Edge Features: Mozammal stays up to date with the latest trends and technologies in the web development landscape. By leveraging their expertise in ASP.NET MVC, they can incorporate cutting-edge features into your web application. From real-time updates using SignalR to seamless integration with social media platforms, Mozammal has the know-how to make your application stand out from the competition and keep your users engaged. 💡 Innovative Features | Real-Time Updates with SignalR | Social Media Integration 🌟 5. Seamless User Experience and Responsive Design: In today's mobile-dominated world, user experience is paramount. Mozammal's proficiency in creating intuitive user interfaces and implementing responsive design ensures that your application looks and performs flawlessly across all devices. By optimizing the user experience, Mozammal helps you engage and retain customers, ultimately driving conversions and boosting your bottom line. 📱 Responsive Design | Intuitive User Interfaces | Enhanced User Experience 🌐 6. Agile Development Process and Timely Delivery: Mozammal follows an agile development process, ensuring efficient project management and seamless collaboration. They provide regular updates on the progress of your application, incorporating feedback along the way to ensure that the end product exceeds your expectations. With a commitment to timely delivery, Mozammal ensures that your project is completed within the agreed-upon timeframe, enabling you to seize new opportunities without delay. ⌛ Agile Development | Timely Delivery | Efficient Project Management ⚡ Conclusion: If you're seeking an exceptional ASP.NET MVC application development service, Mozammal is the expert you can rely on. With their comprehensive expertise, personalized approach, and dedication to delivering outstanding results, Mozammal stands out in the competitive landscape of web development on Fiverr. By choosing Mozammal, you unlock the potential of ASP.NET MVC, accelerating your business growth, and positioning yourself for success in the digital realm. Don't miss out on this opportunity to transform your vision into a reality with Mozammal's exceptional ASP.NET MVC development services. Visit their Fiverr Gig today at [link](https://www.fiverr.com/mozammal/do-asp-dot-net-mvc-application) to get started on your journey to online excellence. đŸ’ģ Unlock Your Business Potential | Exceptional ASP.NET MVC Development | [Visit Mozammal's Fiverr Gig Today!] đŸ’ŧ


Tuesday, 14 February 2017

DataGridview Duplicate Data Remove in C#

        public void RemoveDuplicate(DataGridView grv)
        {
            for (int currentRow = 0; currentRow < grv.Rows.Count - 1; currentRow++)
            {
                DataGridViewRow rowToCompare = grv.Rows[currentRow];

                for (int otherRow = currentRow + 1; otherRow < grv.Rows.Count; otherRow++)
                {
                    DataGridViewRow row = grv.Rows[otherRow];

                    bool duplicateRow = true;

                    for (int cellIndex = 0; cellIndex < row.Cells.Count; cellIndex++)
                    {
                        if (!rowToCompare.Cells[cellIndex].Value.Equals(row.Cells[cellIndex].Value))
                        {
                            duplicateRow = false;
                            break;
                        }
                    }

                    if (duplicateRow)
                    {
                        grv.Rows.Remove(row);
                        otherRow--;
                    }
                }
          }
}
           
         

Tuesday, 30 August 2016

MVC5 CRUD OPERATION STEP BY STEP

Step 1:
Create a Model class———-
public class Booking
{
public virtual int Id { get; set; }
public virtual string HallName { get; set; }
public virtual DateTime bookDate { get; set; }
public virtual string fromtime { get; set; }
public virtual string toTime { get; set; }
public virtual int people { get; set; }
public virtual string status { get; set; }
}
public class ResultObject
{
public int ResultID { get; set; }
public string ResultMessage { get; set; }
public Object Obj { get; set; }
public string Code { get; set; }
}
public class PagedBookingModel
{
public int TotalRows { get; set; }
public IEnumerable Booking { get; set; }
public int PageSize { get; set; }
}
Step 2: Create a Contex of EntityFrmework to access database–
public class BookHallContext : DbContext
{
public BookHallContext() : base(“name=BookHallContext”)
{
}
public System.Data.Entity.DbSet Bookings { get; set; }
}
Step 3: Create a dataAccess Layer—————–
public class BookDataAccess
{
public BookDataAccess() { }
public BookHallContext db = new BookHallContext();
//public DataTable GetDataTable(string commandText)
//{
// // get a configured DbCommand object
// DbCommand comm = GenericDataAcccess.CreateCommand();
// // set the stored procedure name
// comm.CommandText = commandText;
// // execute the stored procedure and return the results
// return GenericDataAcccess.ExecuteSelectCommand(comm);
//}
public IEnumerable GetBookingPage(int pageNumber, int pageSize, string searchCriteria)
{
if (pageNumber m.HallName)
.Skip((pageNumber – 1) * pageSize)
.Take(pageSize)
.ToList();
}
public int CountAllHall()
{
return db.Bookings.Count();
}
public void Dispose()
{
db.Dispose();
}
public Booking GetBookingDetail(int mCustID)
{
return db.Bookings.Where(m => m.Id == mCustID).FirstOrDefault();
}
public bool AddBooking(Booking book)
{
try
{
db.Bookings.Add(book);
db.SaveChanges();
return true;
}
catch (Exception ex)
{
return false;
}
}
public bool UpdateEmployee(Booking bk)
{
try
{
Booking data = db.Bookings.Where(m => m.Id ==bk.Id).FirstOrDefault();
data.HallName = bk.HallName;
data.bookDate = bk.bookDate;
data.fromtime = bk.fromtime;
data.toTime = bk.toTime;
data.people = bk.people;
db.SaveChanges();
return true;
}
catch (Exception mex)
{
return false;
}
}
public bool DeleteBooking(int mCustID)
{
try
{
Booking data = db.Bookings.Where(m => m.Id == mCustID).FirstOrDefault();
db.Bookings.Remove(data);
db.SaveChanges();
return true;
}
catch (Exception mex)
{
return false;
}
}
public ResultObject InsertBookInfo(Booking binfo)
{
string error;
ResultObject resObj = new ResultObject();
SqlConnection con = new SqlConnection(GlobalClass.connection);
SqlCommand cmd = new SqlCommand(“”, con);
cmd.CommandType = CommandType.Text;
con.Open();
cmd.CommandText = @”Insert into Bookings( bookDate,HallName,fromtime,toTime,people) Values(‘” + (binfo.bookDate).ToString(“yyyy/MM/dd”) + “‘,'” + binfo.HallName + “‘,'” + binfo.fromtime + “‘,'” + binfo.toTime + “‘,'” + binfo.people + “‘)”;
int result = -1;
try
{
result = cmd.ExecuteNonQuery();
}
catch
{
result = -1;
}
resObj.ResultID = result;
if (result > 0)
{
resObj.ResultMessage = “Data Saved Successfully”;
resObj.Obj = GetBookingInfoList();
}
else
{
resObj.ResultMessage = “Data Not Saved”;
}
con.Close();
return resObj;
}
public ResultObject UpdateBookInfo(Booking binfo)
{
string error;
ResultObject resObj = new ResultObject();
SqlConnection con = new SqlConnection(GlobalClass.connection);
SqlCommand cmd = new SqlCommand(“”, con);
cmd.CommandType = CommandType.Text;
con.Open();
cmd.CommandText = @”Update Bookings set bookDate='” + binfo.bookDate.ToString(“yyyy/MM/dd”) + “‘,HallName='” + binfo.HallName + “‘,fromtime='” + binfo.fromtime + “‘,toTime='” + binfo.toTime + “‘,people='” + binfo.people + “‘ where Id='”+binfo.Id+”‘)”;
int result = -1;
try
{
result = cmd.ExecuteNonQuery();
}
catch
{
result = -1;
}
resObj.ResultID = result;
if (result > 0)
{
resObj.ResultMessage = “Data Updated Successfully”;
resObj.Obj = GetBookingInfoList();
}
else
{
resObj.ResultMessage = “Data Not Saved”;
}
con.Close();
return resObj;
}
public List GetBookingInfoList()
{
List objList = new List();
DataTable dt = GetAllBookingInfo();
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
objList.Add(new Booking
{
Id = int.Parse(dt.Rows[i]["Id"].ToString()),
bookDate = Convert.ToDateTime(dt.Rows[i]["bookDate"]),
fromtime = dt.Rows[i]["fromtime"].ToString(),
toTime = dt.Rows[i]["toTime"].ToString(),
HallName = dt.Rows[i]["HallName"].ToString(),
people = Int32.Parse(dt.Rows[i]["people"].ToString())
});
}
}
return objList;
}
public DataTable GetAllBookingInfo()
{
DataTable tbl = new DataTable();
SqlConnection con = new SqlConnection(GlobalClass.connection);
SqlCommand cmd = new SqlCommand("", con);
cmd.CommandType = CommandType.Text;
cmd.CommandText = @"Select Id,bookDate,HallName,fromtime,toTime,people from Bookings";
SqlDataAdapter adp = new SqlDataAdapter(cmd);
adp.Fill(tbl);
return tbl;
}
Step 4: Create a Controller
public class BookingController : Controller
{
public BookHallContext db = new BookHallContext();
// GET: /Booking/
public ActionResult Index()
{
ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
return View();
}
// GET: /Booking/Details/5
public ActionResult LoadBookInfo()
{
BookDataAccess acess = new BookDataAccess();
return Json(acess.GetBookingInfoList());
}
public ActionResult InsertBookInfo(Booking obj)
{
BookDataAccess acess = new BookDataAccess();
return Json(acess.InsertBookInfo(obj));
}
public ActionResult UpdateBookInfo(Booking obj)
{
BookDataAccess acess = new BookDataAccess();
return Json(acess.UpdateBookInfo(obj));
}
}
Step 5: Create a view—————–
@{
//WebGrid grid = new WebGrid(rowsPerPage: Model.PageSize);
//grid.Bind(Model.Bookings,
// autoSortAndPage: false,
// rowCount: Model.TotalRows
//);
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
$(document).ready(function () {
// alert(“ok”);
$(“#dvLoading”).hide();
LoadInfo();
$(“#btnSave”).click(function () {
$(“#dvLoading”).dialog();
$(“#lblInfo”).html(”);
var bookInfo = {
“HallName”: $(“#txtHallName”).val(),
“bookDate”: $(“#txtbookDate”).val(),
“fromtime”: $(“#txtfromtime”).val(),
“toTime”: $(“#txttoTime”).val(),
“people”: $(“#txtPeople”).val(),
“Id”: $(“#txtId”).val()
};
var Method = ”;
if ($(“#btnSave”).val() == ‘Update’) {
Method = “UpdateBookInfo”;
}
else {
Method = “InsertBookInfo”;
}
$.ajax({
type: “post”,
url: “/Booking/” + Method,
dataType: “JSON”,
contentType: “application/json;charset=utf-8”,
data: JSON.stringify({ “obj”: bookInfo }),
//data: JSON.stringify({ “_pinfo”: patientInfo }),
success: function (response) {
$(“#dvLoading”).hide();
// var response = data.d;
//
if (response.ResultID != ‘-1’) {
$(“#lblInfo”).html(‘‘ + response.ResultMessage + ‘‘);
ClearField();
BindTable(response.Obj);
$(“#btnSave”).val(“Save”);
}
else {
$(“#lblInfo”).html(‘‘ + response.Code + ‘‘);
}
},
error: function (a, b, c) {
$(“#dvLoading”).hide();
alert(a + ‘..’ + c.statusCode);
}
});
});
function LoadInfo() {
// alert(“Load info mcalled”);
$(“#dvLoading”).show();
$.ajax({
type: “POST”,
url: “/Booking/LoadBookInfo”,
contentType: ‘application/json; charset=utf-8’,
dataType: ‘json’,
cache: false,
success: function (result) {
$(“#dvLoading”).hide();
//var response = result.d;
BindTable(result)
// console.log(response);
},
error: function (xhr, textStatus, errorThrown) {
$(“#dvLoading”).hide();
// alert(xhr.responseText);
alert((“Error thrown ” + errorThrown + “Status: ” + xhr.status));
console.log(xhr + textStatus + errorThrown);
}
});
}
function BindTable(data) {
$(“#tbldata tr:gt(0)”).remove();
var content = ”;
$.each(data, function (i, quality) {
content += ‘
‘ + quality.HallName + ‘ ‘ + quality.bookDate + ‘ ‘ + quality.fromtime + ‘ ‘ + quality.toTime + ‘ ‘ + quality.people + ‘ ‘ + quality.status + ‘ ‘ + quality.Id + ‘
‘;
});
console.log(content);
$(“#tbldata”).append(content);
}
$(“#tbldata”).on(‘click’, “tr:gt(0)”, function () {
var url = $(this).attr(‘href’);
$(“#popdialog”).dialog({
title: ‘Add New Booking’,
autoOpen: false,
resizable: false,
height: 500,
width: 400,
show: { effect: ‘drop’, direction: “up” },
modal: true,
draggable: true,
open: function (event, ui) {
$(this).load(url);
//alert(Id);
},
close: function (event, ui) {
$(this).dialog(‘close’);
}
});
var Id = $(this).find(“td:eq(6)”).text();
$(“#txtHallName”).val($(this).find(“td:eq(0)”).text());
$(“#txtbookDate”).val($(this).find(“td:eq(1)”).text());
$(“#txtfromtime”).val($(this).find(“td:eq(2)”).text());
$(“#txttoTime”).val($(this).find(“td:eq(3)”).text());
$(“#txtpeople”).val($(this).find(“td:eq(4)”).text());
$(“#txtId”).val($(this).find(“td:eq(6)”).text());
$(“#btnSave”).val(“Update”);
$(“#popdialog”).dialog(‘open’);
return false;
});
function ClearField() {
$(“#txtHallName”).val(”),
$(“#txtbookDate”).val(”),
$(“#txtfromtime”).val(”),
$(“txttoTime”).val(”),
$(“#txtpeople”).val(”),
$(“#txtId”).val(”)
}
});
.CSSTableGenerator {
margin: 0px;
padding: 0px;
width: 100%;
border: 1px solid #000000;
}
.CSSTableGenerator table {
border-collapse: collapse;
border-spacing: 0;
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
}
.CSSTableGenerator tr:nth-child(odd) {
background-color: #aad4ff;
}
.CSSTableGenerator tr:nth-child(even) {
background-color: #ffffff;
}
.CSSTableGenerator td {
vertical-align: middle;
border: 1px solid #000000;
border-width: 0px 1px 1px 0px;
text-align: left;
padding: 4px;
font-size: .8em;
font-family: Arial;
font-weight: normal;
}
.CSSTableGenerator tr:last-child td {
border-width: 0px 1px 0px 0px;
}
.CSSTableGenerator tr td:last-child {
border-width: 0px 0px 1px 0px;
}
.CSSTableGenerator tr:last-child td:last-child {
border-width: 0px 0px 0px 0px;
}
.CSSTableGenerator tr:first-child td {
background-color: #005fbf;
border: 0px solid #000000;
text-align: center;
border-width: 0px 0px 1px 1px;
font-size: .8em;
font-family: Arial;
font-weight: bold;
color: #ffffff;
}
.CSSTableGenerator tr:first-child td:first-child {
border-width: 0px 0px 1px 0px;
}
.CSSTableGenerator tr:first-child td:last-child {
border-width: 0px 0px 1px 1px;
}
@*
Please wait.......
*@
HallName
BookDate
From Time
To Time
People
ID
HallNameBookDateFromTimeToTimePeopleID
$(document).ready(function () {
$(“.inputdate”).datepicker({ dateFormat: “yy-mm-dd” });
// $(“.inputtime”).timespinner();
});
====================================File Upload=========================================
public class NewsController : Controller
{
private WebAppDb db = new WebAppDb();
//
// GET: /News/
public ActionResult Index()
{
var post = db.Posts.OrderByDescending(d => d.PublishDate);
return View(post.ToList());
}
//
// GET: /News/List/
[Authorize]
public ActionResult List()
{
var post = db.Posts.OrderByDescending(d => d.PublishDate);
return View(post.ToList());
}
//
// GET: /News/Create/
[Authorize]
public ActionResult Create()
{
return View();
}
[Authorize]
[HttpPost]
public ActionResult Create(BlogPost newpost, HttpPostedFileBase file)
{
if(file != null && file.ContentLength > 0){
string GetFileName = Path.GetFileName(file.FileName);
var ServerPath = Path.Combine(Server.MapPath(“~/Content/Uploads/”), file.FileName);
file.SaveAs(ServerPath);
newpost.Image = “/Content/Uploads/” + file.FileName;
}
if(ModelState.IsValid){
db.Posts.Add(newpost);
db.SaveChanges();
return RedirectToAction(“List”);
}
return View(newpost);
}
//
// GET: /News/Edit/
[Authorize]
public ActionResult Edit(int id = 0)
{
var post = db.Posts.Find(id);
return View(post);
}
[Authorize]
[HttpPost]
public ActionResult Edit(BlogPost post, HttpPostedFileBase file)
{
if (file != null && file.ContentLength > 0)
{
string GetFileName = Path.GetFileName(file.FileName);
var ServerPath = Path.Combine(Server.MapPath(“~/Content/Uploads/”), file.FileName);
file.SaveAs(ServerPath);
post.Image = “/Content/Uploads/” + file.FileName;
}
if (ModelState.IsValid)
{
db.Entry(post).State = System.Data.EntityState.Modified;
db.SaveChanges();
return RedirectToAction(“List”);
}
return View(post);
}
//
// GET: /News/Delete/
[Authorize]
public ActionResult Delete(int id = 0)
{
BlogPost post = db.Posts.Find(id);
if(post == null){
return HttpNotFound();
}
return View(post);
}
[Authorize]
[HttpPost, ActionName(“Delete”)]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id = 0)
{
BlogPost post = db.Posts.Find(id);
db.Posts.Remove(post);
db.SaveChanges();
return RedirectToAction(“List”);
}
}
Create——————————————————————-
@model NGO_Project.Models.BlogPost
@{
ViewBag.Title = “Create News”;
Layout = “~/Views/Shared/_LayoutAdmin.cshtml”;
}
@*@section Sidebar{

  • @Html.ActionLink(“Back to List”, “list”)

  • }*@
    @using (Html.BeginForm(“Create”, “News”,FormMethod.Post, new { @class = “col-md-10 center-margin”, enctype = “multipart/form-data” }))
    {
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
    @Html.LabelFor(model => model.Title)
    @Html.EditorFor(model => model.Title)
    @Html.ValidationMessageFor(model => model.Title, null, new { @class = “parsley-error-list” })
    @Html.LabelFor(model => model.Image)



    @Html.LabelFor(model => model.Description)
    @Html.TextAreaFor(model => model.Description, new { @class = “textarea-no-resize”, style = “margin: 0px; height: 200px;” })
    @Html.ValidationMessageFor(model => model.Description, null, new { @class = “parsley-error-list” })
    @Html.HiddenFor(model => model.PublishDate, new { Value = @DateTime.Now })
    }
    @section Scripts {
    @Scripts.Render(“~/bundles/jqueryval”)
    }
    Edit————————————————————————————-
    @model NGO_Project.Models.BlogPost
    @{
    ViewBag.Title = “Edit News”;
    Layout = “~/Views/Shared/_LayoutAdmin.cshtml”;
    }
    @using (Html.BeginForm(“Edit”, “News”,FormMethod.Post, new { @class = “col-md-10 center-margin”, enctype = “multipart/form-data” }))
    {
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
    @Html.LabelFor(model => model.Title)
    @Html.EditorFor(model => model.Title)
    @Html.ValidationMessageFor(model => model.Title, null, new { @class = “parsley-error-list” })
    @Html.LabelFor(model => model.Image)



    @Html.LabelFor(model => model.Description)
    @Html.TextAreaFor(model => model.Description, new { @class = “textarea-no-resize”, style = “margin: 0px; height: 200px;” })
    @Html.ValidationMessageFor(model => model.Description, null, new { @class = “parsley-error-list” })
    @Html.HiddenFor(model => model.Image, new { Value = @Model.Image })
    @Html.HiddenFor(model => model.PublishDate)
    }
    @section Scripts {
    @Scripts.Render(“~/bundles/jqueryval”)
    }
    —————————————————————–Delete————————————-
    @model NGO_Project.Models.BlogPost
    @{
    ViewBag.Title = “Delete”;
    ViewBag.Subheading = “Are you sure you want to delete this?”;
    Layout = “~/Views/Shared/_LayoutAdmin.cshtml”;
    }
    @using (Html.BeginForm(“Delete”, “News”,FormMethod.Post, new { @class = “col-md-10 center-margin” }))
    {
    @Html.AntiForgeryToken()
    @Html.LabelFor(model => model.Title)
    @Html.DisplayFor(model => model.Title)
    @Html.LabelFor(model => model.PublishDate)
    @Html.DisplayFor(model => model.PublishDate)
    @Html.LabelFor(model => model.Image)
    @Html.LabelFor(model => model.Description)
    @Html.DisplayFor(model => model.Description)
    }
    Index———————————————————————-
    @model IEnumerable
    @{
    ViewBag.Title = “News | NGO Web App”;
    ViewBag.Page = “News”;
    }
    @foreach (var item in Model)
    {

    @Html.DisplayFor(modelItem => item.Title)

    @Html.DisplayFor(modelItem => item.PublishDate) @if (item.Image != null)
    { item.Image)” alt=”Image” width=”113″>}
    @Html.Raw(item.Description)

    Tuesday, 23 August 2016

    Implement “WebAPI” in Asp.NET MVC

    How to implement “WebAPI” in MVC?
    Below are the steps to implement "webAPI" :-Step1:-Create the project using the "WebAPI" template.


    Comments system

    Advertising

    Disqus Shortname