Esempio n. 1
0
    public void SetCurrency()
    {
        bool IsDefault = true;

        if ((Session[appFunctions.Session.CurrencyID.ToString()] != null))
        {
            if (Session[appFunctions.Session.CurrencyID.ToString()].ToString() != "")
            {
                IsDefault = false;
            }
        }
        tblCurrency objCurrency = new tblCurrency();

        if (IsDefault)
        {
            objCurrency.Where.AppIsDefault.Value = true;
            objCurrency.Query.Load();
        }
        else
        {
            objCurrency.LoadByPrimaryKey(Convert.ToInt32(Session[appFunctions.Session.CurrencyID.ToString()].ToString()));
        }
        if (objCurrency.RowCount > 0)
        {
            Session[appFunctions.Session.CurrencyID.ToString()]      = objCurrency.s_AppCurrencyID;
            Session[appFunctions.Session.CurrencyImage.ToString()]   = objCurrency.s_AppSymbol;
            Session[appFunctions.Session.CurrencyInRupee.ToString()] = objCurrency.s_AppRate;
        }
        objCurrency = null;
    }
Esempio n. 2
0
        public SavingResult SaveNewRecord(tblCurrency SaveModel)
        {
            SavingResult res = new SavingResult();

            //-- Perform Validation
            //res.ExecutionResult = eExecutionResult.ValidationError;
            //res.ValidationError = "Validation error message";
            //return res;

            //--
            using (dbVisionEntities db = new dbVisionEntities())
            {
                //tblCurrency SaveModel;
                if (SaveModel.CurrencyName == "")
                {
                    res.ValidationError = "Can not accept blank value. Please enter Currency Name.";
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    return(res);
                }
                else if (IsDuplicateRecord(SaveModel.CurrencyName, SaveModel.CurrencyID, db))
                {
                    res.ValidationError = "Can not accept duplicate value. The Currency Name is already exists.";
                    res.ExecutionResult = eExecutionResult.ValidationError;
                    return(res);
                }

                if (SaveModel.CurrencyID == 0) // New Entry
                {
                    SaveModel.rcuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID;
                    SaveModel.rcdt  = DateTime.Now;
                    db.tblCurrencies.Add(SaveModel);
                }
                else
                {
                    SaveModel.reuid = Model.CommonProperties.LoginInfo.LoggedinUser.UserID;
                    SaveModel.redt  = DateTime.Now;
                    db.tblCurrencies.Attach(SaveModel);
                    db.Entry(SaveModel).State = System.Data.Entity.EntityState.Modified;
                }

                //--
                try
                {
                    db.SaveChanges();
                    res.PrimeKeyValue   = SaveModel.CurrencyID;
                    res.ExecutionResult = eExecutionResult.CommitedSucessfuly;
                }
                catch (Exception ex)
                {
                    CommonFunctions.GetFinalError(res, ex);
                }
            }
            return(res);
        }
 private bool SaveData()
 {
     objCommon = new clsCommon();
     if (objCommon.IsRecordExists("tblCurrency", tblCurrency.ColumnNames.AppCurrency, tblCurrency.ColumnNames.AppCurrencyID, txtCurrencyName.Text, hdnPKID.Value))
     {
         DInfo.ShowMessage("Currency Name alredy exits.", Enums.MessageType.Error);
         return(false);
     }
     objCurrency = new tblCurrency();
     if (!string.IsNullOrEmpty(hdnPKID.Value) && hdnPKID.Value != "")
     {
         objCurrency.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value));
     }
     else
     {
         objCurrency.AddNew();
         objCurrency.AppDisplayOrder = objCommon.GetNextDisplayOrder("tblCurrency", tblCurrency.ColumnNames.AppDisplayOrder);
     }
     objCurrency.AppCurrency     = txtCurrencyName.Text;
     objCurrency.AppCurrencyCode = txtCurrencyCode.Text;
     objCurrency.s_AppRate       = txtRate.Text;
     objCurrency.s_AppSymbol     = txtSymbol.Text;
     objCurrency.AppIsActive     = chkIsActive.Checked;
     if (chkIsDefault.Checked)
     {
         tblColor ObjTempcolor = new tblColor();
         ObjTempcolor.SetDefaultColor();
         ObjTempcolor             = null;
         objCurrency.AppIsActive  = true;
         objCurrency.AppIsDefault = true;
     }
     else
     {
         if (objCurrency.AppDisplayOrder == 1)
         {
             objCurrency.AppIsActive  = true;
             objCurrency.AppIsDefault = true;
         }
         else
         {
             objCurrency.AppIsDefault = false;
         }
     }
     objCurrency.Save();
     intPkId     = objCurrency.AppCurrencyID;
     objCurrency = null;
     objCommon   = null;
     return(true);
 }
