Thursday 23 February 2012

DOC




Draft Details
//////////

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Swash.BusinessLayer;
using Swash.Objects;

namespace Website.ERP.AMS
{
    public partial class ServiceRequisitionDraftDetails : System.Web.UI.Page
    {
        #region for global variable Declaration
        int empId=36;
        #endregion for global variable Declaration
        #region Events
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                GetServiceDraftDetails();
            }
        }
     
        protected void GridViewDraftDetails_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "View")
            {
                ViewState["tmpdata"] = null;
                Response.Redirect("ServiceRequisitionDraftView.aspx?draftId=" + e.CommandArgument.ToString(), "_blank", "menubar=0,width=600,height=500,status=yes,toolbar=no,location=no,scrollbars=yes,resizable=no,titlebar=no");
            }
        }

        protected void ImgBack_Click(object sender, ImageClickEventArgs e)
        {
            Back();
        }
        public void Back()
        {
            Response.Redirect("ServiceRequisitionEntry.aspx");
        }

        protected void GridViewDraftDetails_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GetServiceDraftDetails();
        }

        protected void ImgBtnBack_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("ServiceRequisitionDetails.aspx");
        }
        #endregion Events

        #region Method
        public void GetServiceDraftDetails()
        {
            List<AMS_ServiceRequisition> draftDetails = new List<AMS_ServiceRequisition>();
            if (ViewState["tmpdata"] == null)
            {
                draftDetails = ERPManagement.GetInstance.GetServiceDraftDetails(empId);
                ViewState["tmpdata"] = draftDetails;
            }
            else
            {
                draftDetails = (List<AMS_ServiceRequisition>)ViewState["tmpdata"];
            }
            GridViewDraftDetails.DataSource = draftDetails;
            GridViewDraftDetails.DataBind();
        }
        #endregion

     
    }
}
-------
Design
-------
<div class ="PlaceButton">
 <asp:ImageButton ID="ImgBtnBack" ImageUrl="~/images/back.jpg" runat="server"
            onclick="ImgBtnBack_Click" />
</div>

<div class ="GridDiv">
    <asp:GridView ID="GridViewDraftDetails" runat="server"
        AutoGenerateColumns="false" CssClass="GridViewDefault" AllowPaging="True"
        onrowcommand="GridViewDraftDetails_RowCommand"
        onpageindexchanging="GridViewDraftDetails_PageIndexChanging">
              <Columns>
               <asp:TemplateField  Visible="false">
                    <ItemTemplate>
                        <asp:Label ID="lblRequestNo" runat="server" Text='<%#Eval("RequestNo")%>'></asp:Label>  
                    </ItemTemplate>
                    </asp:TemplateField>
           <asp:BoundField DataField="RequestDate" HeaderText="RequestDraftDate" />
           <asp:BoundField DataField="NoOfItem" HeaderText="NoOfService" />
           <asp:TemplateField>
                <ItemTemplate>
                    <asp:LinkButton ID="LnkDraftView" Text="View" runat="server" CommandName="View" CommandArgument='<%#Eval("RequestNo") %>'>View</asp:LinkButton>
                  </ItemTemplate>
            </asp:TemplateField >
               </Columns>
    </asp:GridView>
   
    </div>
</div>
</asp:Content>

namespace Swash.BusinessLayer
{
    public partial class ERPManagement
    {
        #region Retrive Service Draft
        public List<AMS_ServiceRequisition> GetServiceDraftDetails(int empId)
        {
            string Context = "ERPManagement.GetServiceDraftDetails";
            try
            {
                return ERPCache.GetServiceDraftDetails(empId);
            }
            catch (System.Exception ex)
            {
                throw (new Exception(Context, ex));
            }
        }

        public List<AMS_ServiceRequisition> GetAllServiceDraft(int  draftId)
        {
            string Context = "ERPManagement.GetAllServiceDraft";
            try
            {
                return ERPCache.GetAllServiceDraft(draftId);
            }
            catch (System.Exception ex)
            {
                throw (new Exception(Context, ex));
            }
        }
namespace Swash.CacheLayer
{
    public partial class ERPCache
    {
        #region Retrive Service Draft
        public static List<AMS_ServiceRequisition> GetServiceDraftDetails(int empId)
        {
            return ERPIntegration.GetServiceDraftDetails(empId);
        }
        public static List<AMS_ServiceRequisition> GetAllServiceDraft(int draftId)
        {
            return ERPIntegration.GetAllServiceDraft(draftId);
        }
namespace Swash.IntegrationLayer
{
    public partial class ERPIntegration
    {
        #region Retrive ServiceDraft Record
        public static List<AMS_ServiceRequisition> GetServiceDraftDetails(int empId)
        {
            List<AMS_ServiceRequisition> ListserviceDraft = new List<AMS_ServiceRequisition>();
            DataTable dtDraft = new DataTable();
            dtDraft = ERPDataAccess.GetInstance.GetServiceDraftDetails(empId);
            foreach (DataRow dr in dtDraft.Rows)
            {
                AMS_ServiceRequisition objservice = new AMS_ServiceRequisition();

                objservice.RequestNo = int.Parse(dr["RequestNo"].ToString());

                objservice.RequestDate = dr["RequestDate"].ToString();
                objservice.NoOfItem = int.Parse(dr["NoOfItem"].ToString());

                ListserviceDraft.Add(objservice);
            }
            return ListserviceDraft;
        }

        public static List<AMS_ServiceRequisition> GetAllServiceDraft(int draftId)
        {
            List<AMS_ServiceRequisition> listServiceDraft = new List<AMS_ServiceRequisition>();
            DataTable dtServiceDraft = new DataTable();
            dtServiceDraft = ERPDataAccess.GetInstance.GetAllServiceDraft(draftId);
            foreach (DataRow dr in dtServiceDraft.Rows)
            {
                AMS_ServiceRequisition objServiceDraft = new AMS_ServiceRequisition();
                objServiceDraft.RequisitionDetailsId = int.Parse(dr["RequisitionDetailsId"].ToString());
                objServiceDraft.RequestId = int.Parse(dr["RequestId"].ToString());
                objServiceDraft.AssetTagNo = dr["AssetTagNo"].ToString();
                objServiceDraft.AssetName = dr["AssetName"].ToString();
                objServiceDraft.RequestDate = dr["RequestDate"].ToString();
                objServiceDraft.RequestPurpose = dr["RequestPurpose"].ToString();
                objServiceDraft.RelatedProblem = dr["RelatedProblem"].ToString();
                objServiceDraft.Priority = dr["Priority"].ToString();
                objServiceDraft.DateOfRequirement = dr["RequirementDate"].ToString();
                objServiceDraft.Purpose  = dr["Purpose"].ToString();
                listServiceDraft.Add(objServiceDraft);
            }
            return listServiceDraft;
        }
namespace Swash.DataAccessLayer
{
    public partial class ERPDataAccess
    {
        public DataTable GetServiceDraftDetails(int empId)
        {
            DataTable dt = new DataTable();
            DataTable returndt = new DataTable();
            returndt.Columns.Add("RequestNo");
            returndt.Columns.Add("RequestDate");
            returndt.Columns.Add("NoOfItem");

            SqlCommand getRequestCommand = new SqlCommand("ams.AMS_GetServiceDraftRequestNo");
            getRequestCommand.CommandType = CommandType.StoredProcedure;
            getRequestCommand.Parameters.Clear();
            getRequestCommand.Parameters.Add(GetParameter("@EmpId", SqlDbType.Int, empId));
            dt = ExecuteGetDataTable(getRequestCommand);
            dt = ExecuteGetDataTable(getRequestCommand);
            foreach (DataRow dr in dt.Rows)
            {
                getRequestCommand.CommandText = "ams.AMS_GetServiceRequestDraftRequestNoWise";
                getRequestCommand.Parameters.Clear();
                SqlParameter par = null;
                int requestid = int.Parse(dr["RequestId"].ToString());
                par = getRequestCommand.Parameters.AddWithValue("@RequestId", requestid);
                SqlParameter par2 = new SqlParameter("@NoOfItem", SqlDbType.Int);
                par2.Direction = ParameterDirection.Output;
                par2.Size = 50;

                SqlParameter par5 = new SqlParameter("@Count", SqlDbType.Int);
                par5.Direction = ParameterDirection.Output;
                par5.Size = 50;
                getRequestCommand.Parameters.Add(par2);
                getRequestCommand.Parameters.Add(par5);
                ExecuteStoredProcedure(getRequestCommand);
                if (int.Parse(getRequestCommand.Parameters["@Count"].Value.ToString()) == 1)
                {

                    int noofitem = Convert.ToInt32(getRequestCommand.Parameters["@NoOfItem"].Value);

                    DataRow returndr = returndt.NewRow();

                    returndr["RequestNo"] = dr["RequestId"].ToString();
                    returndr["RequestDate"] = dr["RequestDate"].ToString();
                    returndr["NoOfItem"] = noofitem;
                    returndt.Rows.Add(returndr);
                }
            }
            return returndt;
        }

        public DataTable GetAllServiceDraft(int draftId)
        {

            SqlCommand getDraftDetailsCommand = new SqlCommand("ams.AMS_GetServiceRequisitionDraftdetailsRequestNoWise");
            getDraftDetailsCommand.CommandType = CommandType.StoredProcedure;
            getDraftDetailsCommand.Parameters.Add(GetParameter("@RequestId", SqlDbType.Int, draftId));
            DataTable dt = ExecuteGetDataTable(getDraftDetailsCommand);
            return dt;
        }

     



//////////
Draft view
design
<%@ Page Title="" Language="C#" AutoEventWireup="true" CodeBehind="ServiceRequisitionDraftView.aspx.cs" Inherits="Website.ERP.AMS.ServiceRequisitionDraftView" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
   
