Thursday, August 28, 2014

Visual Studio IDE restarted during Crystal report design time

If you are working in crystal report which is copied from another report then Visual Studio may be restated without any reason. To avoid this you should take a new crystal report not the copied. 

Wednesday, August 27, 2014

kendo grid checkbox check validation

In the following above image i want to transfer from left side grid data to right side grid & only the selected grid item. I will check that
- The left grid can check more than one checkbox
- right side grid will check only one.
- left & right side selection item will not same.

Then all the selected check box in the left side will get for right side person for save or update as you want.

Transfer button click:


 <button type="submit" class="btn btn-mini btn-primary" onclick="AccountsManagerTransferResponsiblity()">  
           <i class="icon-retweet"></i>Transfer  
         </button>  

Script:


  function AccountsManagerTransferResponsiblity() {  
     var gridData1 = $("#CustomerAccountManagerKendoGrid1").data("kendoGrid").dataSource.data();  
     var gridData2 = $("#CustomerAccountManagerKendoGrid2").data("kendoGrid").dataSource.data();  
     if (!CheckGridConstraint(gridData1, gridData2)) return;  
     // var gEmpID1 = GetSelectedEmpID(gridData1);  
     // Get selected grid value   
     var gEmpID2 = GetSelectedEmpID(gridData2);  
     //get the grid from left side   
      var gridData = $("#CustomerAccountManagerKendoGrid1").data("kendoGrid").dataSource.data();  
     // set model data   
      for (var i = 0; i < gridData.length; i++) {  
      }  
     var postUrl;  
     var paramValue;  
     // Your controller action path  
     postUrl = '@Url.Content("~/Billing/CustomerAccountManage/AccountsManagerTransferResponsiblityAction")';  
     paramValue = JSON.stringify(  
     {  
       'pEmpID1': gEmpID1  
       , 'pEmpID2': gEmpID2  
       , ManagerList: gridData // passing the grid value in controller as parameter  
     });  
     $.ajax({  
       url: postUrl,  
       type: 'POST',  
       dataType: 'json',  
       data: paramValue,  
       contentType: 'application/json; charset=utf-8',  
       success: function (result) {  
         console.log(result);  
       },  
       error: function (objAjaxRequest, strError) {  
         var respText = objAjaxRequest.responseText;  
         console.log(respText);  
       }  
     });  
   }  


Validation Script:


  function CheckGridConstraint(gridData1, gridData2) {  
     if (!CheckMultipleSelection(gridData1, gridData2)) {  
       return false;  
     }  
     if (!CheckSameEmployeeSelect(gridData1, gridData2)) {  
       alert("Please select different employee to TransferResponsiblity");  
       return false;  
     }  
     return true;  
   }  
   function CheckMultipleSelection(gridData1, gridData2) {  
     var gridCheckCount = 0;  
     //for (var i = 0; i < gridData1.length; i++) {  
     //  if (gridData1[i].SelectStatus == true) {  
     //    gridCheckCount += 1;  
     //  }  
     //}  
     if (gridCheckCount > 1) {  
       alert("Please select one record for left grid");  
       return false;  
     }  
     gridCheckCount = 0;  
     for (var i = 0; i < gridData2.length; i++) {  
       if (gridData2[i].SelectStatus == true) {  
         gridCheckCount += 1;  
       }  
     }  
     if (gridCheckCount > 1) {  
       alert("Please select one record for right grid");  
       return false;  
     }  
     return true;  
   }  
   function CheckSameEmployeeSelect(gridData1, gridData2) {  
     var gd1EmpID;  
     var gd2EmpID;  
     for (var i = 0; i < gridData1.length; i++) {  
       if (gridData1[i].SelectStatus == true) {  
         gd1EmpID = gridData1[i].GEmployeeGenInfoID;  
         for (var j = 0; j < gridData2.length; j++) {  
           if (gridData2[i].SelectStatus == true) {  
             gd2EmpID = gridData2[j].GEmployeeGenInfoID;  
             if (gd1EmpID == gd2EmpID) {  
               return false;  
             }  
           }  
         }  
       }  
     }  
     return true;  
   }  