Esempio n. 4
0
    private void LoadDataGrid(bool IsResetPageIndex, bool IsSort, string strFieldName = "", string strFieldValue = "")
    {
        objCurrency = new tblCurrency();

        objDataTable = objCurrency.LoadGridData(ddlFields.SelectedValue, txtSearch.Text.Trim());

        //'Reset PageIndex of gridviews
        if (IsResetPageIndex)
        {
            if (dgvGridView.PageCount > 0)
            {
                dgvGridView.PageIndex = 0;
            }
        }

        dgvGridView.DataSource = null;
        dgvGridView.DataBind();
        lblCount.Text        = 0.ToString();
        hdnSelectedIDs.Value = "";

        //'Check for data into datatable
        if (objDataTable.Rows.Count <= 0)
        {
            DInfo.ShowMessage("No data found", Enums.MessageType.Information);
            return;
        }
        else
        {
            if (ddlPerPage.SelectedItem.Text.ToLower() == "all")
            {
                dgvGridView.AllowPaging = false;
            }
            else
            {
                dgvGridView.AllowPaging = true;
                dgvGridView.PageSize    = Convert.ToInt32(ddlPerPage.SelectedItem.Text);
            }

            lblCount.Text          = objDataTable.Rows.Count.ToString();
            objDataTable           = SortDatatable(objDataTable, ViewState["SortColumn"].ToString(), (appFunctions.Enum_SortOrderBy)ViewState["SortOrder"], IsSort);
            dgvGridView.DataSource = objDataTable;
            dgvGridView.DataBind();
        }

        objCurrency = null;
    }
Esempio n. 5
0
        public ActionResult AddNewCurrency(tblCurrency model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var symbol = model.CurrencyCode.ToUpper();

                    if (db.tblCurrencies.Any(o => o.CurrencyCode == symbol))
                    {
                        TempData["ResultError"] = "There is already currency with this code in database!";
                        return(RedirectToAction("AddNewCurrency"));
                    }

                    var currencyData = GetCurrencieExchangeRate(symbol);

                    if (isAllGood)
                    {
                        var value = currencyData.rates[symbol];

                        var tbl = new tblCurrency
                        {
                            CurrencyCode  = model.CurrencyCode,
                            CurrencyName  = model.CurrencyName,
                            CurrencyValue = Convert.ToDecimal(value),
                            UserName      = User.Identity.Name,
                            DateChanged   = DateTime.Now,
                            DateCreated   = DateTime.Now
                        };

                        db.tblCurrencies.Add(tbl);
                        db.SaveChanges();

                        return(RedirectToAction("ViewAllCurrencies"));
                    }
                }
                catch (Exception ex)
                {
                    SendExceptionToAdmin(ex.ToString());
                }
            }

            TempData["ResultError"] = "Something went wrong! ";
            return(View());
        }
 private void SetValuesToControls()
 {
     if (!string.IsNullOrEmpty(hdnPKID.Value) && hdnPKID.Value != "")
     {
         objCurrency = new tblCurrency();
         if (objCurrency.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value)))
         {
             txtCurrencyName.Text = objCurrency.AppCurrency;
             txtCurrencyCode.Text = objCurrency.AppCurrencyCode;
             txtRate.Text         = objCurrency.s_AppRate;
             txtSymbol.Text       = objCurrency.s_AppSymbol;
             chkIsActive.Checked  = objCurrency.AppIsActive;
             chkIsDefault.Checked = objCurrency.AppIsDefault;
             if (chkIsDefault.Checked)
             {
                 chkIsDefault.Enabled = false;
             }
         }
         objCurrency = null;
     }
 }
