/// <summary>
        /// Function to insert values to DailySalaryVoucherMaster Table
        /// </summary>
        /// <param name="dailysalaryvouchermasterinfo"></param>
        public void DailySalaryVoucherMasterAdd(DailySalaryVoucherMasterInfo dailysalaryvouchermasterinfo)
        {
            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("DailySalaryVoucherMasterAdd", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam = sccmd.Parameters.Add("@dailySalaryVoucherMasterId", SqlDbType.Decimal);
                sprmparam.Value = dailysalaryvouchermasterinfo.DailySalaryVoucehrMasterId;
                sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
                sprmparam.Value = dailysalaryvouchermasterinfo.LedgerId;
                sprmparam = sccmd.Parameters.Add("@voucherNumber", SqlDbType.VarChar);
                sprmparam.Value = dailysalaryvouchermasterinfo.VoucherNo;
                sprmparam = sccmd.Parameters.Add("@invoiceNumber", SqlDbType.VarChar);
                sprmparam.Value = dailysalaryvouchermasterinfo.InvoiceNo;
                sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
                sprmparam.Value = dailysalaryvouchermasterinfo.Date;
                sprmparam = sccmd.Parameters.Add("@salaryDate", SqlDbType.DateTime);
                sprmparam.Value = dailysalaryvouchermasterinfo.SalaryDate;
                sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
                sprmparam.Value = dailysalaryvouchermasterinfo.TotalAmount;
                sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value = dailysalaryvouchermasterinfo.Narration;
                sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
                sprmparam.Value = dailysalaryvouchermasterinfo.ExtraDate;
                sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = dailysalaryvouchermasterinfo.Extra1;
                sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = dailysalaryvouchermasterinfo.Extra2;
                sprmparam = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
                sprmparam.Value = dailysalaryvouchermasterinfo.SuffixPrefixId;
                sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
                sprmparam.Value = dailysalaryvouchermasterinfo.VoucherTypeId;
                sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
                sprmparam.Value = dailysalaryvouchermasterinfo.FinancialYearId;
                sccmd.ExecuteNonQuery();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Function to insert values to DailySalaryVoucherMaster Table and return the Curresponding row's Id
        /// </summary>
        /// <param name="dailysalaryvouchermasterinfo"></param>
        /// <param name="IsAutomatic"></param>
        /// <returns></returns>
        public DataTable DailySalaryVoucherMasterAddWithIdentity(DailySalaryVoucherMasterInfo dailysalaryvouchermasterinfo, bool IsAutomatic)
        {
            DataTable dtbl = new DataTable();

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlDataAdapter sqlda = new SqlDataAdapter("DailySalaryVoucherMasterAddWithIdentity", sqlcon);
                sqlda.SelectCommand.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@ledgerId", SqlDbType.Decimal);
                sprmparam.Value = dailysalaryvouchermasterinfo.LedgerId;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@voucherNo", SqlDbType.VarChar);
                sprmparam.Value = dailysalaryvouchermasterinfo.VoucherNo;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
                sprmparam.Value = dailysalaryvouchermasterinfo.InvoiceNo;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@date", SqlDbType.DateTime);
                sprmparam.Value = dailysalaryvouchermasterinfo.Date;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@salaryDate", SqlDbType.DateTime);
                sprmparam.Value = dailysalaryvouchermasterinfo.SalaryDate;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@totalAmount", SqlDbType.Decimal);
                sprmparam.Value = dailysalaryvouchermasterinfo.TotalAmount;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value = dailysalaryvouchermasterinfo.Narration;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = dailysalaryvouchermasterinfo.Extra1;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = dailysalaryvouchermasterinfo.Extra2;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
                sprmparam.Value = dailysalaryvouchermasterinfo.SuffixPrefixId;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
                sprmparam.Value = dailysalaryvouchermasterinfo.VoucherTypeId;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@isAutomatic", SqlDbType.Bit);
                sprmparam.Value = IsAutomatic;
                sprmparam       = sqlda.SelectCommand.Parameters.Add("@financialYearId", SqlDbType.Decimal);
                sprmparam.Value = dailysalaryvouchermasterinfo.FinancialYearId;
                sqlda.Fill(dtbl);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(dtbl);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Function to insert values to DailySalaryVoucherMaster Table
 /// </summary>
 /// <param name="dailysalaryvouchermasterinfo"></param>
 public void DailySalaryVoucherMasterAdd(DailySalaryVoucherMasterInfo dailysalaryvouchermasterinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("DailySalaryVoucherMasterAdd", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@dailySalaryVoucherMasterId", SqlDbType.Decimal);
         sprmparam.Value = dailysalaryvouchermasterinfo.DailySalaryVoucehrMasterId;
         sprmparam       = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = dailysalaryvouchermasterinfo.LedgerId;
         sprmparam       = sccmd.Parameters.Add("@voucherNumber", SqlDbType.VarChar);
         sprmparam.Value = dailysalaryvouchermasterinfo.VoucherNo;
         sprmparam       = sccmd.Parameters.Add("@invoiceNumber", SqlDbType.VarChar);
         sprmparam.Value = dailysalaryvouchermasterinfo.InvoiceNo;
         sprmparam       = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = dailysalaryvouchermasterinfo.Date;
         sprmparam       = sccmd.Parameters.Add("@salaryDate", SqlDbType.DateTime);
         sprmparam.Value = dailysalaryvouchermasterinfo.SalaryDate;
         sprmparam       = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
         sprmparam.Value = dailysalaryvouchermasterinfo.TotalAmount;
         sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = dailysalaryvouchermasterinfo.Narration;
         sprmparam       = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime);
         sprmparam.Value = dailysalaryvouchermasterinfo.ExtraDate;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = dailysalaryvouchermasterinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = dailysalaryvouchermasterinfo.Extra2;
         sprmparam       = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
         sprmparam.Value = dailysalaryvouchermasterinfo.SuffixPrefixId;
         sprmparam       = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = dailysalaryvouchermasterinfo.VoucherTypeId;
         sprmparam       = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
         sprmparam.Value = dailysalaryvouchermasterinfo.FinancialYearId;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Function to get particular values from DailySalaryVoucherMaster Table based on the parameter
        /// </summary>
        /// <param name="dailySalaryVoucehrMasterId"></param>
        /// <returns></returns>
        public DailySalaryVoucherMasterInfo DailySalaryVoucherMasterView(decimal dailySalaryVoucehrMasterId)
        {
            DailySalaryVoucherMasterInfo dailysalaryvouchermasterinfo = new DailySalaryVoucherMasterInfo();
            SqlDataReader sdrreader = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("DailySalaryVoucherMasterView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@dailySalaryVoucherMasterId", SqlDbType.Decimal);
                sprmparam.Value = dailySalaryVoucehrMasterId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    dailysalaryvouchermasterinfo.DailySalaryVoucehrMasterId = decimal.Parse(sdrreader[0].ToString());
                    dailysalaryvouchermasterinfo.LedgerId       = decimal.Parse(sdrreader[1].ToString());
                    dailysalaryvouchermasterinfo.VoucherNo      = sdrreader[2].ToString();
                    dailysalaryvouchermasterinfo.InvoiceNo      = sdrreader[3].ToString();
                    dailysalaryvouchermasterinfo.Date           = DateTime.Parse(sdrreader[4].ToString());
                    dailysalaryvouchermasterinfo.SalaryDate     = DateTime.Parse(sdrreader[5].ToString());
                    dailysalaryvouchermasterinfo.TotalAmount    = decimal.Parse(sdrreader[6].ToString());
                    dailysalaryvouchermasterinfo.Narration      = sdrreader[7].ToString();
                    dailysalaryvouchermasterinfo.ExtraDate      = DateTime.Parse(sdrreader[8].ToString());
                    dailysalaryvouchermasterinfo.Extra1         = sdrreader[9].ToString();
                    dailysalaryvouchermasterinfo.Extra2         = sdrreader[10].ToString();
                    dailysalaryvouchermasterinfo.SuffixPrefixId = decimal.Parse(sdrreader[11].ToString());
                    dailysalaryvouchermasterinfo.VoucherTypeId  = decimal.Parse(sdrreader[12].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(dailysalaryvouchermasterinfo);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Function to Daily Salary Voucher View From Register
        /// </summary>
        /// <param name="decDailySalaryVoucehrMasterId"></param>
        /// <returns></returns>
        public DailySalaryVoucherMasterInfo DailySalaryVoucherViewFromRegister(decimal decDailySalaryVoucehrMasterId)
        {
            DailySalaryVoucherMasterInfo infoDailySalaryVoucherMaster = new DailySalaryVoucherMasterInfo();
            SqlDataReader sqldr = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sqlcmd = new SqlCommand("DailySalaryVoucherViewFromRegister", sqlcon);
                sqlcmd.CommandType = CommandType.StoredProcedure;
                sqlcmd.Parameters.Add("@dailySalaryVoucherMasterId", SqlDbType.Decimal).Value = decDailySalaryVoucehrMasterId;
                sqldr = sqlcmd.ExecuteReader();
                while (sqldr.Read())
                {
                    infoDailySalaryVoucherMaster.Date           = Convert.ToDateTime(sqldr["date"].ToString());
                    infoDailySalaryVoucherMaster.VoucherNo      = sqldr["voucherNo"].ToString();
                    infoDailySalaryVoucherMaster.InvoiceNo      = sqldr["invoiceNo"].ToString();
                    infoDailySalaryVoucherMaster.SalaryDate     = Convert.ToDateTime(sqldr["salaryDate"].ToString());
                    infoDailySalaryVoucherMaster.LedgerId       = Convert.ToDecimal(sqldr["ledgerId"].ToString());
                    infoDailySalaryVoucherMaster.TotalAmount    = Convert.ToDecimal(sqldr["totalAmount"].ToString());
                    infoDailySalaryVoucherMaster.Narration      = sqldr["narration"].ToString();
                    infoDailySalaryVoucherMaster.VoucherTypeId  = Convert.ToDecimal(sqldr["voucherTypeId"].ToString());
                    infoDailySalaryVoucherMaster.SuffixPrefixId = Convert.ToDecimal(sqldr["suffixPrefixId"].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqldr.Close();
                sqlcon.Close();
            }
            return(infoDailySalaryVoucherMaster);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Function for Edit
        /// </summary>
        public void EditFunction()
        {
            try
            {
                DailySalaryVoucherMasterInfo infoMaster = new DailySalaryVoucherMasterInfo();
                DailySalaryVoucherMasterSP spMaster = new DailySalaryVoucherMasterSP();
                DailySalaryVoucherDetailsInfo infoDetails = new DailySalaryVoucherDetailsInfo();
                DailySalaryVoucherDetailsSP spDetails = new DailySalaryVoucherDetailsSP();
                LedgerPostingSP spLedgerPosting = new LedgerPostingSP();

                infoMaster.DailySalaryVoucehrMasterId = decMasterIdforEdit;
                infoMaster.Date = Convert.ToDateTime(dtpDate.Value.ToString());
                infoMaster.LedgerId = Convert.ToDecimal(cmbCashorBankAccount.SelectedValue.ToString());
                infoMaster.Narration = txtNarration.Text;
                infoMaster.TotalAmount = Convert.ToDecimal(lblShowTotelamount.Text.ToString());
                if (isAutomatic)
                {
                    infoMaster.VoucherNo = strVoucherNo;
                }
                else
                {
                    infoMaster.VoucherNo = txtVoucherNo.Text.Trim();
                }

                if (isAutomatic)
                {
                    infoMaster.InvoiceNo = strInvoiceNo;
                }
                else
                {
                    infoMaster.InvoiceNo = txtVoucherNo.Text.Trim();
                }
                infoMaster.Extra1 = string.Empty;
                infoMaster.Extra2 = string.Empty;
                infoMaster.SuffixPrefixId = decDailySuffixPrefixId;
                infoMaster.VoucherTypeId = decDailyVoucherTypeId;
                infoMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                infoMaster.SalaryDate = Convert.ToDateTime(dtpSalaryDate.Text.ToString());
                infoDetails.Extra1 = string.Empty;// Fields not in design//
                infoDetails.Extra2 = string.Empty;// Fields not in design//
                spMaster.DailySalaryVoucherMasterEdit(infoMaster);
                int inRowCount = dgvDailySalaryVoucher.RowCount;
                for (int i = 0; i < inRowCount; i++)
                {
                    if (dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value.ToString() != string.Empty)
                    {
                        infoDetails.EmployeeId = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value.ToString());
                    }
                    if (dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value.ToString() != string.Empty)
                    {
                        infoDetails.Wage = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value.ToString());
                    }
                    if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() != string.Empty)
                    {
                        infoDetails.Status = dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString();
                    }

                    if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == string.Empty && dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtDailySalaryVocherMasterId"].Value.ToString() != string.Empty)
                    {
                        decimal DailySalaryVoucherDetailsId = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtdailySalaryVoucherDetailsId"].Value.ToString());
                        spDetails.DailySalaryVoucherDetailsDelete(DailySalaryVoucherDetailsId);

                        LedgerUpdate();

                    }
                    if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == "paid" && dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtDailySalaryVocherMasterId"].Value.ToString() == string.Empty)
                    {
                        infoDetails.DailySalaryVocherMasterId = decMasterIdforEdit;
                        spDetails.DailySalaryVoucherDetailsAdd(infoDetails);
                        //spMaster.DailySalaryVoucherMasterEdit(infoMaster);
                        LedgerUpdate();

                    }
                    if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == string.Empty && dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtDailySalaryVocherMasterId"].Value.ToString() == string.Empty)
                    {
                        spMaster.DailySalaryVoucherMasterEdit(infoMaster);
                        LedgerUpdate();

                    }
                }
                if (spDetails.DailySalaryVoucherDetailsCount(decMasterIdforEdit) == 0)
                {
                    spMaster.DailySalaryVoucherMasterDelete(decMasterIdforEdit);
                }
                Messages.UpdatedMessage();
                Clear();
                if (frmDailySalaryRegisterobj != null)
                {

                    this.Close();
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("DSV12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Function to Save
        /// </summary>
        public void SaveFunction()
        {
            try
            {

                DailySalaryVoucherMasterInfo infoMaster = new DailySalaryVoucherMasterInfo();
                DailySalaryVoucherMasterSP spMaster = new DailySalaryVoucherMasterSP();
                DailySalaryVoucherDetailsInfo infoDetails = new DailySalaryVoucherDetailsInfo();
                DailySalaryVoucherDetailsSP spDetails = new DailySalaryVoucherDetailsSP();

                //-------------In multi user case check whether salary is paying for the same persone--------------//
                int inCounts = dgvDailySalaryVoucher.RowCount;
                int incont = 0;
                decimal decVal = 0;
                for (int i = 0; i < inCounts; i++)
                {
                    decVal = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value.ToString());
                    if (spDetails.CheckWhetherDailySalaryAlreadyPaid(decVal, dtpSalaryDate.Value) != "0")
                    {
                        strEployeeNames = strEployeeNames + spDetails.CheckWhetherDailySalaryAlreadyPaid(decVal, dtpSalaryDate.Value) + ",";
                        foreach (char ch in strEployeeNames)
                        {
                            if (ch == ',')
                            {
                                incont++;
                            }
                        }
                        if (incont == 15)
                        {
                            incont = 0;
                            strEployeeNames = strEployeeNames + Environment.NewLine;
                        }

                    }
                }
                if (spDetails.CheckWhetherDailySalaryAlreadyPaid(decVal, dtpSalaryDate.Value) != "0")
                {

                    Messages.InformationMessage("Salary already paid for - " + " " + strEployeeNames);
                    DailySalaryVoucherDetailsGridfill(isEditmode);
                }
                else
                {
                    if (isAutomatic)
                    {
                        infoMaster.VoucherNo = strVoucherNo;
                    }
                    else
                    {
                        infoMaster.VoucherNo = txtVoucherNo.Text.Trim();
                    }
                    infoMaster.Date = DateTime.Parse(dtpDate.Text.ToString());
                    infoMaster.SalaryDate = DateTime.Parse(dtpSalaryDate.Text.ToString());
                    infoMaster.LedgerId = Convert.ToDecimal(cmbCashorBankAccount.SelectedValue.ToString());
                    infoMaster.Narration = txtNarration.Text.Trim();
                    infoMaster.TotalAmount = Convert.ToDecimal(lblShowTotelamount.Text.ToString());
                    infoMaster.Extra1 = string.Empty; // Fields not in design//
                    infoMaster.Extra2 = string.Empty; // Fields not in design//
                    if (isAutomatic)
                    {
                        infoMaster.InvoiceNo = strInvoiceNo;
                    }
                    else
                    {
                        infoMaster.InvoiceNo = txtVoucherNo.Text.Trim();
                    }
                    infoMaster.SuffixPrefixId = decDailySuffixPrefixId;
                    infoMaster.VoucherTypeId = decDailyVoucherTypeId;
                    infoMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;

                    int inval = 0;
                    int inCount = dgvDailySalaryVoucher.RowCount;
                    for (int i = 0; i < inCount; i++)
                    {
                        if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == "paid")
                        {
                            inval++;
                        }

                    }
                    if (inval >= 0)
                    {
                        //-------------checks Voucher No. repeating in Multi user case----------//
                        DataTable dtbl = new DataTable();
                        dtbl = spMaster.DailySalaryVoucherMasterAddWithIdentity(infoMaster, isAutomatic);
                        foreach (DataRow dr in dtbl.Rows)
                        {
                            decMasterId = Convert.ToDecimal(dr.ItemArray[0].ToString());
                            strUpdatedVoucherNo = dr.ItemArray[1].ToString();
                            strUpdatedInvoiceNo = dr.ItemArray[2].ToString();
                        }
                        if (!isAutomatic)
                        {
                            strVoucherNo = txtVoucherNo.Text;
                        }
                        if (isAutomatic)
                        {
                            if (Convert.ToDecimal(strUpdatedVoucherNo) != Convert.ToDecimal(strVoucherNo))
                            {
                                Messages.InformationMessage("Voucher number changed from  " + strInvoiceNo + "  to  " + strUpdatedInvoiceNo);
                                strVoucherNo = strUpdatedVoucherNo.ToString();
                                strInvoiceNo = strUpdatedInvoiceNo;
                            }
                        }
                        //-------------------------------------//
                        LedgerPosting(Convert.ToDecimal(cmbCashorBankAccount.SelectedValue.ToString()));

                        infoDetails.DailySalaryVocherMasterId = decMasterId;
                        infoDetails.Extra1 = string.Empty;// Fields not in design//
                        infoDetails.Extra2 = string.Empty;// Fields not in design//
                        int inRowCount = dgvDailySalaryVoucher.RowCount;
                        for (int i = 0; i < inRowCount; i++)
                        {

                            if (dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value.ToString() != string.Empty)
                            {
                                infoDetails.EmployeeId = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value.ToString());
                            }
                            if (dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value.ToString() != string.Empty)
                            {
                                infoDetails.Wage = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value.ToString());

                            }
                            if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() != string.Empty)
                            {
                                infoDetails.Status = dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString();

                            }

                            if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == "paid" && dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtDailySalaryVocherMasterId"].Value.ToString() == string.Empty)
                            {
                                infoDetails.DailySalaryVocherMasterId = decMasterId;
                                spDetails.DailySalaryVoucherDetailsAdd(infoDetails);
                            }
                        }
                        Messages.SavedMessage();
                        DailySalaryVoucherDetailsGridfill(isEditmode);
                        Clear();

                    }
                    else
                    {
                        strVoucherNo = spMaster.DailySalaryVoucherMasterGetMax(decDailyVoucherTypeId);
                        Messages.InformationMessage("Can't save without atleast one employee");
                        Clear();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("DSV11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Function to fill controls for updation
        /// </summary>
        public void fillFunction()
        {
            try
            {
                DailySalaryVoucherMasterSP SpMaster = new DailySalaryVoucherMasterSP();
                DailySalaryVoucherMasterInfo InfoMaster = new DailySalaryVoucherMasterInfo();
                VoucherTypeSP spVoucherType = new VoucherTypeSP();
                InfoMaster = SpMaster.DailySalaryVoucherViewFromRegister(decMasterIdforEdit);

                strVoucherNoforEdit = InfoMaster.VoucherNo;
                strVoucherNo = InfoMaster.VoucherNo;
                txtVoucherNo.Text = InfoMaster.InvoiceNo;
                strInvoiceNo = InfoMaster.InvoiceNo;
                dtpDate.Text = InfoMaster.Date.ToString();
                dtpSalaryDate.Text = InfoMaster.SalaryDate.ToString();
                lblShowTotelamount.Text = Math.Round(Convert.ToDecimal(InfoMaster.TotalAmount.ToString("0.00000")), PublicVariables._inNoOfDecimalPlaces).ToString();
                txtNarration.Text = InfoMaster.Narration;
                decDailySuffixPrefixId = InfoMaster.SuffixPrefixId;
                decDailyVoucherTypeId = InfoMaster.VoucherTypeId;
                cmbCashorBankAccount.SelectedValue = InfoMaster.LedgerId.ToString();
                isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(decDailyVoucherTypeId);
                if (isAutomatic)
                {
                    txtVoucherNo.Enabled = false;
                }
                else
                {
                    txtVoucherNo.Enabled = true;
                }

                dtpSalaryDate.Enabled = false;
                txtSalaryDate.Enabled = false;
                DailySalaryVoucherDetailsGridfill(isEditmode);
            }
            catch (Exception ex)
            {
                MessageBox.Show("DSV6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to Daily Salary Voucher View From Register
 /// </summary>
 /// <param name="decDailySalaryVoucehrMasterId"></param>
 /// <returns></returns>
 public DailySalaryVoucherMasterInfo DailySalaryVoucherViewFromRegister(decimal decDailySalaryVoucehrMasterId)
 {
     DailySalaryVoucherMasterInfo infoDailySalaryVoucherMaster = new DailySalaryVoucherMasterInfo();
     SqlDataReader sqldr = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sqlcmd = new SqlCommand("DailySalaryVoucherViewFromRegister", sqlcon);
         sqlcmd.CommandType = CommandType.StoredProcedure;
         sqlcmd.Parameters.Add("@dailySalaryVoucherMasterId", SqlDbType.Decimal).Value = decDailySalaryVoucehrMasterId;
         sqldr = sqlcmd.ExecuteReader();
         while (sqldr.Read())
         {
             infoDailySalaryVoucherMaster.Date = Convert.ToDateTime(sqldr["date"].ToString());
             infoDailySalaryVoucherMaster.VoucherNo = sqldr["voucherNo"].ToString();
             infoDailySalaryVoucherMaster.InvoiceNo = sqldr["invoiceNo"].ToString();
             infoDailySalaryVoucherMaster.SalaryDate = Convert.ToDateTime(sqldr["salaryDate"].ToString());
             infoDailySalaryVoucherMaster.LedgerId = Convert.ToDecimal(sqldr["ledgerId"].ToString());
             infoDailySalaryVoucherMaster.TotalAmount = Convert.ToDecimal(sqldr["totalAmount"].ToString());
             infoDailySalaryVoucherMaster.Narration = sqldr["narration"].ToString();
             infoDailySalaryVoucherMaster.VoucherTypeId = Convert.ToDecimal(sqldr["voucherTypeId"].ToString());
             infoDailySalaryVoucherMaster.SuffixPrefixId = Convert.ToDecimal(sqldr["suffixPrefixId"].ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqldr.Close();
         sqlcon.Close();
     }
     return infoDailySalaryVoucherMaster;
 }
        /// <summary>
        /// Function to insert values to DailySalaryVoucherMaster Table and return the Curresponding row's Id
        /// </summary>
        /// <param name="dailysalaryvouchermasterinfo"></param>
        /// <param name="IsAutomatic"></param>
        /// <returns></returns>
        public DataTable DailySalaryVoucherMasterAddWithIdentity(DailySalaryVoucherMasterInfo dailysalaryvouchermasterinfo, bool IsAutomatic)
        {
            DataTable dtbl = new DataTable();
            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlDataAdapter sqlda = new SqlDataAdapter("DailySalaryVoucherMasterAddWithIdentity", sqlcon);
                sqlda.SelectCommand.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam = sqlda.SelectCommand.Parameters.Add("@ledgerId", SqlDbType.Decimal);
                sprmparam.Value = dailysalaryvouchermasterinfo.LedgerId;
                sprmparam = sqlda.SelectCommand.Parameters.Add("@voucherNo", SqlDbType.VarChar);
                sprmparam.Value = dailysalaryvouchermasterinfo.VoucherNo;
                sprmparam = sqlda.SelectCommand.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
                sprmparam.Value = dailysalaryvouchermasterinfo.InvoiceNo;
                sprmparam = sqlda.SelectCommand.Parameters.Add("@date", SqlDbType.DateTime);
                sprmparam.Value = dailysalaryvouchermasterinfo.Date;
                sprmparam = sqlda.SelectCommand.Parameters.Add("@salaryDate", SqlDbType.DateTime);
                sprmparam.Value = dailysalaryvouchermasterinfo.SalaryDate;
                sprmparam = sqlda.SelectCommand.Parameters.Add("@totalAmount", SqlDbType.Decimal);
                sprmparam.Value = dailysalaryvouchermasterinfo.TotalAmount;
                sprmparam = sqlda.SelectCommand.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value = dailysalaryvouchermasterinfo.Narration;
                sprmparam = sqlda.SelectCommand.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = dailysalaryvouchermasterinfo.Extra1;
                sprmparam = sqlda.SelectCommand.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = dailysalaryvouchermasterinfo.Extra2;
                sprmparam = sqlda.SelectCommand.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
                sprmparam.Value = dailysalaryvouchermasterinfo.SuffixPrefixId;
                sprmparam = sqlda.SelectCommand.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
                sprmparam.Value = dailysalaryvouchermasterinfo.VoucherTypeId;
                sprmparam = sqlda.SelectCommand.Parameters.Add("@isAutomatic", SqlDbType.Bit);
                sprmparam.Value = IsAutomatic;
                sprmparam = sqlda.SelectCommand.Parameters.Add("@financialYearId", SqlDbType.Decimal);
                sprmparam.Value = dailysalaryvouchermasterinfo.FinancialYearId;
                sqlda.Fill(dtbl);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return dtbl;
        }
 /// <summary>
 /// Function to get particular values from DailySalaryVoucherMaster Table based on the parameter
 /// </summary>
 /// <param name="dailySalaryVoucehrMasterId"></param>
 /// <returns></returns>
 public DailySalaryVoucherMasterInfo DailySalaryVoucherMasterView(decimal dailySalaryVoucehrMasterId)
 {
     DailySalaryVoucherMasterInfo dailysalaryvouchermasterinfo = new DailySalaryVoucherMasterInfo();
     SqlDataReader sdrreader = null;
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("DailySalaryVoucherMasterView", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam = sccmd.Parameters.Add("@dailySalaryVoucherMasterId", SqlDbType.Decimal);
         sprmparam.Value = dailySalaryVoucehrMasterId;
         sdrreader = sccmd.ExecuteReader();
         while (sdrreader.Read())
         {
             dailysalaryvouchermasterinfo.DailySalaryVoucehrMasterId = decimal.Parse(sdrreader[0].ToString());
             dailysalaryvouchermasterinfo.LedgerId = decimal.Parse(sdrreader[1].ToString());
             dailysalaryvouchermasterinfo.VoucherNo = sdrreader[2].ToString();
             dailysalaryvouchermasterinfo.InvoiceNo = sdrreader[3].ToString();
             dailysalaryvouchermasterinfo.Date = DateTime.Parse(sdrreader[4].ToString());
             dailysalaryvouchermasterinfo.SalaryDate = DateTime.Parse(sdrreader[5].ToString());
             dailysalaryvouchermasterinfo.TotalAmount = decimal.Parse(sdrreader[6].ToString());
             dailysalaryvouchermasterinfo.Narration = sdrreader[7].ToString();
             dailysalaryvouchermasterinfo.ExtraDate = DateTime.Parse(sdrreader[8].ToString());
             dailysalaryvouchermasterinfo.Extra1 = sdrreader[9].ToString();
             dailysalaryvouchermasterinfo.Extra2 = sdrreader[10].ToString();
             dailysalaryvouchermasterinfo.SuffixPrefixId = decimal.Parse(sdrreader[11].ToString());
             dailysalaryvouchermasterinfo.VoucherTypeId = decimal.Parse(sdrreader[12].ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sdrreader.Close();
         sqlcon.Close();
     }
     return dailysalaryvouchermasterinfo;
 }