    <link href="../../css/ken-campus-main.css" rel="stylesheet" type="text/css" />
 
         
     
 
</head>
<body>

 <form id="form1" runat="server">
 <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
 </asp:ToolkitScriptManager>


 <script type ="text/javascript"  language="javascript">


     function refreshParent()
     {
         window.opener.location.href = window.opener.location.href;
     }

   
    </script>
<div class="MainSectionDiv">
        Requisition Details :<asp:Label ID="lblMsg" runat="server"></asp:Label>
       
    </div>

<div class="DefaultWOI">
<%--<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>--%>
    <div class="PlaceButton">
    </div>
    <div class="labeldiv">
    Request No :
    </div>

        <div class="valuediv4c">
            <asp:TextBox ID="TXTRequestNo" runat="server" ReadOnly="true" BackColor="DarkGray" ></asp:TextBox>
           
        </div>
       
        <div class="labeldiv4c">
            Date :
        </div>
        <div class="valuediv4c">
            <asp:TextBox ID="TXTCurrentDate" runat="server" ReadOnly="true" BackColor="DarkGray"></asp:TextBox>
        </div>

   
     
       
        <div class="labeldiv">
            Asset Tag No:
        </div>
        <div class="valuediv4c">
         
            <asp:TextBox ID="TXTAsettagno" runat="server" autocompletetype="Disabled"
                TabIndex="1" AutoPostBack="True" ontextchanged="TXTAsettagno_TextChanged1"></asp:TextBox>
            <asp:AutoCompleteExtender ID="TXTAsettagno_AutoCompleteExtender" runat="server"
                DelimiterCharacters="" Enabled="True" ServicePath="~/App_WebServices/KCWebServices.svc" ServiceMethod="AutoCompleteFillAssetTagNo"
                TargetControlID="TXTAsettagno"
                MinimumPrefixLength="1"
                CompletionInterval="1000"
                EnableCaching="true"
                CompletionSetCount="20"
                FirstRowSelected="true"
                >
            </asp:AutoCompleteExtender>
        </div>
        <div class="labeldiv4c">
            Asset Name :
        </div>
        <div class="valuediv4c">
            <asp:TextBox ID="TXTAssetname" runat="server" TabIndex="2"></asp:TextBox>
        </div>
        <div class="labeldiv">
            Related Problem :
        </div>
        <div class="valuedivML">
            <asp:TextBox ID="TXTRelatedproblem" runat="server" TextMode="MultiLine"
                MaxLength="199" TabIndex="3"></asp:TextBox>
           
        </div>
       
       
        <div class="labeldiv">
            Date Of Requirement :
        </div>
        <div class="valuediv4c">
            <asp:TextBox ID="TXTDateOfRequirement" runat="server" TabIndex="4"></asp:TextBox>
            <asp:TextBoxWatermarkExtender ID="TXTDateOfRequirement_TextBoxWatermarkExtender"
                runat="server" Enabled="True" TargetControlID="TXTDateOfRequirement"
                WatermarkText="dd/mm/yyyy" WatermarkCssClass="watermarkclass">
            </asp:TextBoxWatermarkExtender>
            <asp:CalendarExtender ID="TXTDateOfRequirement_CalendarExtender" runat="server" Enabled="True"
                TargetControlID="TXTDateOfRequirement" Format="dd/MM/yyyy" CssClass="Calender">
            </asp:CalendarExtender>
            <asp:MaskedEditExtender ID="MaskedEditExtender1" runat="server"
            TargetControlID="TXTDateOfRequirement"
            Mask="99/99/9999"
            MessageValidatorTip="true"
            CultureName="en-AU"
            OnFocusCssClass="MaskedEditFocus"
            OnInvalidCssClass="MaskedEditError"
            MaskType="Date"
            DisplayMoney="Left"
            AcceptNegative="Left"
            ErrorTooltipEnabled="True" ClearTextOnInvalid="true" />
            <%--<asp:MaskedEditValidator ID="MaskedEditValidator1" runat="server"
            ControlExtender="MaskedEditExtender1"
            ControlToValidate="DateOfRequirement"
            EmptyValueMessage="Date is required"          
            Display="Dynamic"            
            TooltipMessage="Input a date"/>--%>
        </div>
        <div class="labeldiv4c">
            Priority :
        </div>
        <div class="valuediv4c">
            <asp:DropDownList ID="DDLPriority" runat="server" TabIndex="5">
            </asp:DropDownList>
        </div>
        <div class="labeldivML">
            Purpose
        </div>
        <div class="valuedivML">
            <asp:TextBox ID="TXTpurpose" runat="server" TextMode="MultiLine" TabIndex="6"></asp:TextBox>
        </div>
     
    <div class="PlaceButton">
        <asp:ImageButton ID="ImageButtonAddNew" runat="server" ImageUrl="~/images/addnew.jpg"
            OnClick="ImageButtonAddNew_Click" TabIndex="7" />

            <asp:ImageButton ID="ImageButtonEditSave" runat="server"
            ImageUrl="~/images/Save.jpg" onclick="ImageButtonEditSave_Click"
            TabIndex="8" />
    </div>
   
   
    <div class="GridDiv">
   
            <%--onrowdeleting="Gridassetrequisitiondetails_RowDeleting"
            onrowediting="Gridassetrequisitiondetails_RowEditing"--%>
        <asp:GridView ID="Gridassetrequisitiondetails" runat="server"
            CssClass="GridViewDefault" AutoGenerateColumns="False"
            onrowcommand="Gridassetrequisitiondetails_RowCommand"
                onpageindexchanging="Gridassetrequisitiondetails_PageIndexChanging"  >
           <Columns>

               <asp:BoundField DataField="SerialNo" HeaderText="SerialNo" />
               <%--<asp:BoundField DataField="RequestType" HeaderText="RequestType" />--%>
               <asp:BoundField DataField="AssetTagNo" HeaderText="AssetTagNo" />
               <asp:BoundField DataField="AssetTagName" HeaderText="AssetName" />
               <asp:BoundField DataField="RlatedProblem" HeaderText="RlatedProblem" />
               <asp:BoundField DataField="Priority" HeaderText="Priority" />
               <asp:BoundField DataField="DateOfRequirement" HeaderText="DateOfRequirement" />
               <asp:BoundField DataField="Purpose" HeaderText="Purpose" />

         
           <asp:TemplateField HeaderText="Edit">
           <ItemTemplate>
           <asp:ImageButton ID="ImageButtonEdit" runat="server" ImageUrl="~/images/edit.png" CausesValidation="false" CommandName="edi" CommandArgument='<%# Eval("SerialNo") %>' />
           </ItemTemplate>          
           </asp:TemplateField>
            <asp:TemplateField HeaderText="Delete">
           <ItemTemplate>
           <asp:ImageButton ID="ImageButtonDelete" runat="server" ImageUrl="~/images/delete.png" CausesValidation="false" OnClientClick="return confirm('Are you sure to delete ?');" CommandName="del" CommandArgument='<%# Eval("SerialNo") %>' />
           </ItemTemplate>          
           </asp:TemplateField>
         
           </Columns>    
        </asp:GridView>
    </div>
    <div class="LineSpace">
    <!--Placing a HiddenField Control which will be used at the time of Records Edit From Gridview -->
        <asp:HiddenField ID="HiddenFieldSlno" runat="server" />
         <asp:HiddenField ID="HiddenFieldRequestNo" runat="server" />

    <!--Placing a HiddenField Control which will be used at the time of Records Edit From Gridview -->
     <!-- putting RequiredFieldValidator for All the Field -->
           

       <%--<asp:BoundField DataField="RequestType" HeaderText="RequestType" />--%>
         
            <!--DDLAsettagno-->
             <asp:RequiredFieldValidator ID="RfvTXTAsettagno" runat="server" ControlToValidate="TXTAsettagno"
            ErrorMessage="Please Enter the Asset Tag No"   Display="None">
            </asp:RequiredFieldValidator>
            <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender1_RfvDDLAsettagno"
            runat="server" Enabled="True" TargetControlID="RfvTXTAsettagno">
            </asp:ValidatorCalloutExtender>
            <!--TXTRelatedproblem-->
             <asp:RequiredFieldValidator ID="RfvTXTRelatedproblem" runat="server" ControlToValidate="TXTRelatedproblem"
            ErrorMessage="Please Enter The Problem" Display="None">
            </asp:RequiredFieldValidator>
            <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender1RfvTXTRelatedproblem"
            runat="server" Enabled="True" TargetControlID="RfvTXTRelatedproblem">
            </asp:ValidatorCalloutExtender>
            <!--TXTDateOfRequirement-->
           
           
            <asp:RequiredFieldValidator ID="RfvDateOfRequirement" runat="server" ControlToValidate="TXTDateOfRequirement"
            ErrorMessage="Please Select the Date of Requirements" Display="None">
            </asp:RequiredFieldValidator>
            <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender1RfvDateOfRequirement"
            runat="server" Enabled="True" TargetControlID="RfvDateOfRequirement">
            </asp:ValidatorCalloutExtender>

