Exemple #1
0
 /// <summary>
 /// Function to save
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         ExchangeRateInfo infoExchangeRate = new ExchangeRateInfo();
         ExchangeRateSP   spExchangeRate   = new ExchangeRateSP();
         infoExchangeRate.CurrencyId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
         infoExchangeRate.Date       = Convert.ToDateTime(dtpDate.Text.Trim().ToString());
         infoExchangeRate.Rate       = Convert.ToDecimal(txtExchangeRate.Text.Trim().ToString());
         infoExchangeRate.Narration  = txtNarration.Text.Trim();
         infoExchangeRate.Extra1     = string.Empty;
         infoExchangeRate.Extra2     = string.Empty;
         if (spExchangeRate.ExchangeRateCheckExistence(Convert.ToDateTime(txtDate.Text.Trim().ToString()), Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()), 0) == false)
         {
             if (ExchangeRateCheck())
             {
                 spExchangeRate.ExchangeRateAddParticularFields(infoExchangeRate);
                 Messages.SavedMessage();
                 Clear();
             }
         }
         else
         {
             Messages.ReferenceExistsMessageForUpdate();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("ER2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #2
0
 /// <summary>
 /// Function to insert particular values to ExchangeRate Table
 /// </summary>
 /// <param name="exchangerateinfo"></param>
 public void ExchangeRateAddParticularFields(ExchangeRateInfo exchangerateinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ExchangeRateAddParticularFields", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@currencyId", SqlDbType.Decimal);
         sprmparam.Value = exchangerateinfo.CurrencyId;
         sprmparam       = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = exchangerateinfo.Date;
         sprmparam       = sccmd.Parameters.Add("@rate", SqlDbType.Decimal);
         sprmparam.Value = exchangerateinfo.Rate;
         sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = exchangerateinfo.Narration;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = exchangerateinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = exchangerateinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Exemple #3
0
 /// <summary>
 /// Function to edit
 /// </summary>
 public void Editfunction()
 {
     try
     {
         ExchangeRateInfo infoExchangeRate = new ExchangeRateInfo();
         ExchangeRateSP   spExchangeRate   = new ExchangeRateSP();
         infoExchangeRate.CurrencyId     = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
         infoExchangeRate.Date           = Convert.ToDateTime(dtpDate.Text.Trim().ToString());
         infoExchangeRate.Rate           = Convert.ToDecimal(txtExchangeRate.Text.Trim().ToString());
         infoExchangeRate.Narration      = txtNarration.Text.Trim();
         infoExchangeRate.Extra1         = String.Empty;
         infoExchangeRate.Extra2         = String.Empty;
         infoExchangeRate.ExchangeRateId = decId;
         if (spExchangeRate.ExchangeRateCheckExistence(Convert.ToDateTime(txtDate.Text.Trim().ToString()), Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()), decExchangeRateId) == false)
         {
             if (ExchangeRateCheck())
             {
                 spExchangeRate.ExchangeRateEdit(infoExchangeRate);
                 Messages.UpdatedMessage();
                 SearchClear();
                 Clear();
             }
         }
         else
         {
             Messages.InformationMessage("Already exists");
             cmbCurrency.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("ER3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #4
0
 /// <summary>
 /// Function to fill controls for update
 /// </summary>
 public void FillControls()
 {
     try
     {
         ExchangeRateInfo infoExchangeRate = new ExchangeRateInfo();
         ExchangeRateSP   spExchangeRate   = new ExchangeRateSP();
         infoExchangeRate = spExchangeRate.ExchangeRateView(decId);
         int inNoOfDecimalPlaces = spExchangeRate.NoOfDecimalNumberViewByExchangeRateId(decId);
         cmbCurrency.SelectedValue = infoExchangeRate.CurrencyId.ToString();
         dtpDate.Text         = infoExchangeRate.Date.ToString();
         txtExchangeRate.Text = Math.Round(Convert.ToDecimal(infoExchangeRate.Rate.ToString()), inNoOfDecimalPlaces).ToString();
         txtNarration.Text    = infoExchangeRate.Narration;
         decExchangeRateId    = infoExchangeRate.ExchangeRateId;
     }
     catch (Exception ex)
     {
         MessageBox.Show("ER13:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #5
0
        /// <summary>
        /// Function to get particular values from ExchangeRate Table based on the parameter
        /// </summary>
        /// <param name="exchangeRateId"></param>
        /// <returns></returns>
        public ExchangeRateInfo ExchangeRateView(decimal exchangeRateId)
        {
            ExchangeRateInfo exchangerateinfo = new ExchangeRateInfo();
            SqlDataReader    sdrreader        = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ExchangeRateView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
                sprmparam.Value = exchangeRateId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    exchangerateinfo.ExchangeRateId = decimal.Parse(sdrreader[0].ToString());
                    exchangerateinfo.CurrencyId     = decimal.Parse(sdrreader[1].ToString());
                    exchangerateinfo.Date           = DateTime.Parse(sdrreader[2].ToString());
                    exchangerateinfo.Rate           = decimal.Parse(sdrreader[3].ToString());
                    exchangerateinfo.Narration      = sdrreader[4].ToString();
                    exchangerateinfo.ExtraDate      = DateTime.Parse(sdrreader[5].ToString());
                    exchangerateinfo.Extra1         = sdrreader[6].ToString();
                    exchangerateinfo.Extra2         = sdrreader[7].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(exchangerateinfo);
        }