コード例 #1
0
        public ActionResponse Create(FXRateModel model)
        {
            if (model.ExchangeRate > 0)
            {
                Core_FXRate dbmodel = new Core_FXRate
                {
                    BaseCurrencyID = 1,
                    CurrencyID     = 2,
                    ExchangeRate   = (Double)model.ExchangeRate,
                    CreatedBy      = model.CreatedBy,
                    // CreatedDate = model.CreatedDate,
                    CreatedDate = DateTime.Now,

                    isApproved = false
                };
                ent.AddToCore_FXRate(dbmodel);
                ent.SaveChanges();
                _res.ActionMessage  = String.Format(Resources.Message.SuccessfullySaved, "FX Rate");
                _res.ErrNumber      = 0;
                _res.ErrSource      = "DataBase";
                _res.ErrType        = "App";
                _res.ResponseStatus = true;
            }
            else
            {
                _res.ActionMessage  = String.Format(Resources.Message.InvalidField, "Exchange Rate");
                _res.ErrNumber      = 1001;
                _res.ErrSource      = "DataBase";
                _res.ErrType        = "App";
                _res.ResponseStatus = true;
            }
            return(_res);
        }
コード例 #2
0
 public ActionResponse Approve(int?FXRateId)
 {
     if (FXRateId != null)
     {
         Core_FXRate result = ent.Core_FXRate.Where(x => x.FXRateId == FXRateId).FirstOrDefault();
         result.isApproved = true;
         ent.ApplyCurrentValues(result.EntityKey.EntitySetName, result);
         ent.SaveChanges();
         _res.ActionMessage  = String.Format(Resources.Message.SuccessfullyApproved, "FX Rate");
         _res.ErrNumber      = 0;
         _res.ErrSource      = "DataBase";
         _res.ErrType        = "App";
         _res.ResponseStatus = true;
     }
     else
     {
         _res.ActionMessage  = String.Format(Resources.Message.InvalidOperation, "FX Rate");
         _res.ErrNumber      = 2000;
         _res.ErrSource      = "DataBase";
         _res.ErrType        = "App";
         _res.ResponseStatus = true;
     }
     return(_res);
 }
コード例 #3
0
        public ActionResult Create(LedgerVoucherModel model, FormCollection coll)
        {
            try
            {
                var   ts            = (TravelSession)Session["TravelPortalSessionInfo"];
                Int64 VoucherNumber = _ser.GetVoucherNumber(model.ProductId);

                ///////////Begin of Saving transaction info  ///////////////////////
                int totalentry = Convert.ToInt32(coll["noOfentry"]);
                List <GL_Transactions> entryDataList = new List <GL_Transactions>();
                for (int i = 0; i < totalentry; i++)
                {
                    string          Dr_Cr = coll["DrCr"] ?? coll["DrCr" + i];
                    GL_Transactions list  = new GL_Transactions();
                    if (string.IsNullOrEmpty(coll["Narration"] ?? coll["Narration" + i]) && (string.IsNullOrEmpty(coll["DrCr"] ?? coll["DrCr" + i])))
                    {
                        /////// TODO: Handle error due to java script error.Do not put this code here /////
                    }
                    else
                    {
                        list.LedgerId     = Convert.ToInt32(coll["LedgerId"] ?? coll["LedgerId" + i]);
                        list.Narration1   = coll["Narration"] ?? coll["Narration" + i];
                        list.TranDate     = model.TranDate;
                        list.ProductId    = model.ProductId;
                        list.CurrencyId   = model.CurrencyID;
                        list.TranStatusId = 1;
                        list.MakerId      = ts.AppUserId;
                        list.TranTypeId   = 2;
                        list.MakerDate    = DateTime.Now;
                        if (Dr_Cr == "Dr" || Dr_Cr == "D" || Dr_Cr == "d")
                        {
                            list.Dr_Cr  = "D";
                            list.Amount = Convert.ToDouble(coll["Debit"] ?? coll["Debit" + i]);
                        }
                        else if (Dr_Cr == "Cr" || Dr_Cr == "C" || Dr_Cr == "c")
                        {
                            list.Dr_Cr  = "C";
                            list.Amount = Convert.ToDouble(coll["Credit"] ?? coll["Credit" + i]);
                        }
                        list.VoucherNo      = VoucherNumber;
                        list.BaseCurrencyId = 1;

                        Core_FXRate ExchangeRate = ent.Core_FXRate.Where(x => (x.CurrencyID == model.CurrencyID && x.isApproved == true)).OrderByDescending(xx => xx.CreatedDate).FirstOrDefault();

                        double FXRate = 1;
                        if (ExchangeRate != null)
                        {
                            FXRate = ExchangeRate.ExchangeRate;
                        }

                        list.FXRate    = FXRate;
                        list.FCYAmount = list.Amount * FXRate;

                        list.CheckerRemark = model.CheckerRemark;
                        string clientIP;
                        clientIP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                        if (clientIP == string.Empty)
                        {
                            clientIP = Request.ServerVariables["REMOTE_ADDR"];
                        }
                        list.CheckerTerminalId = clientIP;

                        entryDataList.Add(list);
                    }
                }
                _ser.SaveVoucher(entryDataList);
                TempData["SuccessMessage"] = "Successfully Created General Voucher";
                return(RedirectToAction("Create"));
            }
            catch (Exception ex)
            {
                TempData["ActionResponse"] = "There is an error: " + ex.Message;
                return(RedirectToAction("Create"));
            }
        }