             <!--DDLPriority -->
           <asp:RequiredFieldValidator ID="RfvDDLPriority" runat="server" ErrorMessage="Please select the priority"
        Display="None" InitialValue="Select" ControlToValidate="DDLPriority" >
        </asp:RequiredFieldValidator>
        <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender1RfvDDLPriority"
            runat="server" Enabled="True" TargetControlID="RfvDDLPriority">
            </asp:ValidatorCalloutExtender>
            <!-- End of putting RequiredFieldValidator for All the Field -->
    </div>
    <div class="PlaceButton">
        <asp:ImageButton ID="ImageButtonSave" runat="Server" CausesValidation="false"
            ImageUrl="~/images/button-send.jpg" OnClick="Save_Click" TabIndex="9" />
            <asp:ImageButton ID="Draft" runat="Server" CausesValidation="false" ImageUrl="~/images/button-save-in-draft.jpg" onclick="Draft_Click"   />
   
        <asp:ImageButton ID="ImageButtonReset" runat="server"  CausesValidation="false"
            ImageUrl="~/images/reset.jpg" onclick="Reset_Click1" TabIndex="10" />
       
    </div>

    <%--</ContentTemplate>
    </asp:UpdatePanel>--%>
    </div>
</form>
</body>
</html>
///////////
codebehind

namespace Website.ERP.AMS
{
    public partial class ServiceRequisitionDraftView : System.Web.UI.Page
    {
       

        #region Declaring Global Variable
        int empId;
        string requestPurpose = "";
        #endregion Declaring Global Variable



        #region Event
        protected void Page_Load(object sender, EventArgs e)
        {
            empId = 36;
            requestPurpose = "Service";
            if (!IsPostBack)
            {
                //calling methods for Fill the Dropdownlist at the first time of page loading
                Fillcommondropdownlist();

                Disableclontrol();
                if (Request.QueryString["draftId"] != null)
                {
                    HiddenFieldRequestNo.Value = Request.QueryString["draftId"].ToString();                  
                    ViewState["tmpdataset"] = null;
                    BindGridassetrequisitiondetails(int.Parse(HiddenFieldRequestNo.Value));
                }


            }

        }


        protected void ImageButtonAddNew_Click(object sender, ImageClickEventArgs e)
        {

            BindGridassetrequisitiondetails(0);
            Clearcontrols();
            Enableclontrol();
        }
        protected void Save_Click(object sender, ImageClickEventArgs e)
        {
            String Status = "New";
            InsertServicerequisition(Status);
        }

        protected void ImageButtonEditSave_Click(object sender, ImageClickEventArgs e)
        {
            Saveeditrecords();
        }

        protected void Gridassetrequisitiondetails_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int slno = Convert.ToInt32(e.CommandArgument);
            if (e.CommandName == "edi")
            {
                Editdetails(slno);
            }
            else if (e.CommandName == "del")
            {

                deleterecords(slno);
            }
        }

        protected void Draft_Click(object sender, ImageClickEventArgs e)
        {
            String Status = "Draft";
            InsertServicerequisition(Status);

        }



        protected void Reset_Click1(object sender, ImageClickEventArgs e)
        {

            Clearcontrols();
        }

        protected void TXTAsettagno_TextChanged(object sender, EventArgs e)
        {
         
            string tagno = TXTAsettagno.Text;
            string assetname = KCWebServices.GetAllAsset(tagno);
            TXTAssetname.Text = tagno;
           
        }


        protected void Gridassetrequisitiondetails_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            BindGridassetrequisitiondetails(int.Parse(HiddenFieldRequestNo.Value));
        }

        protected void TXTAsettagno_TextChanged1(object sender, EventArgs e)
        {
            //ams.AMS_GetServiceRequestDraftRequestNoWise
            string tagno = TXTAsettagno.Text;
            string assetname = KCWebServices.GetAllAsset(tagno);
            TXTAssetname.Text = assetname;
        }

     
        #endregion Event




        #region Methods section

        public void Fillcommondropdownlist()
        {
            DateTime dt = DateTime.Now.Date;
            String ddmmyy = dt.ToString("dd/MM/yyyy");
            TXTCurrentDate.Text = ddmmyy;
            Fillpriority();
        }

        public void Fillpriority()
        {
            foreach (int value in Enum.GetValues(typeof(Priority)))
            {
                DDLPriority.Items.Add(Enum.GetName(typeof(Priority), value));
            }
            DDLPriority.Items.Insert(0, "Select");
        }


        public void BindGridassetrequisitiondetails(int val)
        {
            if (val !=0)
            {
                DataTable dt = Returndatatable(val);
                ViewState["tmpdataset"] = dt;
                Gridassetrequisitiondetails.DataSource = dt;
                Gridassetrequisitiondetails.DataBind();
                if (Gridassetrequisitiondetails.Rows.Count > 0)
                {
                    Enableclontrol();
                }
            }
            else if (val == 0)
            {
                if (ViewState["tmpdataset"] != null)
                {
                    DataTable dt = Returndatatable(val);
                    ViewState["tmpdataset"] = dt;
                    Gridassetrequisitiondetails.DataSource = dt;
                    Gridassetrequisitiondetails.DataBind();
                    //DataTable dt = (DataTable)ViewState["tmpdataset"];
                    //Gridassetrequisitiondetails.DataSource = dt;
                    //Gridassetrequisitiondetails.DataBind();
                }
            }
        }

        public void Disableclontrol()
        {

            TXTRequestNo.Attributes.Add("Readonly", "Readonly");
            TXTCurrentDate.Attributes.Add("Readonly", "Readonly");
            TXTAssetname.Attributes.Add("Readonly", "Readonly");
            ImageButtonEditSave.Visible = false;
            ImageButtonSave.Visible = false;
            Draft.Visible = false;
            ImageButtonReset.Visible = false;

        }

        public void Clearcontrols()
        {
            TXTAsettagno.Text = string.Empty;
            TXTAssetname.Text = string.Empty;
            TXTRelatedproblem.Text = string.Empty;
            TXTDateOfRequirement.Text = "";
            DDLPriority.SelectedIndex = 0;
            TXTpurpose.Text = "";
        }

        public void Enableclontrol()
        {
            ImageButtonSave.Visible = true;
            Draft.Visible = true;
            ImageButtonReset.Visible = true;

        }

        public DataTable Returndatatable( int val)
        {

            DataTable dt = new DataTable();
            if (ViewState["tmpdataset"] == null)
            {
                dt.Columns.Add("RequestNo");
                dt.Columns.Add("SerialNo");
                dt.Columns.Add("EmpId");
                dt.Columns.Add("RequestPurpose");
                dt.Columns.Add("RequestType");
                dt.Columns.Add("AssetTagNo");
                dt.Columns.Add("AssetTagName");
                dt.Columns.Add("RlatedProblem");
                dt.Columns.Add("Priority");
                dt.Columns.Add("DateOfRequirement");
                dt.Columns.Add("Purpose");
                dt.Columns.Add("Status");              
                List<AMS_ServiceRequisition> serviceRequisitionDraft = new List<AMS_ServiceRequisition>();
                serviceRequisitionDraft = ERPManagement.GetInstance.GetAllServiceDraft(val);
                int i = 1;
                foreach (AMS_ServiceRequisition ser in serviceRequisitionDraft)
                {
                    //var result = from ServiceDraft in serviceRequisitionDraft select new { ServiceDraft.RequestId, ServiceDraft.RequestPurpose, ServiceDraft.AssetTagNo, ServiceDraft.RequisitionDetailsId, ServiceDraft.RelatedProblem, ServiceDraft.AssetName, ServiceDraft.RequestDate, ServiceDraft.Purpose, ServiceDraft.RequirementDate, ServiceDraft.Priority };
                    DataRow dr = dt.NewRow();
                    dr["RequestNo"] = HiddenFieldRequestNo.Value;
                    dr["SerialNo"] = i.ToString(); ;
                    dr["EmpId"] = empId;
                    dr["RequestPurpose"] = requestPurpose;
                    //dr["RequestType"] = DDLRequestType.SelectedItem.Text;
                    dr["AssetTagNo"] = ser.AssetTagNo;
                    dr["AssetTagName"] = ser.AssetName;
                    dr["RlatedProblem"] = ser.RelatedProblem;
                    dr["Priority"] = ser.Priority;
                    dr["DateOfRequirement"] = ser.DateOfRequirement;
                    dr["Purpose"] = ser.Purpose;
                    dt.Rows.Add(dr);
                    i++;
                }



            }
            else
            {
                dt = (DataTable)ViewState["tmpdataset"];
                int slno = 1;
                foreach (DataRow drr in dt.Rows)
                {
                    slno = Convert.ToInt32(drr["SerialNo"]);
                }
                slno++;

                DataRow dr = dt.NewRow();
                dr["RequestNo"] = HiddenFieldRequestNo.Value;
                dr["SerialNo"] = slno;
                dr["EmpId"] = empId;
                dr["RequestPurpose"] = requestPurpose;
                //dr["RequestType"] = DDLRequestType.SelectedItem.Text;
                dr["AssetTagNo"] = TXTAsettagno.Text;
                dr["AssetTagName"] = TXTAssetname.Text;
                dr["RlatedProblem"] = TXTRelatedproblem.Text;
                dr["Priority"] = DDLPriority.SelectedItem.Text;
                dr["DateOfRequirement"] = TXTDateOfRequirement.Text;
                dr["Purpose"] = TXTpurpose.Text;
                dt.Rows.Add(dr);
            }
            return dt;
        }


