/// <summary>
        /// Function to insert values to SalaryPackage Table
        /// </summary>
        /// <param name="salarypackageinfo"></param>
        /// <returns></returns>
        public decimal SalaryPackageAdd(SalaryPackageInfo salarypackageinfo)
        {
            decimal decIdentity = -1;

            try
            {
                decIdentity = spSalaryPackage.SalaryPackageAdd(salarypackageinfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show("AL2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(decIdentity);
        }
Exemplo n.º 2
0
        public void SaveFunction()
        {
            try
            {
                SalaryPackageInfo salaryInfo = new SalaryPackageInfo();
                SalaryPackageSP   salarySp   = new SalaryPackageSP();


                for (int i = 0; i < dgvSalaryPackage.RowCount - 1; i++)
                {
                    if (dgvSalaryPackage.Rows[i].Cells["dgvPayHead"].Value.ToString() != string.Empty && dgvSalaryPackage.Rows[i].Cells["dgvPayHead"].Value != null)
                    {
                        salaryInfo.PayHead = Convert.ToString(dgvSalaryPackage.Rows[i].Cells["dgvPayHead"].Value);
                    }

                    if (dgvSalaryPackage.Rows[i].Cells["dgvPayType"].Value.ToString() != string.Empty && dgvSalaryPackage.Rows[i].Cells["dgvPayType"].Value != null)
                    {
                        salaryInfo.PayType = Convert.ToString(dgvSalaryPackage.Rows[i].Cells["dgvPayType"].Value);
                    }

                    if (dgvSalaryPackage.Rows[i].Cells["dgvAmount"].Value.ToString() != string.Empty && dgvSalaryPackage.Rows[i].Cells["dgvAmount"].Value != null)
                    {
                        salaryInfo.Amount = Convert.ToDecimal(dgvSalaryPackage.Rows[i].Cells["dgvAmount"].Value);
                    }

                    bool isCellChecked = (bool)dgvSalaryPackage.Rows[i].Cells["dgvtxtIsActive"].Value;

                    if (isCellChecked == true)
                    {
                        salaryInfo.IsActive = true;
                    }
                    else
                    {
                        salaryInfo.IsActive = false;
                    }


                    salarySp.SalaryPackageAdd(salaryInfo);
                }

                clearfielsd();
                Messages.SavedMessage();
            }
            catch (Exception ex)
            {
                MessageBox.Show(" SaveFunction " + ex.Message);
            }
        }
        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
            }));
        }