Get right side single check value:


  function GetSelectedEmpID(gridData) {  
     for (var i = 0; i < gridData.length; i++) {  
       if (gridData[i].SelectStatus == true) {  
         return gridData[i].GEmployeeGenInfoID;  
       }  
     }  
   }  

Get value in controller:


   public ActionResult AccountsManagerTransferResponsiblityAction(string pEmpID1, string pEmpID2, CustomerAccountManagerViewModel _CustomerAccountManagemodel)  
     {  
       var strMessage = string.Empty;  
       Guid EmpID1 = new Guid(pEmpID1);  
       Guid EmpID2 = new Guid(pEmpID2);  
       DateTime TodayDate = DateTime.Now;  
       try  
       {  
         foreach (var item in _CustomerAccountManagemodel.ManagerList.Where(m => m.SelectStatus == true))  
         {  
           IList<DJBL_tblCustomerAccountManagerAssignRelease> listCustomerAccountManagerAssign1 = _billingCommonservice.BillingUnit.CustomerAccountManagerAssignReleaseRepository.Get(d => d.GEmployeeGenInfoID == item.GEmployeeGenInfoID).ToList();  
           DJBL_tblCustomerAccountManagerAssignRelease custAssRelease = null;  
           // Assign Release Insert  
           foreach (var CustAssignRelease in listCustomerAccountManagerAssign1)  
           {  
             custAssRelease = new DJBL_tblCustomerAccountManagerAssignRelease();  
             custAssRelease.CustomerAccountManagerAssignReleaseID = Guid.NewGuid();  
             custAssRelease.CustomerID = CustAssignRelease.CustomerID;  
             custAssRelease.GEmployeeGenInfoID = EmpID2;  
             custAssRelease.AssignDate = TodayDate;  
             custAssRelease.BooketID = CustAssignRelease.BooketID;  
             custAssRelease.ReleaseDate = null;  
             _billingCommonservice.BillingUnit.CustomerAccountManagerAssignReleaseRepository.Add(custAssRelease);  
           }  
           //Assign Release Update   
           foreach (var am in listCustomerAccountManagerAssign1)  
           {  
             am.ReleaseDate = TodayDate;  
             _billingCommonservice.BillingUnit.CustomerAccountManagerAssignReleaseRepository.Update(am, "CustomerAccountManagerAssignReleaseID");  
           }  
           //Transfer responsiblity Insert   
           foreach (var transfer in listCustomerAccountManagerAssign1)  
           {  
             SaveCustomerAccountManagerTransferResponsiblityHistory((Guid)transfer.GEmployeeGenInfoID, EmpID2, TodayDate, (Guid)transfer.BooketID);  
           }  
           _billingCommonservice.BillingUnit.CustomerAccountManagerAssignReleaseRepository.SaveChanges();  
         }  
         return Content(Boolean.TrueString);  
       }  
       catch (Exception ex)  
       {  
         strMessage = CommonExceptionMessage.GetExceptionMessage(ex, CommonAction.Save);  
       }  
       return Content(strMessage);  
     }  


Both Grid binding same i just share one grid binding:


 $("#CustomerAccountManagerKendoGrid1").kendoGrid({  
     dataSource: {  
       transport: {  
         read: "CustomerAccountManageRead"  
       },  
       schema: {  
         model: {  
           fields: {  
             CustomerAccountManageID: { type: "string" },  
             GEmployeeGenInfoID: { type: "string", editable: false },  
             ManagerName: { type: "string", editable: false },  
             SelectStatus: { type: "boolean" },  
           }  
         }  
       },  
       pageSize: 20,  
       serverPaging: false,  
       serverFiltering: false,  
       serverSorting: false,  
     },  
     height: 300,  
     filterable: true,  
     //groupable: true,  
     sortable: true,  
     resizable: true,  
     selectable: true,  
     editable: true,  
     pageable:  
     {  
       refresh: true,  
       pageSizes: [10, 20, 40, 60, 80, 100]  
     },  
     columns:  
     [  
       { field: "SelectStatus", title: " ", width: "5%", template: "<input type='checkbox' #= SelectStatus ? checked='checked':'' # class='chkbx' />" },  
       { field: "CustomerAccountManageID", title: "CustomerAccountManageID", hidden: true, filterable: false, sortable: false },  
       { field: "GEmployeeGenInfoID", title: "GEmployeeGenInfoID", hidden: true, filterable: false, sortable: false },  
       { field: "ManagerName", title: "Manager Name", width: "35%" },  
     ]  
   });  