        public void InsertServicerequisition(String Status)
        {
         
            if (ViewState["tmpdataset"] != null)
            {
                DataTable dt = (DataTable)ViewState["tmpdataset"];
                int reqno = ERPManagement.GetInstance.InsertServicerequisition(dt, Status);
                if (reqno > 0)
                {
                    if (Status == "New")
                    {
                        string requestno = "";
                        if ((reqno > 0) && (reqno < 10))
                        {
                            requestno = "0" + reqno.ToString();
                        }
                        else
                        {
                            requestno = reqno.ToString();
                        }
                        dt.Clear();
                        Gridassetrequisitiondetails.DataSource = dt;
                        Gridassetrequisitiondetails.DataBind();
                        Disableclontrol();
                        Clearcontrols();                      
                        TXTRequestNo.Text = requestno;
                        ViewState["tmpdataset"] = null;
                        lblMsg.Text = "Request For Service Sent Successfully";
                        ImageButtonAddNew.Enabled = false;
                        Draft.Enabled = false;
                        string script = "refreshParent()";
                        Page.ClientScript.RegisterStartupScript(GetType(), "test", script, true);
                    }
                    else if (Status == "Draft")
                    {
                        dt.Clear();
                        Gridassetrequisitiondetails.DataSource = dt;
                        Gridassetrequisitiondetails.DataBind();
                        Disableclontrol();
                        Clearcontrols();                      
                        ViewState["tmpdataset"] = null;
                        TXTRequestNo.Text = "";
                        lblMsg.Text = "Records Saved In Draft Successully";
                        ImageButtonAddNew.Enabled = false;
                        Draft.Enabled = false;
                        string script = "refreshParent()";
                        Page.ClientScript.RegisterStartupScript(GetType(), "test", script, true);
                    }
                }

            }
            else
            {
                lblMsg.Text = "Please ADD Items Before Saving or Sending Request";
            }
        }


        public void Editdetails(int slno)
        {
            DataTable dt = (DataTable)ViewState["tmpdataset"];
            DataView dvEmp = new DataView(dt);
            dvEmp.RowFilter = "SerialNo='" + slno.ToString() + "'";
            //DataRow[] rows = dt.Select("Serial No='"+slno+"'");
            // DDLRequestType.Text = dvEmp[0]["RequestType"].ToString();
            DDLPriority.Text = dvEmp[0]["Priority"].ToString();
            TXTAsettagno.Text = dvEmp[0]["AssetTagNo"].ToString();
            TXTAssetname.Text = dvEmp[0]["AssetTagName"].ToString();
            TXTRelatedproblem.Text = dvEmp[0]["RlatedProblem"].ToString();
            TXTDateOfRequirement.Text = dvEmp[0]["DateOfRequirement"].ToString();
            TXTpurpose.Text = dvEmp[0]["Purpose"].ToString();
            HiddenFieldSlno.Value = slno.ToString();
            EnableclontrolImageButtonEditSave();
        }
        public void Saveeditrecords()
        {
            if (ViewState["tmpdataset"] != null)
            {
                DataTable dt = (DataTable)ViewState["tmpdataset"];

                DataView dvEmp = new DataView(dt);
                dvEmp.RowFilter = "SerialNo='" + HiddenFieldSlno.Value.ToString() + "'";

                //dvEmp[0]["RequestType"] = DDLRequestType.SelectedItem.Text;
                dvEmp[0]["Priority"] = DDLPriority.SelectedItem.Text; ;
                dvEmp[0]["AssetTagNo"] = TXTAsettagno.Text;
                dvEmp[0]["AssetTagName"] = TXTAssetname.Text;
                dvEmp[0]["RlatedProblem"] = TXTRelatedproblem.Text;
                dvEmp[0]["DateOfRequirement"] = TXTDateOfRequirement.Text;
                dvEmp[0]["Purpose"] = TXTpurpose.Text;
                dt.AcceptChanges();
                Gridassetrequisitiondetails.DataSource = dt;
                Gridassetrequisitiondetails.DataBind();
                DisableclontrolImageButtonEditSave();
                Clearcontrols();
            }
        }

        public void deleterecords(int slno)
        {
            DataTable dt = (DataTable)ViewState["tmpdataset"];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                int grdsno = int.Parse(dt.Rows[i]["SerialNo"].ToString());
                if (grdsno == slno)
                {
                    dt.Rows.RemoveAt(i);
                }
            }

            dt.AcceptChanges();
            Gridassetrequisitiondetails.DataSource = dt;
            Gridassetrequisitiondetails.DataBind();
        }


        public void EnableclontrolImageButtonEditSave()
        {
            ImageButtonAddNew.Visible = false;
            ImageButtonEditSave.Visible = true;
        }
        public void DisableclontrolImageButtonEditSave()
        {
            ImageButtonAddNew.Visible = true;
            ImageButtonEditSave.Visible = false;
        }

       


        #endregion

     


    }
   
}
namespace Swash.BusinessLayer
{
    public partial class ERPManagement
    {
        public List<AMS_ServiceRequisition> GetAllAsset()
        {
            return ERPCache.GetAllAsset();
        }
        public List<AMS_ServiceRequisition> GetAssetNameTagWise(string TagNo)
        {
            return ERPCache.GetAssetNameTagWise(TagNo);
        }

        public List<AMS_ServiceRequisition> GetServiceRequisitionDetailsForEmployee(AMS_ServiceRequisition serviceRequisition)
        {
            return ERPCache.GetServiceRequisitionDetailsForEmployee(serviceRequisition);
        }

        public List<AMS_ServiceRequisition> FillgridViewServiceDetailsRequestNoWise(string Requestid)
        {
            return ERPCache.FillgridViewServiceDetailsRequestNoWise(Requestid);
        }

     
     

        public int InsertServicerequisition(DataTable dt, String Status)
        {
            return ERPCache.InsertServicerequisition(dt, Status);
        }



       

       
       
     
    }
}
namespace Swash.CacheLayer
{
    public partial class ERPCache
    {
        public static List<AMS_ServiceRequisition> GetAllAsset()
        {
             return ERPIntegration.GetAllAsset();
        }
        public static List<AMS_ServiceRequisition> GetAssetNameTagWise(string TagNo)
        {
            return ERPIntegration.GetAssetNameTagWise(TagNo);
        }

        public static int InsertServicerequisition(DataTable dt, String Status)
        {
            return ERPIntegration.InsertServicerequisition(dt, Status);
        }

        public static List<AMS_ServiceRequisition> GetServiceRequisitionDetailsForEmployee(AMS_ServiceRequisition serviceRequisition)
        {
            return ERPIntegration.GetServiceRequisitionDetailsForEmployee(serviceRequisition);
        }

        public static List<AMS_ServiceRequisition> FillgridViewServiceDetailsRequestNoWise(String Requestid)
        {
            return ERPIntegration.FillgridViewServiceDetailsRequestNoWise(Requestid);
        }
        ////GetRequisitionDetailsRequestnowise
        //public static DataTable GetServiceRequisitionDetailsRequestnowise(AMS_ServiceRequisition servicerequisition)
        //{
        //    return ERPIntegration.GetServiceRequisitionDetailsRequestnowise(servicerequisition);
        //}

    }
}
namespace Swash.IntegrationLayer
{
    public partial class ERPIntegration
    {
        public static List<AMS_ServiceRequisition> GetAllAsset()
        {
           return ERPDataAccess.GetInstance.GetAllAsset();
        }
        public static List<AMS_ServiceRequisition> GetAssetNameTagWise(string TagNo)
        {
            return ERPDataAccess.GetInstance.GetAssetNameTagWise(TagNo);
        }
       
       public static int InsertServicerequisition(DataTable dt,String Status)
        {
            return ERPDataAccess.GetInstance.InsertServicerequisition(dt,Status);  
        }

        #region Retrieve Record
       public static List<AMS_ServiceRequisition> GetServiceRequisitionDetailsForEmployee(AMS_ServiceRequisition serviceRequisition)
        {
            return ERPDataAccess.GetInstance.GetServiceRequisitionDetailsForEmployee(serviceRequisition);
        }
        // //GetAllassetrequisiondetails



       public static List<AMS_ServiceRequisition> FillgridViewServiceDetailsRequestNoWise(string Requestid)
       {
           return ERPDataAccess.GetInstance.FillgridViewServiceDetailsRequestNoWise(Requestid);
       }

        ////GetRequisitionDetailsRequestnowise
        //public static DataTable GetServiceRequisitionDetailsRequestnowise(AMS_ServiceRequisition servicerequisition)
        // {
        //     return ERPDataAccess.GetInstance.GetServiceRequisitionDetailsRequestnowise(servicerequisition);
        // }
       #endregion
    }
}
namespace Swash.DataAccessLayer
{
    public partial class ERPDataAccess
    {

