/// <summary>
 /// Function to delete particular details based on the parameter
 /// </summary>
 /// <param name="SalaryPackageId"></param>
 public void SalaryPackageDetailsDeleteWithSalaryPackageId(decimal SalaryPackageId)
 {
     try
     {
         spSalaryPackageDetails.SalaryPackageDetailsDeleteWithSalaryPackageId(SalaryPackageId);
     }
     catch (Exception ex)
     {
         MessageBox.Show("AL2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        public JsonResult SaveSalaryPackage(string salaryPackageId, string salaryPackageName, string active, string narration, string jsonDetails, string totalAmount)
        {
            bool              isSave            = true;
            string            message           = "success";
            SalaryPackageInfo infoSalaryPackage = new SalaryPackageInfo();

            try
            {
                SalaryPackageSP        spSalaryPackage        = new SalaryPackageSP();
                SalaryPackageDetailsSP spSalaryPackageDetails = new SalaryPackageDetailsSP();
                int   nSalaryPackageId = int.Parse(salaryPackageId);
                float fTotalAmount     = float.Parse(totalAmount);
                bool  isActive         = bool.Parse(active);
                infoSalaryPackage.SalaryPackageId   = nSalaryPackageId;
                infoSalaryPackage.SalaryPackageName = salaryPackageName;
                infoSalaryPackage.Narration         = narration;
                infoSalaryPackage.Extra1            = string.Empty;
                infoSalaryPackage.Extra2            = string.Empty;
                infoSalaryPackage.IsActive          = isActive;
                infoSalaryPackage.TotalAmount       = Convert.ToDecimal(totalAmount);

                if (nSalaryPackageId > 0) // edit mode
                {
                    spSalaryPackage.SalaryPackageEdit(infoSalaryPackage);
                    spSalaryPackageDetails.SalaryPackageDetailsDeleteWithSalaryPackageId(nSalaryPackageId);
                    isSave = SavePayHeadDetails(spSalaryPackageDetails, jsonDetails, nSalaryPackageId);
                    if (!isSave)
                    {
                        spSalaryPackage.SalaryPackageDeleteAll(nSalaryPackageId);
                    }
                }
                else
                {
                    nSalaryPackageId = (int)spSalaryPackage.SalaryPackageAdd(infoSalaryPackage);
                    if (nSalaryPackageId != -1)
                    {
                        infoSalaryPackage.SalaryPackageId = nSalaryPackageId;
                        isSave = SavePayHeadDetails(spSalaryPackageDetails, jsonDetails, nSalaryPackageId);
                        if (!isSave)
                        {
                            spSalaryPackage.SalaryPackageDeleteAll(nSalaryPackageId);
                        }
                    }
                    else
                    {
                        message = "Package name already exists";
                    }
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }


            return(Json(new {
                isSuccess = isSave,
                messaage = message,
                data = infoSalaryPackage
            }));
        }