Business Logic Layer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Linq;
using System.Reflection;
using System.Data.Linq.Mapping;
using System.Data.Linq.Provider;
using System.Data.Linq.SqlClient;
/// <summary>
/// Summary description for BLL_Feedback
/// </summary>
public partial class FeedBackDataContext : System.Data.Linq.DataContext
{
public FeedBackDataContext() :
base(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"].ToString())
{
}
/// <summary>
/// This Method is used for Feedback Insert
/// </summary>
/// <param name="FeedbackID"></param>
/// <param name="FeedbackName"></param>
/// <param name="FeedbackPhoneNumber"></param>
/// <param name="EmailID"></param>
/// <param name="FeedbackMessage"></param>
/// <param name="FeedbackStatus"></param>
/// <returns></returns>
[System.Data.Linq.Mapping.FunctionAttribute(Name = "dbo.USP_IUD_MST_FEEDBACK")]
public int FeedbackInsert([global::System.Data.Linq.Mapping.ParameterAttribute(Name = "Feadback_Id", DbType = "Int")] Int32 FeedbackID, [System.Data.Linq.Mapping.ParameterAttribute(Name = "Feedback_Name", DbType = "Varchar(250)")] string FeedbackName, [global::System.Data.Linq.Mapping.ParameterAttribute(Name = "feedback_Phone", DbType = "VarChar(15)")] string FeedbackPhoneNumber, [global::System.Data.Linq.Mapping.ParameterAttribute(Name = "Email_id", DbType = "VarChar(150)")] string EmailID, [global::System.Data.Linq.Mapping.ParameterAttribute(Name = "Feedback_Message", DbType = "VarChar(8000)")] string FeedbackMessage, [global::System.Data.Linq.Mapping.ParameterAttribute(Name = "Feedback_Status", DbType = "bit")] bool FeedbackStatus, [global::System.Data.Linq.Mapping.ParameterAttribute(Name = "IUD", DbType = "Char(1)")] string ActionType,
[global::System.Data.Linq.Mapping.ParameterAttribute(Name = "FeedbackPartner", DbType = "varchar(50)")] string FeedbackPartner,
[global::System.Data.Linq.Mapping.ParameterAttribute(Name = "addrs", DbType = "varchar(500)")] string address
)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), FeedbackID, FeedbackName, FeedbackPhoneNumber, EmailID, FeedbackMessage, FeedbackStatus, ActionType, FeedbackPartner, address);
return ((int)(result.ReturnValue));
}
public Table<FeedbackMasterDislay> GetFeedback
{
get
{
return GetTable<FeedbackMasterDislay>();
}
}
}
[Table(Name = "MST_FEEDBACK")]
public class FeedbackMasterDislay
{
[Column(IsPrimaryKey = true, Name = "Feadback_Id", DbType = "Int", IsDbGenerated = true)]
public int Feadback_Id { set; get; }
[Column(Name = "Feedback_Name",DbType="Varchar(250)")]
public string Feedback_Name { set; get; }
[Column(Name = "feedback_Phone", DbType = "Varchar(15)")]
public string feedback_Phone { set; get; }
[Column(Name = "Email_id", DbType = "Varchar(150)")]
public string Email_id { set; get; }
[Column(Name = "Feedback_Message", DbType = "Varchar(8000)")]
public string Feedback_Message { set; get; }
[Column(Name = "Feedback_Status", DbType = "bit")]
public bool Feedback_Status { set; get; }
[Column(Name = "FeedbackDateTime", DbType = "Datetime")]
public DateTime FeedbackDateTime { set; get; }
[Column(Name = "FeedbackPartner", DbType = "varchar(50)")]
public string FeedbackPartner { set; get; }
[Column(Name = "addrs", DbType = "varchar(500)")]
public string Address { set; get; }
}
---------------------------------------------------------
View Part
<%@ Page Title="Feedback View" Language="C#" MasterPageFile="~/View/Admin/Admin.master" AutoEventWireup="true" CodeFile="FeedbackMaster.aspx.cs" Inherits="View_Admin_Portal_Feedbackview" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<link href="../css/GridView.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<fieldset class="basic_d" style="width:90%">
<legend>Feedback View</legend>
<asp:GridView ID="grdFeedback" DataKeyNames="Feadback_Id"
AllowSorting="true" AllowPaging="true" PageSize="20"
PagerSettings-PageButtonCount="5" PagerSettings-Mode="Numeric"
runat="server" CssClass="Grid"
AutoGenerateColumns="false" EmptyDataText="Record not found" ShowHeaderWhenEmpty="true"
Width="100%" OnRowDeleting="grdBankMaster_RowDeleting"
onpageindexchanging="grdFeedback_PageIndexChanging"
onrowcommand="grdFeedback_RowCommand" >
<Columns>
<asp:TemplateField HeaderText="Sl. No.">
<ItemTemplate>
<%# (grdFeedback.PageSize * grdFeedback.PageIndex) + (Container.DisplayIndex + 1)%>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:BoundField DataField="Feedback_Name" HeaderText="Name." HeaderStyle-HorizontalAlign="Left">
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="feedback_Phone" NullDisplayText="N/A" HeaderText="Phone." HeaderStyle-HorizontalAlign="Left">
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="Address" HeaderText="Address" NullDisplayText="N/A" HeaderStyle-HorizontalAlign="Left">
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField HeaderText="Date" DataField="FeedbackDateTime" DataFormatString="{0:dd/MM/yyyy}" NullDisplayText="N/A" />
<asp:BoundField DataField="Feedback_Message" ItemStyle-Wrap="true" HeaderText="Message." NullDisplayText="N/A" HeaderStyle-HorizontalAlign="Left">
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:TemplateField HeaderText="Reply">
<ItemTemplate>
<asp:LinkButton ID="lnbReply" CommandName="reply" CommandArgument='<%#Eval("Email_Id") %>' runat="server" Text="Reply"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Action">
<ItemTemplate>
<asp:ImageButton ID="lnkDelete" ImageUrl="~/View/Admin/images/delete.gif" CommandName="Delete" OnClientClick="return confirm('Are you sure to delete this record ?')" runat="server" Text="Delete" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle CssClass="paging" HorizontalAlign="Center" />
</asp:GridView>
<asp:Panel ID="pnl_show" style="margin:0 auto;width:400px;" runat="server" Visible="false" >
Email: <asp:Label ID="lbl_email" runat="server" ></asp:Label>
<asp:TextBox ID="txtReply" ValidationGroup="aa" placeholder="Reply your Feedback Message" runat="server" TextMode="MultiLine" Height="200px" Width="400px" ></asp:TextBox>
<asp:Button ID="btn_submit" runat="server" ValidationGroup="aa" CssClass="btn btn-primary" Text="Reply"
onclick="btn_submit_Click" />
<asp:RequiredFieldValidator ID="reqReply" ValidationGroup="aa" runat="server" ControlToValidate="txtReply" ErrorMessage="Message Field cannot be empty" Display="Dynamic" SetFocusOnError="true" ForeColor="Red" ></asp:RequiredFieldValidator>
</asp:Panel>
</fieldset>
</asp:Content>
-----------------------------------------
aspx.cs File
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class View_Admin_Portal_Feedbackview : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ShowFeedback();
}
}
private void ShowFeedback()
{
try
{
FeedBackDataContext fdback = new FeedBackDataContext();
var res = from m in fdback.GetFeedback
where m.Feedback_Status == true
select m;
grdFeedback.DataSource = res;
grdFeedback.DataBind();
}
catch (Exception ee)
{
LuminiousAlert.JavaScript.Alert(ee.Message);
}
}
protected void grdBankMaster_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
try
{
int DataKey = Convert.ToInt32(grdFeedback.DataKeys[e.RowIndex].Value.ToString());
FeedBackDataContext bl = new FeedBackDataContext();
var result = bl.GetFeedback.Single(m => m.Feadback_Id == DataKey);
bl.GetFeedback.DeleteOnSubmit(result);
bl.SubmitChanges();
}
catch (Exception ee)
{
ExceptionHandler.WriteException(ee.Message);
}
finally
{
}
ShowFeedback();
}
protected void grdFeedback_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
grdFeedback.PageIndex = e.NewPageIndex;
ShowFeedback();
}
protected void grdFeedback_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("reply"))
{
pnl_show.Visible = true;
lbl_email.Text = e.CommandArgument.ToString();
}
}
protected void btn_submit_Click(object sender, EventArgs e)
{
bool b = LuminousMail.EmailHelper.SendEmail(lbl_email.Text, "Feedback Reply", txtReply.Text);
if (b)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "MSG", "alert('Reply your Feedback Sucessfully');", true);
pnl_show.Visible = false;
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "MSG", "alert('Invalid Email Address');", true);
pnl_show.Visible = false;
}
}
}
reference:- https://www.c-sharpcorner.com/UploadFile/3d39b4/simple-select-insert-update-and-delete-using-linq-to-sql/
https://www.c-sharpcorner.com/article/an-overview-of-linq-to-sql/
No comments:
Post a Comment