        /// <summary>
        /// Function use for ServiceRequisitionDetails Page
        public List<AMS_ServiceRequisition> GetServiceRequisitionDetailsForEmployee(AMS_ServiceRequisition serviceRequisition)
        {
            List<AMS_ServiceRequisition> service = new List<AMS_ServiceRequisition>();
            DataTable dt = new DataTable();

            SqlCommand getrequestacquisition = new SqlCommand();
            getrequestacquisition.CommandText = "ams.AMS_SelectServiceRequisitionRequestNoForEmployee";
            getrequestacquisition.CommandType = CommandType.StoredProcedure;
            getrequestacquisition.Parameters.Clear();

            SqlParameter par = null;
            par = getrequestacquisition.Parameters.AddWithValue("@EmpId", serviceRequisition.EmployeeId);

            SqlParameter par1 = new SqlParameter("@Count", SqlDbType.Int);
            par1.Direction = ParameterDirection.Output;
            par1.Size = 50;
            getrequestacquisition.Parameters.Add(par1);
            dt = ExecuteGetDataTable(getrequestacquisition);
            foreach (DataRow dr in dt.Rows)
            {
                getrequestacquisition.CommandText = "ams.AMS_GetServiceRequisitionDetailsForEmployee";
                getrequestacquisition.Parameters.Clear();
                int requestno = int.Parse(dr["RequestId"].ToString());
                par = getrequestacquisition.Parameters.AddWithValue("@RequestId", requestno);

                //SqlParameter par01 = new SqlParameter("@AssetTagNo", SqlDbType.VarChar);
                //par01.Direction = ParameterDirection.Output;
                //par01.Size = 100;

                SqlParameter par2 = new SqlParameter("@NoOfItem", SqlDbType.Int);
                par2.Direction = ParameterDirection.Output;
                par2.Size = 50;

                SqlParameter par3 = new SqlParameter("@ApprovedItems", SqlDbType.Int);
                par3.Direction = ParameterDirection.Output;
                par3.Size = 50;

                SqlParameter par4 = new SqlParameter("@Status", SqlDbType.VarChar);
                par4.Direction = ParameterDirection.Output;
                par4.Size = 100;
                SqlParameter par5 = new SqlParameter("@Count", SqlDbType.Int);
                par5.Direction = ParameterDirection.Output;
                par5.Size = 50;

                //getrequestacquisition.Parameters.Add(par01);
                getrequestacquisition.Parameters.Add(par2);
                getrequestacquisition.Parameters.Add(par3);
                getrequestacquisition.Parameters.Add(par4);
                getrequestacquisition.Parameters.Add(par5);
                ExecuteStoredProcedure(getrequestacquisition);
                if (int.Parse(getrequestacquisition.Parameters["@Count"].Value.ToString()) > 0)
                {
                   // string tagno = Convert.ToString(getrequestacquisition.Parameters["@AssetTagNo"].Value.ToString());
                    int noofitem = Convert.ToInt32(getrequestacquisition.Parameters["@NoOfItem"].Value.ToString());
                    int approveditem = Convert.ToInt32(getrequestacquisition.Parameters["@ApprovedItems"].Value.ToString());
                    String Status = getrequestacquisition.Parameters["@Status"].Value.ToString();
                    AMS_ServiceRequisition ser = new AMS_ServiceRequisition();
                    ser.RequestNo = int.Parse(dr["RequestId"].ToString());
                    ser.RequestDate = dr["CreatedOn"].ToString();
                    //ser.AssetTagNo = tagno;
                    ser.NoOfItem = noofitem;
                    ser.ApprovedItems = approveditem;
                    ser.Status = Status;
                    service.Add(ser);
                }


            }



            return service;
        }
        /// <returns></returns>
        ///

        //Function use for ViewServiceRequisitionToEmployee.aspx page
        public List<AMS_ServiceRequisition> FillgridViewServiceDetailsRequestNoWise(string Requestid)
        {
            List<AMS_ServiceRequisition> Service = new List<AMS_ServiceRequisition>();

            SqlCommand getAssetServiceWise = new SqlCommand();
            getAssetServiceWise.CommandText = "ams.AMS_GetServicedetailsrequestnowise";
            getAssetServiceWise.CommandType = CommandType.StoredProcedure;
            getAssetServiceWise.Parameters.Clear();
            SqlParameter par = null;
            par = getAssetServiceWise.Parameters.AddWithValue("@RequestId", Requestid);
            DataTable dt = ExecuteGetDataTable(getAssetServiceWise);
            foreach (DataRow dr in dt.Rows)
            {
                AMS_ServiceRequisition assetService = new AMS_ServiceRequisition();
                assetService.RequestNo = int.Parse(dr["RequestId"].ToString());
                assetService.RequestFor = dr["RequestPurpose"].ToString();
                assetService.RequestType = dr["RequestType"].ToString();
                assetService.RequestDate = dr["CreatedOn"].ToString();
                assetService.AssetTagNo = dr["AssetTagNo"].ToString();
                assetService.AssetName = dr["AssetName"].ToString();
                assetService.RelatedProblem = dr["RelatedProblem"].ToString();
                assetService.RequirementDate = dr["RequirementDate"].ToString();
                assetService.Purpose = dr["Purpose"].ToString();
                assetService.Status = dr["Status"].ToString();
                Service.Add(assetService);
            }
            return Service;
        }


        public List<AMS_ServiceRequisition> GetAllAsset()
        {
            List<AMS_ServiceRequisition> servicerequisition = new List<AMS_ServiceRequisition>();
            //string query = "select AssetMasterId,AstTagID,AstCompName,AssetName,AssetSpecification,AssetCost,VendorId,WarrentyStartDate,WarrentyEndDate"
            //,AssetUrl,AssetTechnicalSupportUrl,TechnicalSupportTelePhone,ContactDetails,
            //Comments,CreatedBy,CreatedOn,ModifiedBy,ModifiedOn,IsActive,IsDeleted";
            SqlCommand getallcompanyaseet = new SqlCommand();
            getallcompanyaseet.CommandText = "ams.AMS_GetallCompanyAseetDetails";
            getallcompanyaseet.CommandType = CommandType.StoredProcedure;
            DataTable dt = ExecuteGetDataTable(getallcompanyaseet);
            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    AMS_ServiceRequisition ser = new AMS_ServiceRequisition();

                    ser.AssetTagNo = dr["AstTagId"].ToString();
                    //ser.IsActive=Convert.ToBoolean(dr["IsActive"]);
                    // ser.IsDeleted=Convert.ToBoolean(dr["IsDeleted"]);
                    servicerequisition.Add(ser);


                }
            }
            return servicerequisition;
        }
        public List<AMS_ServiceRequisition> GetAssetNameTagWise(string tagNo)
        {
            List<AMS_ServiceRequisition> servicerequisition = new List<AMS_ServiceRequisition>();
            //string query = "select AssetMasterId,AstTagID,AstCompName,AssetName,AssetSpecification,AssetCost,VendorId,WarrentyStartDate,WarrentyEndDate"
            //,AssetUrl,AssetTechnicalSupportUrl,TechnicalSupportTelePhone,ContactDetails,
            //Comments,CreatedBy,CreatedOn,ModifiedBy,ModifiedOn,IsActive,IsDeleted";
            SqlCommand getallcompanyaseet = new SqlCommand();
            getallcompanyaseet.CommandText = "ams.AMS_GetAssetNameTagWise";
            getallcompanyaseet.CommandType = CommandType.StoredProcedure;
            getallcompanyaseet.Parameters.AddWithValue("@AstTagId", tagNo);
            DataTable dt =ExecuteGetDataTable(getallcompanyaseet);
            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    AMS_ServiceRequisition ser = new AMS_ServiceRequisition();

                    ser.AssetName = dr["AssetName"].ToString();
                    //ser.IsActive=Convert.ToBoolean(dr["IsActive"]);
                   // ser.IsDeleted=Convert.ToBoolean(dr["IsDeleted"]);
                    servicerequisition.Add(ser);
                   

                }
            }
            return servicerequisition;
             
        }
         
        public int InsertServicerequisition(DataTable dt, String Status)
        {
            int Returnval = 0;
            //int transactionstatus = 0;
            if (dt.Rows.Count > 0)
            {
                ////////////////insert in to table AMS_Requisition
                string requestPurpose = dt.Rows[0]["RequestPurpose"].ToString();
                requestPurpose.Replace("'", "&#39");
                int EmpId = Convert.ToInt32(dt.Rows[0]["EmpId"].ToString());
                string status = Status;
                SqlCommand insertCommand = new SqlCommand();
                //SqlTransaction tran=insertCommand.Connection.BeginTransaction();
                try
                {
                    if (Status == "New")
                    {
                        insertCommand.CommandText = "ams.AMS_InsertServiceRequisition";
                    }
                    else if (Status == "Draft")
                    {
                        insertCommand.CommandText = "ams.AMS_InsertServiceRequisitionDraft";
                    }
                    insertCommand.CommandType = CommandType.StoredProcedure;
                    insertCommand.Parameters.Clear();

                    SqlParameter par = null;
                    par = insertCommand.Parameters.AddWithValue("@RequestNo", dt.Rows[0]["RequestNo"].ToString());
                    par = insertCommand.Parameters.AddWithValue("@RequestPurpose", requestPurpose);
                    par = insertCommand.Parameters.AddWithValue("@EmpId", EmpId);                  
                    par = insertCommand.Parameters.AddWithValue("@status", status);
                    SqlParameter par1 = new SqlParameter("@RequestId", SqlDbType.Int);
                    par1.Direction = ParameterDirection.Output;
                    par1.Size = 100;
                    insertCommand.Parameters.Add(par1);
                    ExecuteStoredProcedure(insertCommand);
                    Returnval = int.Parse(insertCommand.Parameters["@RequestId"].Value.ToString());
                    ////////////insert completed on AMS_Requisition
                    ////////////////insert in to table AMS_RequisitionDetails
                    foreach (DataRow dr in dt.Rows)
                    {

                        string RequType = "";//dr["RequestType"].ToString();
                        string Priority = dr["Priority"].ToString();
                        string AssetTagNo = dr["AssetTagNo"].ToString();                      
                        string RlatedProblem = dr["RlatedProblem"].ToString();
                        RlatedProblem.Replace("'", "&#39");
                        String Requirementdate = dr["DateOfRequirement"].ToString();
                        IFormatProvider culture = new System.Globalization.CultureInfo("fr-FR", true);
                        DateTime adt = DateTime.Parse(Requirementdate, culture, System.Globalization.DateTimeStyles.AssumeLocal);
                        String reqdate = adt.ToString("yyyy/MM/dd");
                        string ReqPurpose = dr["Purpose"].ToString();
                        ReqPurpose.Replace("'", "&#39");

                        insertCommand.Parameters.Clear();
                        if (Status == "New")
                        {
                            insertCommand.CommandText = "ams.AMS_InsertServiceRequisitionDetails";
                        }
                        else if (Status == "Draft")
                        {
                            insertCommand.CommandText = "ams.AMS_InsertServiceRequisitionDetailsDraft";
                        }
                        insertCommand.CommandType = CommandType.StoredProcedure;


                        par = insertCommand.Parameters.AddWithValue("@RequestId", Returnval);                    
                        par = insertCommand.Parameters.AddWithValue("@Priority", Priority);

                        par = insertCommand.Parameters.AddWithValue("@AssetTagNo", AssetTagNo);
                        par = insertCommand.Parameters.AddWithValue("@RlatedProblem", RlatedProblem);
                        par = insertCommand.Parameters.AddWithValue("@DateOfRequierment", reqdate);
                        par = insertCommand.Parameters.AddWithValue("@Purpose", ReqPurpose);
                        par = insertCommand.Parameters.AddWithValue("@status", status);
                        ExecuteStoredProcedure(insertCommand);
                    }
                    //tran.Commit();
                   // transactionstatus = 1;
                }
                catch (Exception e)
                {
                    // tran.Rollback();
                }

            }
            return Returnval;
        }

     



     

