Wednesday, February 18, 2015

how to add,edit,delete in popup using jquery and webservices and jquery

Posted by Unknown  |  No comments


 how to add,edit,delete in popup using jquery and webservices and jquery  
 ------------------------------------------------------------------------  
 step 1:  
 ========  
 /*Ready document for dashboard start*/  
 $(document).ready(function () {  
   modelforCustomermasterpopupContactbtnControls();  
 });  
 /*Ready document for dashboard end*/  
 step 2:  
 ========  
 function modelforCustomermasterpopupContactbtnControls() {  
   $('#popupbtnContactsSave).click(function () {  
     switch ($(this)[0].id) {  
       case "popupbtnContactsSave":  
         if ($("#frmContacts").valid()) {  
           var argType = parseInt($('#hdfContsctType').html()) == 1 ? 1 : 3;  
           SaveContactsAddEditDeleteAddress(argType);  
         }  
         break;  
       default:  
         break;  
     }  
   });  
 }  
 step 3:  
 =========  
 /*SaveContactsAddEditDeleteAddress funtion starts here*/  
 function SaveContactsAddEditDeleteAddress(argtype) {  
   var request = {};  
   request.Type = parseInt(argtype);  
   request.ContactID = $('#hdfContactID').html() == '' ? 0 : parseInt($('#hdfContactID').html());  
   request.PartyID = parseInt($('#hdfPartyID').html());  
   request.Name = $("#txtName").val();  
   request.MobileNo = $("#txtMobileNo").val();  
   request.Department = $("#txtDepartment").val();  
   request.Desig = $("#txtDesignation").val();  
   request.EmailID = $("#txtEmailId").val();  
   request.Description = $("#txtDescription").val();  
   $.ajax({  
     type: Http_Post,  
     url: WebNav_AddEditDeleteSupplierContcts,  
     contentType: "application/json; charset=utf-8",  
     dataType: "json",  
     data: '{request: ' + JSON.stringify(request) + '}',  
     success: onCustContactsSuccess,  
     error: onCustomersInfoError  
   });  
 }  
 /* onSaveSuccess function starts here*/  
 function onCustContactsSuccess(response) {  
   switch (response.d.IsValid) {  
     case true:  
       bindPartyContacts(response.d.PartyID);  
        alert("sucess");  
       break;  
     default:  
       break;  
   }  
 }  
 /* onSaveSuccess function end here*/  
 webnvavigation  
 ---------------  
 var WebNav_AddEditDeleteSupplierContcts = "/Services/Masters/SupplierInfo.asmx/AddEditDeleteSupplierContcts"; /*contacts Supplier Master web navigation link By Chandra*/  
 webservices  
 -------------  
 #region Add edit Delete Party Contcts  
     /// <summary>  
     /// To Save Multi Address  
     /// </summary>  
     /// <param name="request"></param>  
     /// <returns></returns>  
     [System.Web.Script.Services.ScriptMethod, System.Web.Services.WebMethod]  
     public PartyContctsResponse AddEditDeleteSupplierContcts(PartyContctsRequest request)  
     {  
       var response = new PartyContctsResponse();  
       try  
       {  
         response = BusinessFactory<MastersBO>.Instance.AddEditDeletePartyContcts(request);  
       }  
       catch (Exception ex)  
       {  
         ExceptionManager.HandleException(ex, request);  
         throw;  
       }  
       return response;  
     }  
     #endregion Add edit Delete Party Contcts  
 BO  
 ----  
 here you can change based on your stored procedures and response code.  
 #region Add edit Delete Party Contcts  
     /// <summary>  
     /// Add edit Delete Party Contcts   
     /// </summary>  
     /// <param name="request"></param>  
     /// <returns></returns>  
     public PartyContctsResponse AddEditDeletePartyContcts(PartyContctsRequest request)  
     {  
       var response = new PartyContctsResponse();  
       response = DataAccessFactory<MastersDAO>.Instance.AddEditDeletePartyContcts(request);  
       switch (response.ResponseCode)  
       {  
         case -999:  
           response.IsValid = false;  
           response.ResponseMessage = Utilities.GetMessage("A04");  
           break;  
         case 1:  
           response.IsValid = true;  
           response.ResponseMessage = Utilities.GetMessage("A37");  
           break;  
         case 2:  
           response.IsValid = true;  
           response.ResponseMessage = Utilities.GetMessage("A38");  
           break;  
         case 3:  
           response.IsValid = true;  
           response.ResponseMessage = Utilities.GetMessage("A39");  
           break;  
         case 4:  
           response.IsValid = true;  
           response.ResponseMessage = Utilities.GetMessage("A40");  
           break;  
         case 5:  
           response.IsValid = true;  
           response.ResponseMessage = Utilities.GetMessage("A41");  
           break;  
         case 6:  
           response.IsValid = true;  
           response.ResponseMessage = Utilities.GetMessage("A42");  
           break;  
       }  
       return response;  
     }  
     #endregion Add SupplierMaster Contacts  
 DAO  
 -------  
 #region Add edit Delete Party Contcts   
     /// <summary>  
     /// Add edit Delete Party Contcts   
     /// </summary>  
     /// <param name="request"></param>  
     /// <returns></returns>  
     public PartyContctsResponse AddEditDeletePartyContcts (PartyContctsRequest request)  
     {  
       var response = new PartyContctsResponse();  
       Database db = DatabaseFactory.CreateDatabase(CommonConstants.CONNECTIONNAME);  
       using (DbCommand dbCommand = db.GetStoredProcCommand(StoredProcedures.spAddEditDeleteCustSuppMasterContacts))  
       {  
         db.AddInParameter(dbCommand, DBParameter.ContactID, DbType.Int32, request.ContactID);  
         db.AddInParameter(dbCommand, DBParameter.PartyID, DbType.Int32, request.PartyID);  
         db.AddInParameter(dbCommand, DBParameter.Type, DbType.Int32, request.Type);  
         db.AddInParameter(dbCommand, DBParameter.Name, DbType.String, request.Name);  
         db.AddInParameter(dbCommand, DBParameter.MobileNo, DbType.String, request.MobileNo);  
         db.AddInParameter(dbCommand, DBParameter.Department, DbType.String, request.Department);  
         db.AddInParameter(dbCommand, DBParameter.Desig, DbType.String, request.Desig);  
         db.AddInParameter(dbCommand, DBParameter.EmailID, DbType.String, request.EmailID);  
         db.AddInParameter(dbCommand, DBParameter.Description, DbType.String, request.Description);  
         db.AddOutParameter(dbCommand, DBParameter.ResponseCode, DbType.Int32, 20);  
         db.ExecuteNonQuery(dbCommand);  
         response.ResponseCode = Convert.ToInt32(db.GetParameterValue(dbCommand, DBParameter.ResponseCode));  
         response.PartyID = request.PartyID;  
       }  
       return response;  
     }  
     #endregion Add SupplierMaster Contacts  
 popup div  
 -----------  
 <div class="modal" id="PrtyContacts-widget" role="dialog" aria-labelledby="myModalLabel"  
     aria-hidden="true">  
     <div class="modal-dialog modelAddressbox">  
       <div class="modal-content">  
         <div class="modal-header">  
           <button type="button" class="close" data-dismiss="modal" aria-label="Close" id="Contactscrossbtn">  
             <span aria-hidden="true">&times;</span></button>  
           <h4 class="modal-title" id="H7">  
             Supplier Contacts</h4>  
         </div>  
         <div class="modal-body">  
           <div class="row">  
             <div class="col-md-12 com-sm-12">  
               <form id="frmContacts">  
               <div class="col-md-6 col-sm-6">  
                 <div class="form-group">  
                   <label for="Name">  
                     <span class="colorred">*</span> Name</label>  
                   <input type="text" class="form-control input-sm" id="txtName" placeholder="Name"  
                     name="Name" required maxlength="30" />  
                   <input type="hidden" id="hdfContactID" />  
                   <input type="hidden" id="hdfPartyID" />  
                   <input type="hidden" id="hdfContsctType" />  
                 </div>  
               </div>  
               <div class="col-md-6 col-sm-6">  
                 <div class="form-group">  
                   <label for="MobileNo">  
                     <span class="colorred">*</span> Mobile No</label>  
                   <input type="text" class="form-control input-sm" placeholder="Mobile No" name="MobileNo"  
                     id="txtMobileNo" required maxlength="50" />  
                 </div>  
               </div>  
               <div class="col-md-6 col-sm-6">  
                 <div class="form-group">  
                   <label for="Designation">  
                     Designation</label>  
                   <input type="text" class="form-control input-sm" placeholder="Designation" name="Designation"  
                     id="txtDesignation" />  
                 </div>  
               </div>  
               <div class="col-md-6 col-sm-6">  
                 <div class="form-group">  
                   <label for="Department">  
                     Department</label>  
                   <input type="text" class="form-control input-sm" placeholder="Department" name="Department"  
                     id="txtDepartment" />  
                 </div>  
               </div>  
               <div class="col-md-6 col-sm-6">  
                 <div class="form-group">  
                   <label for="EmailId">  
                     EmailId</label>  
                   <input type="text" class="form-control input-sm" placeholder="EmailId" name="EmailId"  
                     id="txtEmailId" />  
                 </div>  
               </div>  
               <div class="col-md-6 col-sm-6">  
                 <div class="form-group">  
                   <label for="Description">  
                     Description</label>  
                   <input type="text" class="form-control input-sm" placeholder="Description" name="Description"  
                     id="txtDescription" />  
                 </div>  
               </div>  
               <div class="col-md-4 col-sm-4">  
                 <div class="form-group">  
                   <div class="upload-photo">  
                     <img src="../../Designing/images/defaultuserpic.png" class="img-responsive user">  
                     <div class="uploda-text">  
                       Upload picture  
                       <div class="_3jk">  
                         <input type="file" class="_n _5f0v" title="Choose a file to upload" accept="image/<b>*</b>"  
                           name="file" id="fileAttachments">  
                       </div>  
                     </div>  
                   </div>  
                 </div>  
               </div>  
               </form>  
             </div>  
           </div>  
         </div>  
         <div class="modal-footer">  
           <button class="btn btn-default btn-primary" type="button" id="popupbtnContactsSave"  
             title="Save">  
             Save</button>  
           <button class="btn btn-default" type="button" id="popupbtnContactsDelete" title="Delete">  
             Delete</button>  
           <button class="btn btn-default" type="button" id="popupbtnContactsClose" title="Close"  
             style="display: none">  
             Close</button>  
         </div>  
       </div>  
     </div>  
   </div>  
 storeprocedes  
 -------------  
 USE [EFACTIC_DEV]  
 GO  
 /****** Object: StoredProcedure [dbo].[USP_ADD_EDIT_DELETE_PARTY_CONTACTS]  Script Date: 01/22/2015 13:16:45 ******/  
 SET ANSI_NULLS ON  
 GO  
 SET QUOTED_IDENTIFIER ON  
 GO  
 -- =============================================  
 -- Author     :          GNANI .P  
 -- Create date     :          19/01/2015  
 -- Description     :          FOR SUPPLIER AND CUSTOMER CONTACTS  
 -- =============================================  
 ALTER PROCEDURE [dbo].[USP_ADD_EDIT_DELETE_PARTY_CONTACTS]  
       @ContactID               INT  
      ,@PartyID               INT                      
      ,@Name                    NVARCHAR(75)     =NULL       
      ,@MobileNo               NVARCHAR(100)     =NULL  
      ,@Department          NVARCHAR(100)     =NULL  
      ,@Desig                    VARCHAR(50)          =NULL  
      ,@EmailID               NVARCHAR(50)     =NULL  
      ,@Description          NVARCHAR(250)     =NULL  
      ,@TYPE                    INT                    =NULL  
      ,@ResponseCode          BIGINT               OUTPUT       
 AS  
 BEGIN  
      BEGIN TRY  
           IF @Type = 1     --ADD CUST MASTER CONTACTS.  
           BEGIN                 
                INSERT INTO dbo.MstCustContacts(CustID,Name,MobileNo,Department,Desig,EmailID,[Description]) VALUES (@PartyID,@Name,@MobileNo,@Department,@Desig,@EmailID,@Description)  
                SET @ResponseCode=1     --ADD SUCCESS FOR CUSTOMER MASTER.  
           END                 
           IF @Type = 2     --ADD SUPP MASTER CONTACTS.  
           BEGIN  
                INSERT INTO dbo.MstSuppContacts(SuppID,Name,MobileNo,Department,Desig,EmailID,[Description]) VALUES (@PartyID,@Name,@MobileNo,@Department,@Desig,@EmailID,@Description)  
                SET @ResponseCode=2     --ADD SUCCESS FOR SUPPLIER MASTER.  
           END                 
           IF @Type = 3     --EDIT CUST MASTER CONTACTS.  
           BEGIN  
                UPDATE dbo.MstCustContacts SET  Name               =     @Name  
                                                        ,MobileNo          =     @MobileNo  
                                                        ,Desig               =     @Desig  
                                                        ,Department          =     @Department  
                                                        ,EmailID          =     @EmailID  
                                                        ,[Description]     =     @Description  
                                                        WHERE CustID     =     @PartyID AND ContactID=@ContactID  
                SET @ResponseCode=3     --EDIT SUCCESS FOR CUSTOMER MASTER.  
           END       
           IF @Type = 4     --EDIT SUPP MASTER CONTACTS.  
           BEGIN  
                UPDATE dbo.MstSuppContacts SET  Name               =     @Name  
                                                        ,MobileNo          =     @MobileNo  
                                                        ,Desig               =     @Desig  
                                                        ,Department          =     @Department  
                                                        ,EmailID          =     @EmailID  
                                                        ,[Description]     =     @Description  
                                                        WHERE SuppID     =     @PartyID AND ContactID=@ContactID  
                SET @ResponseCode=4     --DELETE SUCCESS FOR SUPPLIER MASTER.  
           END  
           IF @Type = 5     --DELETE CUST MASTER CONTACTS.  
           BEGIN  
                DELETE dbo.MstCustContacts WHERE CustID     =     @PartyID      AND ContactID=@ContactID  
                SET @ResponseCode=5     --EDIT SUCCESS FOR CUSTOMER MASTER.  
           END       
           IF @Type = 6     --DELETE SUPP MASTER CONTACTS.  
           BEGIN  
                DELETE dbo.MstSuppContacts WHERE SuppID     =     @PartyID      AND ContactID=@ContactID  
                SET @ResponseCode=6     --DELETE SUCCESS FOR SUPPLIER MASTER.  
           END  
      END TRY  
      BEGIN CATCH  
           SELECT ERROR_MESSAGE()   
           SELECT ERROR_LINE ( )  
           SET @ResponseCode =-999     --OOPS SOMETHING WENT WRONG.  
      END CATCH       
 END  

2:19 AM Share:

0 comments:

Get updates in your email box
Complete the form below, and we'll send you the best coupons.

Deliver via FeedBurner
Proudly Powered by Blogger.
back to top