Esempio n. 7
0
    private bool Delete(int intPKID)
    {
        bool retval = false;

        objCurrency = new tblCurrency();

        var _with1 = objCurrency;

        if (_with1.LoadByPrimaryKey(intPKID))
        {
            if (!_with1.AppIsDefault)
            {
                _with1.MarkAsDeleted();
                _with1.Save();
            }
        }

        retval      = true;
        objCurrency = null;
        return(retval);
    }
Esempio n. 8
0
        public SavingResult DeleteRecord(long DeleteID)
        {
            SavingResult res = new SavingResult();

            using (dbVisionEntities db = new dbVisionEntities())
            {
                if (DeleteID != 0)
                {
                    tblCurrency RecordToDelete = db.tblCurrencies.FirstOrDefault(r => r.CurrencyID == DeleteID);

                    if (RecordToDelete == null)
                    {
                        res.ValidationError = "Selected record not found. May be it has been deleted by another user over network.";
                        res.ExecutionResult = eExecutionResult.ValidationError;
                        return(res);
                    }
                    else
                    {
                        //db.tblCurrencies.Remove(RecordToDelete);
                        byte RecordState_Deleted = (byte)eRecordState.Deleted;
                        RecordToDelete.rstate = RecordState_Deleted;
                        db.tblCurrencies.Attach(RecordToDelete);
                        db.Entry(RecordToDelete).State = System.Data.Entity.EntityState.Modified;
                    }

                    try
                    {
                        db.SaveChanges();
                        res.ExecutionResult = eExecutionResult.CommitedSucessfuly;
                    }
                    catch (Exception ex)
                    {
                        CommonFunctions.GetFinalError(res, ex);
                    }
                }
            }
            return(res);
        }
Esempio n. 9
0
    protected void dgvGridView_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
    {
        if (!string.IsNullOrEmpty(e.CommandArgument.ToString()))
        {
            objCommon = new clsCommon();

            if (e.CommandName == "Up")
            {
                LinkButton  inkButton = (LinkButton)e.CommandSource;
                GridViewRow drCurrent = (GridViewRow)inkButton.Parent.Parent;
                if (drCurrent.RowIndex > 0)
                {
                    GridViewRow drUp = dgvGridView.Rows[drCurrent.RowIndex - 1];
                    objCommon.SetDisplayOrder("tblCurrency", tblCurrency.ColumnNames.AppCurrencyID, tblCurrency.ColumnNames.AppDisplayOrder, (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[0], (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[1], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[0], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[1]);
                    LoadDataGrid(false, false);
                    objCommon = null;
                }
            }
            else if (e.CommandName == "Down")
            {
                LinkButton  lnkButton = (LinkButton)e.CommandSource;
                GridViewRow drCurrent = (GridViewRow)lnkButton.Parent.Parent;
                if (drCurrent.RowIndex < dgvGridView.Rows.Count - 1)
                {
                    GridViewRow drUp = dgvGridView.Rows[drCurrent.RowIndex + 1];
                    objCommon.SetDisplayOrder("tblCurrency", tblCurrency.ColumnNames.AppCurrencyID, tblCurrency.ColumnNames.AppDisplayOrder, (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[0], (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[1], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[0], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[1]);
                    LoadDataGrid(false, false);
                    objCommon = null;
                }
            }
            else if (e.CommandName == "IsActive")
            {
                objCurrency = new tblCurrency();
                if (objCurrency.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())))
                {
                    if (!objCurrency.AppIsDefault)
                    {
                        if (objCurrency.AppIsActive == true)
                        {
                            objCurrency.AppIsActive = false;
                        }
                        else if (objCurrency.AppIsActive == false)
                        {
                            objCurrency.AppIsActive = true;
                        }
                        objCurrency.Save();

                        LoadDataGrid(false, false);
                    }
                }
                objCurrency = null;
            }
            else if (e.CommandName == "IsDefault")
            {
                objCurrency = new tblCurrency();
                objCurrency.SetDefaultColor(e.CommandArgument.ToString());
                objCurrency = null;
                LoadDataGrid(false, false);
            }
        }
    }