        ////GetRequisitionDetailsRequestnowise
    //    public DataTable GetServiceRequisitionDetailsRequestnowise(AMS_ServiceRequisition servicerequisition)
    //    {
    //        DataTable dt = new DataTable();
    //        DataTable returndt = new DataTable();
    //        returndt.Columns.Add("RequestNo");
    //        returndt.Columns.Add("NoOfItem");
    //        returndt.Columns.Add("ApprovedItems");
    //        returndt.Columns.Add("Status");
    //        returndt.Columns.Add("RequestDate");
    //        SqlCommand getrequestacquisition = new SqlCommand();
    //        getrequestacquisition.CommandText = "ams.GetServiceRequisitionRequestNOEmployeeWise1";
    //        getrequestacquisition.CommandType = CommandType.StoredProcedure;
    //        getrequestacquisition.Parameters.Clear();

    //        SqlParameter par = null;
    //        par = getrequestacquisition.Parameters.AddWithValue("@EmpId", servicerequisition.EmployeeId);
    //        par = getrequestacquisition.Parameters.AddWithValue("@RequestId", servicerequisition.RequestNo);

    //        SqlParameter par1 = new SqlParameter("@Count", SqlDbType.Int);
    //        par1.Direction = ParameterDirection.Output;
    //        par1.Size = 50;
    //        getrequestacquisition.Parameters.Add(par1);
    //        dt = ExecuteGetDataTable(getrequestacquisition);
    //        foreach (DataRow dr in dt.Rows)
    //        {
    //            getrequestacquisition.CommandText = "ams.GetServiceRequisitionRequestNOWise1";
    //            getrequestacquisition.Parameters.Clear();
    //            par = getrequestacquisition.Parameters.AddWithValue("@RequestId", dr["RequestId"].ToString());

    //            SqlParameter par2 = new SqlParameter("@NoOfItem", SqlDbType.Int);
    //            par2.Direction = ParameterDirection.Output;
    //            par2.Size = 50;

    //            SqlParameter par3 = new SqlParameter("@ApprovedItems", SqlDbType.Int);
    //            par3.Direction = ParameterDirection.Output;
    //            par3.Size = 50;

    //            SqlParameter par4 = new SqlParameter("@Status", SqlDbType.VarChar);
    //            par4.Direction = ParameterDirection.Output;
    //            par4.Size = 100;
    //            SqlParameter par5 = new SqlParameter("@Count", SqlDbType.Int);
    //            par5.Direction = ParameterDirection.Output;
    //            par5.Size = 50;

    //            getrequestacquisition.Parameters.Add(par2);
    //            getrequestacquisition.Parameters.Add(par3);
    //            getrequestacquisition.Parameters.Add(par4);
    //            getrequestacquisition.Parameters.Add(par5);
    //            ExecuteStoredProcedure(getrequestacquisition);
    //            if (int.Parse(getrequestacquisition.Parameters["@Count"].Value.ToString()) > 0)
    //            {
    //                int noofitem = Convert.ToInt32(getrequestacquisition.Parameters["@NoOfItem"].Value.ToString());
    //                int approveditem = Convert.ToInt32(getrequestacquisition.Parameters["@ApprovedItems"].Value.ToString());
    //                String Status = getrequestacquisition.Parameters["@Status"].Value.ToString();
    //                DataRow returndr = returndt.NewRow();
    //                returndr["RequestNo"] = dr["RequestId"].ToString();
    //                returndr["RequestDate"] = dr["CreatedOn"].ToString();
    //                returndr["NoOfItem"] = noofitem;
    //                returndr["ApprovedItems"] = approveditem;
    //                returndr["Status"] = Status;
    //                returndt.Rows.Add(returndr);
    //            }


    //        }



    //        return returndt;
    //    }

    }
}
/////////


NTier:


<%@ Page Title="" Language="C#" MasterPageFile="~/App_WebControls/App_MasterPages/MainMasterPage.Master" AutoEventWireup="true" CodeBehind="CategoryDetails.aspx.cs" Inherits="Website.ERP.AMS.CategoryDetails" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<%@ MasterType VirtualPath="~/App_WebControls/App_MasterPages/MainMasterPage.Master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
 <script src="../../Scripts/jquery-1.7.1.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script type ="text/javascript">
        $(document).ready(function () {
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(showpopupOfCategoryAssetDetails);
            showpopupOfCategoryAssetDetails();
        });

        function showpopupOfCategoryAssetDetails() {

            $("#<%=GridViewCategoryDetails.ClientID%>>tbody>tr>td:nth-child(1)").find('a').css("cursor", "pointer").mouseover(function (e) {

                var row1 = $(this).closest("tr");
                var id1 = row1.find("input[type=hidden][id*= HidCategoryId]").val();
                if (id1 != null) {
                    var data1 = { CategoryId: id1 };
                    var data1 = JSON.stringify(data1);
                    $.ajax({

                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        url: "../../App_WebServices/KCWebServices.svc/GetAllAssetDetailsCategoryWise1",
                        data: data1,
                        dataType: "json",
                        success: insertCallback
                    });
                    function insertCallback(result) {
                        res = result.d; //receiving json data
                        // res = result["d"];
                        var table = '<table cellpadding=0 cellspacing=10>';
                        table = table + '<tr><td colspan=3><h2>Category :' + res[0].CategoryName + '</h2></td></tr>';
                        table = table + '<tr><td colspan=3><h3>Asset List</h3></td></tr>';
                        table = table + '<tr><td colspan=3><hr/></td></tr>';

                        $("#content").find('tr').remove(); //removing all row from table
                        //checking if result is not null
                        if (res != null) {


                            //looping rhe hole records sent back by web methods
                            for (var i = 0; i < res.length; i++)
                             {
                                var row = '<tr>';
                                row += '<td>';
                                if (i < res.length)
                                 {
                                    row += "<a href='../../ERP/AMS/AssetMasterEntry.aspx?AssetId=" + res[i].AssetId + "'>" + res[i].AssetName + " </a>";
                                 }
                                row += '</td>';
                                i++;
                                row += '<td>';
                                if (i < res.length) {
                                    row += "<a href='../../ERP/AMS/AssetMasterEntry.aspx?AssetId=" + res[i].AssetId + "'>" + res[i].AssetName + " </a>";
                                }
                                row += '</td>';
                                i++;
                                row += '<td>';
                                if (i < res.length)
                                {
                                    row += "<a href='../../ERP/AMS/AssetMasterEntry.aspx?AssetId=" + res[i].AssetId + "'>" + res[i].AssetName + " </a>";
                                }
                                row += '</td>';
                                // row += '<td>' + res[i].AssetName + '</td>';
                                row += '</tr>';
                                table += row;
                            }


                            ///////////////////////////////////////////////////////////////////////////////////////

                            var height = $('#output').height();
                            var width = $('#output').width();
                            leftVal = e.pageX + 20 + "px";
                            topVal = e.pageY + "px";
                            //show the popup message and hide with fading effect
                            $('#output').css({ left: leftVal, top: topVal }).show("slow");
                            //end seting pop up position
                        }
                        else {
                            var row = '<tr>';
                            row += '<td colspan=3>No Asset Found on This Category</td></tr>';
                            table += row;
                        }
                        var row = '<tr>';
                        row += '<td>';

                     
                        row += "<b><a href='../../ERP/AMS/AssetMasterEntry.aspx?CategoryId=" + res[0].CategoryId + "&CategoryName=" + res[0].CategoryName +"'> Add New Asset </a></b>";
                        table += row;
                        row += '</td>';
                        row += '</tr>';
                        table += '</table>';
                        $('#content').html(table);
                    } //end callback
                }
                //end null checking
                //End Caling Webservice
            });           //end mouse over

            $("#close").click(function () {

                $('#output').css({ left: leftVal, top: topVal }).hide("slow");
            }); //close div click        

        } //end function