Grid load:


  public JsonResult CustomerAccountManageRead()  
     {  
       var models = CustomerAccountManage();  
       return Json(models, JsonRequestBehavior.AllowGet);  
     }     


  private List<AssignManagerViewModel> CustomerAccountManage()  
     {  
       IList<DJBL_uspGetAllAssignManager_Result> dataList = null;  
       dataList = _billingCommonservice.BillingUnit.FunctionRepository.AssignManagerValue().ToList();  
       List<AssignManagerViewModel> seriesList = new List<AssignManagerViewModel>();  
       foreach (var md in dataList)  
       {  
         AssignManagerViewModel obj = new AssignManagerViewModel();  
         obj.GEmployeeGenInfoID = md.GEmployeeGenInfoID ?? Guid.Empty;  
         obj.ManagerName = md.ManagerName;  
         obj.ManagerDesignation = md.ManagerDesignation;  
         obj.ManagerDepartment = md.ManagerDepartment;  
         obj.ManagerEmpID = md.ManagerEmpID;  
         obj.ManagerEmpCardNo = md.ManagerEmpCardNo;  
         obj.NoOfCustomer = Convert.ToInt32(md.NoOfCustomer);  
         seriesList.Add(obj);  
       }  
       var PackageInfoInfoViewModels = seriesList.Select(  
         md => new AssignManagerViewModel  
              {  
                GEmployeeGenInfoID = md.GEmployeeGenInfoID,  
                ManagerName = md.ManagerName,  
                ManagerDesignation = md.ManagerDesignation,  
                ManagerDepartment = md.ManagerDepartment,  
                ManagerEmpID = md.ManagerEmpID,  
                ManagerEmpCardNo = md.ManagerEmpCardNo,  
                NoOfCustomer = md.NoOfCustomer,  
                ActionLink = Common.KendoUIGridActionLinkGenerate("Billing", "CustomerAccountManage", md.GEmployeeGenInfoID.ToString(), true, true, false)  
              }).OrderBy(o => o.ManagerName).ThenBy(ot => ot.ManagerEmpID);  
       return PackageInfoInfoViewModels.ToList();  
     }  


Thank you.


Wednesday, August 20, 2014

Unable to find the report in the manifest resources. Please build the project, and try again.




After following the process
If you are using your report class for your report then don’t convert the report in content.Then this problem will not arise again.







Right click on your solution or crystal report folder. Go to Open Folder In File Explorer.


Select your report. You have to choose only the rpt file not the cs file of your report.


Copy the report & save it Desktop or another place.

Now Delete the crystal report, If you are using source controller also delete from it.

Now add the report as existing file where you save the rpt file, It will automatically generate it’s cs file.

Now build & run your solution.

Monday, August 11, 2014

Crystal report formula for hiding page header or footer in last page


#Step:1




#Step:2



#Step:3



Please put this formual in Page Header or Page Footer->Section Expert-> Suppress


 PageNumber=TotalPageCount  


Hope it will help you.


Sunday, August 10, 2014

Page wise total in Crystal Report


Create a formula field TOTAL1 and edit this code:

 WhilePrintingRecords;  
 NumberVar total;  
 total := 0;  



Place TOTAL1 in page header section.
Create a formula field TOTAL2 and edit this code:

 WhilePrintingRecords;  
 NumberVar total;  
 total := total + CDbl ({field01})  


where field01 is the field to summarize & CDbl is converting.
Place TOTAL2 in details section.

Create a formula field TOTAL3 and edit this code:

 WhilePrintingRecords;  
 NumberVar total;  



Place TOTAL3 in page footer.


you can also see This

 
 











SQL Get all Index create script from Database

To get all script from database as a create new index into another database you can use the following --Get all Index Script SELECT...