private bool SavePayHeadDetails(SalaryPackageDetailsSP spSalaryPackageDetails, string jsonDetails, int nSalaryPackageId)
        {
            bool isSave = false;

            try
            {
                List <Dictionary <string, object> > items = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(jsonDetails);

                for (int i = 0; i < items.Count; i++)
                {
                    SalaryPackageDetailsInfo infoSalaryPackageDetails = new SalaryPackageDetailsInfo();
                    infoSalaryPackageDetails.PayHeadId       = Convert.ToDecimal(items[i]["payHeadId"]);
                    infoSalaryPackageDetails.Amount          = Convert.ToDecimal(items[i]["Amount"]);
                    infoSalaryPackageDetails.Narration       = items[i]["Narration"].ToString();
                    infoSalaryPackageDetails.SalaryPackageId = nSalaryPackageId;
                    infoSalaryPackageDetails.Extra1          = string.Empty;
                    infoSalaryPackageDetails.Extra2          = string.Empty;
                    if (spSalaryPackageDetails.SalaryPackageDetailsAdd(infoSalaryPackageDetails))
                    {
                        isSave = true;
                    }
                    else
                    {
                        isSave = false;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                isSave = false;
            }

            return(isSave);
        }
        public JsonResult GetSalaryPackageDetails(string salaryPackageId)
        {
            int                    nSalaryPackageId      = int.Parse(salaryPackageId);
            SalaryPackageSP        spSalaryPackage       = new SalaryPackageSP();
            SalaryPackageDetailsSP spSalaryPackageDetils = new SalaryPackageDetailsSP();
            SalaryPackageInfo      infoSalaryPackage     = new SalaryPackageInfo();
            string                 jsonDetails           = "";

            if (nSalaryPackageId > 0)
            {
                infoSalaryPackage = spSalaryPackage.SalaryPackageView(nSalaryPackageId);
                DataTable dtblSalaryPackageDetails = spSalaryPackageDetils.SalaryPackageDetailsViewWithSalaryPackageId(nSalaryPackageId);
                jsonDetails = Utils.ConvertDataTabletoString(dtblSalaryPackageDetails);
            }

            PayHeadSP spPayhead    = new PayHeadSP();
            DataTable dtblPayheads = spPayhead.PayHeadViewAll();
            string    jsonPayheads = Utils.ConvertDataTabletoString(dtblPayheads);

            return(Json(new
            {
                isSuccess = true,
                message = "success",
                data = new
                {
                    salaryPackageId = infoSalaryPackage.SalaryPackageId,
                    salaryPackageName = infoSalaryPackage.SalaryPackageName,
                    narration = infoSalaryPackage.Narration,
                    isActive = infoSalaryPackage.IsActive,
                    salaryPackageDetails = jsonDetails,
                    payHeads = jsonPayheads
                }
            }));
        }
Beispiel #3
0
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         SalaryPackageDetailsSP spSalaryPackageDetails = new SalaryPackageDetailsSP();
         DataTable dtbl = spSalaryPackageDetails.SalaryPackageDetailsForSalaryPackageDetailsReport(cmbSalaryPackage.Text);
         dgvSalaryPackageDetails.DataSource = dtbl;
         decCountAdditon   = 0;
         decCountDeduction = 0;
         decTotalAmount    = 0;
         foreach (DataGridViewRow dgvRaw in dgvSalaryPackageDetails.Rows)
         {
             if (dgvRaw.Cells["dgvtxttype"].Value.ToString() == "Addition")
             {
                 decimal decAmt = Convert.ToDecimal(dgvRaw.Cells["txtAmount"].Value.ToString());
                 decCountAdditon = decCountAdditon + decAmt;
             }
             else
             {
                 decimal decAmt = Convert.ToDecimal(dgvRaw.Cells["txtAmount"].Value.ToString());
                 decCountDeduction = decCountDeduction + decAmt;
             }
             if (dgvRaw.Cells["txtAmount"].Value != null && dgvRaw.Cells["txtAmount"].Value.ToString() != "")
             {
                 decimal decAmt = Convert.ToDecimal(dgvRaw.Cells["txtAmount"].Value.ToString());
                 decTotalAmount = decTotalAmount + decAmt;
             }
         }
         txttotalReduction.Text = Math.Round(decCountDeduction, PublicVariables._inNoOfDecimalPlaces).ToString();
         txttotalAddition.Text  = Math.Round(decCountAdditon, PublicVariables._inNoOfDecimalPlaces).ToString(); //Convert.ToString(decCountAdditon);
         txtTotal.Text          = Math.Round(decTotalAmount, PublicVariables._inNoOfDecimalPlaces).ToString();  //Convert.ToString(decTotalAmount);
     }
     catch (Exception ex)
     {
         MessageBox.Show("SPDR:1" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #4
0
 /// <summary>
 /// On 'Print' button click to Print
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnPrint_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvSalaryPackageDetails.RowCount > 0)
         {
             DataTable dtblOther   = new DataTable();
             frmReport frmreport   = new frmReport();
             DataSet   ds          = new DataSet();
             CompanySP spCompany   = new CompanySP();
             DataTable dtblCompany = spCompany.CompanyViewDataTable(1);
             SalaryPackageDetailsSP spSalaryPackageDetails = new SalaryPackageDetailsSP();
             DataTable dtbl = spSalaryPackageDetails.SalaryPackageDetailsForSalaryPackageDetailsReport(cmbSalaryPackage.Text);
             ds.Tables.Add(dtblCompany);
             ds.Tables.Add(dtbl);
             ds.Tables.Add(dtblOther);
             DataColumn dc = new DataColumn("Addition", typeof(decimal));
             dtblOther.Columns.Add(dc);
             dc = new DataColumn("Deduction", typeof(decimal));
             dtblOther.Columns.Add(dc);
             DataRow dr = dtblOther.NewRow();
             dr[0] = decCountAdditon;
             dr[1] = decCountDeduction;
             dtblOther.Rows.InsertAt(dr, 0);
             frmreport.MdiParent = formMDI.MDIObj;
             frmreport.SalaryPackageDetailsReport(ds);
         }
         else
         {
             Messages.InformationMessage("No data found");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SPDR:7" + ex.Message, "Open Miracle", 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
            }));
        }