    function mypopupAddNew() {
        mywindow = window.open("../../ERP/AMS/CategoryEntry.aspx", "mywindow", "location=1,status=1,scrollbars=1,  width=900,height=600,screenX=300,screenY=300");
        mywindow.moveTo(100, 20);
    }
    function mypopupView(catId) {
        mywindow = window.open("../../ERP/AMS/CategoryEntry.aspx?CategoryId=" +catId, "mywindow", "location=1,status=1,scrollbars=1,  width=900,height=600,screenX=300,screenY=300");
        mywindow.moveTo(100, 20);
    }
   
</script>
<div class="DefaultWOI">
<div class="title">
Category [Details]
</div>
   <div class="SearchTextDiv">
                <asp:TextBox ID="TxtSearch" runat="server" />
</div>
   <div class="SearchImageDiv">
 <asp:ImageButton ID="ImgBtnSearch" ImageUrl="~/Images/SearchButton.gif"
           runat="server" onclick="ImgBtnSearch_Click" />
 </div>
   <%--<div class="PlaceButton">
  <asp:ImageButton ID="ImgBtnAddNew" runat="server" ImageUrl="~/images/addnew.jpg" OnClientClick="mypopupAddNew()" />              
</div>--%>
   <div class="GridDiv">
     <asp:GridView ID="GridViewCategoryDetails" runat="server"
                AutoGenerateColumns="False" CssClass="GridViewDefault" AllowPaging="True"
           onpageindexchanging="GridViewCategoryDetails_PageIndexChanging"
           PageSize="10" onrowcommand="GridViewCategoryDetails_RowCommand"  >
                <Columns>
                    <asp:TemplateField HeaderText="Category Name">
                        <ItemTemplate>
                            <%--<asp:LinkButton ID="LnkBtnCategory" runat="server" Text='<%#Eval("CategoryName") %>' OnClientClick='<%# Eval("CategoryId","javascript:mypopupView({0});") %>' />--%>
                            <asp:LinkButton ID="LnkBtnCategory" runat="server" Text='<%#Eval("CategoryName") %>'  CommandName="Edi" CommandArgument='<%#Eval("CategoryId") %>' OnClientClick='<%# Eval("CategoryId","javascript:mypopupView({0});") %>' />
                            <asp:HiddenField ID="HidCategoryId"  runat="server" Value='<%#Eval("CategoryId") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <%--<asp:BoundField DataField="CategoryName" HeaderText="Category Name" />
                    <asp:BoundField DataField="CategoryDescription" HeaderText="Category Description" />
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:ImageButton ID="ImgBtnEdit" runat="server" ImageUrl="~/Images/edit.png" CommandName="Edit" CommandArgument='<%#Eval("CategoryId") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:ImageButton ID="ImgBtnDelete" runat="server" ImageUrl="~/Images/delete.png"
                                OnClientClick="return confirm('Are you sure to delete ?');" CommandName="Del"
                                CommandArgument='<%# Eval("CategoryId") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>--%>
                </Columns>
            </asp:GridView>
</div>
<div class="LineSpace">
<asp:TextBoxWatermarkExtender ID="TxtSearch_TextBoxWatermarkExtender"
                    runat="server" Enabled="True" TargetControlID="TxtSearch"
                    WatermarkCssClass="watermarkclass" WatermarkText="Search By Category Name">
                </asp:TextBoxWatermarkExtender>
                <asp:AutoCompleteExtender ID="TxtSearch_AutoCompleteExtender" runat="server"
                    DelimiterCharacters="" Enabled="True" MinimumPrefixLength="1" ServicePath="~/App_WebServices/KCWebServices.svc" ServiceMethod="AutoCompleteCategoryList" CompletionInterval="1000" EnableCaching="true"
                    TargetControlID="TxtSearch">
                </asp:AutoCompleteExtender>
</div>
<div id="output" class="ShowPopup">
            <div id="closepopup">
                <div id="close" class="ClosePopup">
                </div>
            </div>
            <div id="content" style="overflow:auto; height:120; width:200 " >
            </div>            
           </div>
</div>
</asp:Content>



/////////////////////////////
code
///////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Swash.Objects;
using Swash.BusinessLayer;

namespace Website.ERP.AMS
{
    public partial class CategoryDetails : System.Web.UI.Page
    {
       
       
        int userId;
       
       
        #region Events
        protected void Page_Load(object sender, EventArgs e)
        {
            #region Master Button
            MasterButtonsEvents();//Call
            #endregion Master Button
            this.Form.DefaultButton = ImgBtnSearch.UniqueID;
            userId = 1;
            if (IsPostBack == false)
            {
               // EnableDisableMasterButtons();
                MasterLoad();
                MasterDetails();  

                FillGridViewCategory();
            }
        }
        protected void ImgBtnSearch_Click(object sender, ImageClickEventArgs e)
        {
            FillGridViewCategory();          
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
           
            Response.Redirect("AssetMasterEntry.aspx");
        }
        protected void GridViewCategoryDetails_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridViewCategoryDetails.PageIndex = e.NewPageIndex;
            FillGridViewCategory();
        }
        protected void AddNew(Object Sender, EventArgs e)
        {
            AddNew();
        }
        #endregion
        #region Method for attaching Events to Master Buttons
        private void MasterButtonsEvents()
        {          
            Master.MasterNewItem.Click += AddNew;
        }
        #endregion Method for attaching Events to Master Buttons
        #region Method for Enable Disable Master Button
       
        void MasterLoad()
        {
            Master.MasterNewItem.Enabled = false;
            Master.MasterNewItem.ImageUrl = "~/images/menu-add-new-light.png";
            Master.MasterSave.Enabled = false;
            Master.MasterSave.ImageUrl = "~/images/menu-save-light.png";
            Master.MasterDelete.Enabled = false;
            Master.MasterDelete.ImageUrl = "~/images/menu-delete-light.png";
            Master.MasterReset.Enabled = false;
            Master.MasterReset.ImageUrl = "~/images/menu-reset-light.png";
            Master.MasterPrint.Enabled = false;
            Master.MasterPrint.ImageUrl = "~/images/menu-print-light.png";
        }

        void MasterDetails()
        {
            Master.MasterNewItem.Enabled = true;
            Master.MasterNewItem.ImageUrl = "~/images/menu-add-new.png";
            //Master.MasterPrint.Enabled = true;
           // Master.MasterPrint.ImageUrl = "~/images/menu-print.png";
        }
        #endregion Method for Enable Disable Master Button
        #region Methods
        void FillGridViewCategory()
        {
            List<AMS_CategoryEntry> showCategory = new List<AMS_CategoryEntry>();
            if (ViewState["tmpdate"] == null)
            {
                showCategory = ERPManagement.GetInstance.GetAllCategory();
            }
            else
            {
                showCategory = (List<AMS_CategoryEntry>)ViewState["tmpdate"];
            }

            var result = from category in showCategory
                         where category.CreatedBy==userId
                         select category;
            if (TxtSearch.Text != "")
            {
                result = result.Where(category => category.CategoryName.ToString().ToLower().Trim().StartsWith(TxtSearch.Text.ToString().ToLower().Trim()));
            }
            GridViewCategoryDetails.DataSource = result.ToList();
            GridViewCategoryDetails.DataBind();
        }

        public void AddNew()
        {
            Response.Redirect("CategoryEntry.aspx");
        }

     
       
        #endregion

        protected void GridViewCategoryDetails_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string catid = e.CommandArgument.ToString();
            if (e.CommandName == "Edi")
            {
                Response.Redirect("CategoryEntry.aspx?CategoryId=" + catid);
            }

        }
        //protected void GridViewCategoryDetails_RowCommand(object sender, GridViewCommandEventArgs e)
        //{
        //    string catid = e.CommandArgument.ToString();
        //    if (e.CommandName == "edi")
        //    {
        //        Response.Redirect("CategoryEntry.aspx?CategoryId=" + catid, "_blank", "menubar=0,width=600,height=400,status=yes,toolbar=no,location=no,scrollbars=no,resizable=no,titlebar=no");
        //    }
        //    if (e.CommandName == "Del")
        //    {
        //        ERPManagement.GetInstance.DeleteCategory(int.Parse(catid), userId);
        //        ViewState["tmpdate"] = null;
        //        FillGridViewCategory();
        //    }
        //}
     
    }
}
//////////////////
////
Management
////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Swash.Objects;
using Swash.CacheLayer;
using System.Data;

namespace Swash.BusinessLayer
{
    public partial class ERPManagement
    {
        #region Insert Record
        public void InsertCategory(AMS_CategoryEntry newCategory)
        {
            string Context = "ERPManagement.InsertCategory()";
            try
            {
                ERPCache.InsertCategory(newCategory);
            }
            catch(System.Exception ex)
            {
                throw (new Exception(Context, ex));
            }
        }
        #endregion
        #region Retrieve Record
        public List<AMS_CategoryEntry> GetAllCategory()
        {
            string Context = "ERPManagement.GetAllCategory()";
            try
            {
                return ERPCache.GetAllCategory();
            }
            catch (System.Exception ex)
            {
                throw (new Exception(Context, ex));
            }
        }
        public DataTable GetAllAssetDetailsCategoryWise1(int CategoryId)
        {
            string Context = "ERPManagement.GetAllAssetDetailsCategoryWise()";
            try
            {
                return ERPCache.GetAllAssetDetailsCategoryWise1(CategoryId);
            }
            catch (System.Exception ex)
            {
                throw (new Exception(Context, ex));
            }
        }

        public List<AMS_CategoryEntry> GetAllAssetDetailsCategoryWise(int CategoryId)
        {
            string Context = "ERPManagement.GetAllAssetDetailsCategoryWise()";
            try
            {
                return ERPCache.GetAllAssetDetailsCategoryWise(CategoryId);
            }
            catch (System.Exception ex)
            {
                throw (new Exception(Context, ex));
            }
        }
 
        #endregion
        #region Update Record
        public void UpdateCategory(AMS_CategoryEntry updateCategory)
        {
            string Context = "ERPManagement.UpdateCategory()";
            try
            {
                ERPCache.UpdateCategory(updateCategory);
            }
            catch(System.Exception ex)
            {
                throw (new Exception(Context, ex));
            }
        }
        #endregion
        #region Delete Record
        public void DeleteCategory(int categoryId,int userid)
        {
            string Context = "ERPManagement.DeleteCategory()";
            try
            {
                ERPCache.DeleteCategory(categoryId, userid);
            }
            catch (System.Exception ex)
            {
                throw (new Exception(Context, ex));
            }
        }
        #endregion
    }
}
\\\\\\\\\\\
Cache
/////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Swash.Objects;
using Swash.IntegrationLayer;
using System.Data;

namespace Swash.CacheLayer
{
    public partial class ERPCache
    {
        #region Insert Record
        public static void InsertCategory(AMS_CategoryEntry newCategory)
        {
            ERPIntegration.InsertCategory(newCategory);
        }
        #endregion
        #region Retrieve Record
        public static List<AMS_CategoryEntry> GetAllCategory()
        {
            return ERPIntegration.GetAllCategory();
        }
        public static DataTable  GetAllAssetDetailsCategoryWise1(int CategoryId)
        {
            return ERPIntegration.GetAllAssetDetailsCategoryWise1(CategoryId);
        }
        public static  List<AMS_CategoryEntry> GetAllAssetDetailsCategoryWise(int CategoryId)
        {
            return ERPIntegration.GetAllAssetDetailsCategoryWise(CategoryId);
        }
   
        #endregion
        #region Update Record
        public static void UpdateCategory(AMS_CategoryEntry updateCategory)
        {
            ERPIntegration.UpdateCategory(updateCategory);
        }
        #endregion

        #region Delete Record
        public static void DeleteCategory(int categoryId,int userid)
        {
            ERPIntegration.DeleteCategory(categoryId, userid);
        }
        #endregion
    }
}
\\\\\\\\\\
Integration
////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Swash.Objects;
using Swash.DataAccessLayer;
using System.Data;

namespace Swash.IntegrationLayer
{
    public partial class ERPIntegration
    {
        #region Insert Record
        public static void InsertCategory(AMS_CategoryEntry newCategory)
        {
            ERPDataAccess.GetInstance.InsertCategory(newCategory);
        }
        #endregion
        #region Retrieve Record
        public static List<AMS_CategoryEntry> GetAllCategory()
        {
            List<AMS_CategoryEntry> listCategory = new List<AMS_CategoryEntry>();
            DataTable dtCategory = new DataTable();
            dtCategory = ERPDataAccess.GetInstance.GetAllCategory();
            foreach (DataRow dr in dtCategory.Rows)
            {
                AMS_CategoryEntry objCategory = new AMS_CategoryEntry();
                objCategory.CategoryId = int.Parse(dr["CategoryId"].ToString());
                objCategory.CategoryName = dr["CategoryName"].ToString();
                objCategory.CategoryDescription = dr["CategoryDescription"].ToString();
                objCategory.CreatedBy = int.Parse(dr["CreatedBy"].ToString());
                listCategory.Add(objCategory);      
            }
            return listCategory;
        }

        public static DataTable GetAllAssetDetailsCategoryWise1(int CategoryId)
        {          
            DataTable dtCategory = new DataTable();
            dtCategory = ERPDataAccess.GetInstance.GetAllAssetDetailsCategoryWise(CategoryId);
            return dtCategory;
        }
 
         public static List<AMS_CategoryEntry>GetAllAssetDetailsCategoryWise(int CategoryId)
        {
            List<AMS_CategoryEntry> listCategory = new List<AMS_CategoryEntry>();
            DataTable dtCategory = new DataTable();
            dtCategory = ERPDataAccess.GetInstance.GetAllAssetDetailsCategoryWise(CategoryId );
            foreach (DataRow dr in dtCategory.Rows)
            {
                AMS_CategoryEntry objCategory = new AMS_CategoryEntry();              
                objCategory.CategoryName = dr["CategoryName"].ToString();
                objCategory.AssetName  = dr["AssetName"].ToString();
                objCategory.AssetId = int.Parse(dr["AssetId"].ToString());
                listCategory.Add(objCategory);      
            }
            return listCategory;
        }
 
        #endregion
        #region Update Record
        public static void UpdateCategory(AMS_CategoryEntry updateCategory)
        {
            ERPDataAccess.GetInstance.UpdateCategory(updateCategory);
        }
        #endregion
        #region Delete Record
        public static void DeleteCategory(int categoryId,int userId)
        {
            ERPDataAccess.GetInstance.DeleteCategory(categoryId,userId);
        }
        #endregion
    }
}
///////////////
DataAccess
\\\\\\\\\\\\
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using Swash.Objects;

namespace Swash.DataAccessLayer
{
    public partial class ERPDataAccess
    {
        #region Insert Record
        public void InsertCategory(AMS_CategoryEntry newCategory)
        {
            try
            {
                SqlCommand insertCommand = new SqlCommand("ams.AMS_InsertCategory");
                insertCommand.CommandType = CommandType.StoredProcedure;
                insertCommand.Parameters.Add(GetParameter("@CategoryName", SqlDbType.VarChar, newCategory.CategoryName));
                insertCommand.Parameters.Add(GetParameter("@CategoryDescription", SqlDbType.VarChar, newCategory.CategoryDescription));
                insertCommand.Parameters.Add(GetParameter("@CreatedBy", SqlDbType.Int, newCategory.CreatedBy));
                ExecuteStoredProcedure(insertCommand);
            }
            catch(SqlException ex)
            {
                string s = ex.Message.ToString();
            }
        }
        #endregion
        #region Update Record
        public void UpdateCategory(AMS_CategoryEntry updateCategory)
        {
            SqlCommand UpdateCommand = new SqlCommand("ams.AMS_UpdateCategory");
            UpdateCommand.CommandType = CommandType.StoredProcedure;
            UpdateCommand.Parameters.Add(GetParameter("@CategoryId", SqlDbType.Int, updateCategory.CategoryId));
            UpdateCommand.Parameters.Add(GetParameter("@CategoryName", SqlDbType.VarChar, updateCategory.CategoryName));
            UpdateCommand.Parameters.Add(GetParameter("@CategoryDescription", SqlDbType.VarChar, updateCategory.CategoryDescription));
            UpdateCommand.Parameters.Add(GetParameter("@ModifiedBy", SqlDbType.Int, updateCategory.ModifiedBy));
            ExecuteStoredProcedure(UpdateCommand);
        }
        #endregion
        #region Delete Record
        public void DeleteCategory(int deleteCategoryId,int userId)
        {
            SqlCommand DeleteCommand = new SqlCommand("ams.AMS_DeleteCategory");
            DeleteCommand.CommandType = CommandType.StoredProcedure;
            DeleteCommand.Parameters.Add(GetParameter("@CategoryId", SqlDbType.Int, deleteCategoryId));
            DeleteCommand.Parameters.Add(GetParameter("@ModifiedBy", SqlDbType.Int, userId));
            ExecuteStoredProcedure(DeleteCommand);
        }
        #endregion
        #region Retrieve Record
        public DataTable GetAllCategory()
        {
            DataTable dtCategory = new DataTable();
            SqlCommand selectCommand = new SqlCommand("ams.AMS_SelectCategory");
            selectCommand.CommandType = CommandType.StoredProcedure;
            dtCategory = ExecuteGetDataTable(selectCommand);
            return dtCategory;
        }
        public DataTable GetAllAssetDetailsCategoryWise(int CategoryId)
        {
            DataTable dtGetAsset = new DataTable();
            SqlCommand selectCommand = new SqlCommand("ams.AMS_GetAllAssetDetailsCategoryWise");
            selectCommand.CommandType = CommandType.StoredProcedure;
            selectCommand.Parameters.AddWithValue("@CategoryId", CategoryId);
            dtGetAsset = ExecuteGetDataTable(selectCommand);
            return dtGetAsset;
               

        }

        #endregion

    }
}
////////
Web Service
/////////////////
 #region Fetch AssetNameDetails CategoryID Wise
         [OperationContract]
        public List<AMS_CategoryAssetDetails> GetAllAssetDetailsCategoryWise1(int CategoryId)
        {
            List<AMS_CategoryAssetDetails> AssetList = new List<AMS_CategoryAssetDetails>();
            DataTable dtCategory = new DataTable();
            dtCategory = ERPManagement.GetInstance.GetAllAssetDetailsCategoryWise1(CategoryId); ;
            foreach (DataRow dr in dtCategory.Rows)
            {
                AMS_CategoryAssetDetails catentry = new AMS_CategoryAssetDetails();
                catentry.CategoryName = dr["CategoryName"].ToString().Trim();
                catentry.AssetName = dr["AssetName"].ToString();
                catentry.AssetId = dr["AssetId"].ToString();
                catentry.CategoryId = int.Parse(dr["CategoryId"].ToString());
                AssetList.Add(catentry);
            }
            return AssetList.ToList();
         }
////



No comments:

Post a Comment