public static List <Comission> GetComissions() { ComissionList = new List <Comission>(); SqlConnection conn = new SqlConnection(); try { DatabaseControl dbc = new DatabaseControl(); SqlDataReader rd = dbc.GetDataFromDB("select * from dbo.Comissions", out conn); if (rd != null) { while (rd.Read()) { Comission comission = new Comission(); comission.Index = int.Parse(rd["index_value"].ToString()); comission.From = decimal.Parse(rd["from_value"].ToString().Replace(",", ".")); comission.To = decimal.Parse(rd["to_value"].ToString().Replace(",", ".")); comission.Value = decimal.Parse(rd["value"].ToString().Replace(",", ".")); comission.Type = int.Parse(rd["type_value"].ToString()); ComissionList.Add(comission); } } } catch (Exception ex) { Singleton <Logger> .Instance.WriteMainLine("AdminModel:GetUserModels: " + ex.Message); } finally { conn.Close(); } return(ComissionList); }
public ActionResult Comission(Comission comission) { if (!ModelState.IsValid) { return(View(comission)); } if (comission.CommissionTime < DateTime.Now) { ModelState.AddModelError("CommissionTime", "Время комиссии должно быть больше чем текущее время"); return(View(comission)); } RepositoryContext.Current.Add(comission); foreach (var project in comission.Projects) { if (comission.Type == ComissionType.Comission) { ProjectStateManager.StateManagerFactory(project, User.Identity.Name, Roles.GetRolesForUser(User.Identity.Name)) .Comission(); } else { ProjectStateManager.StateManagerFactory(project, User.Identity.Name, Roles.GetRolesForUser(User.Identity.Name)) .Ispolcom(); } } return(RedirectToAction("All", "BaseProject")); }
private void simpleButton3_Click(object sender, EventArgs e) { Comission saveService = new Comission(); saveService.CommissionId = txtCommissionID.Text; MessageModel message = new DoctorWisePatientManager().DeleteCommission(saveService); MessageBox.Show(message.MessageBody, message.MessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); Clear(); }
public async Task <IActionResult> Edit(string[] sportman, int id, [Bind("Id,Name,RegionId")] Comission comission) { if (id != comission.Id) { return(NotFound()); } if (ModelState.IsValid) { try { var oldComission = await _context.Comissions.Include(a => a.SportmanComissions).ThenInclude(b => b.Sportman).Where(p => p.Id == id).FirstOrDefaultAsync(); if (sportman.Length != 0) { foreach (var sportmanComission in _context.SportmanComissions.Where(a => a.ComissionId == id)) { if (!sportman.Contains(sportmanComission.Sportman.Id.ToString())) { var sportmanComissionToDel = await _context.SportmanComissions.FirstOrDefaultAsync(a => a.ComissionId == id && a.SportmanId == sportmanComission.Sportman.Id); oldComission.SportmanComissions.Remove(sportmanComissionToDel); } } foreach (var sportmanId in sportman) { if (oldComission.SportmanComissions.All(a => a.SportmanId != int.Parse(sportmanId))) { oldComission.SportmanComissions.Add(new SportmanComission() { SportmanId = int.Parse(sportmanId) }); } } } oldComission.Name = comission.Name; oldComission.RegionId = comission.RegionId; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ComissionExists(comission.Id)) { return(NotFound()); } throw; } return(RedirectToAction(nameof(Index))); } ViewBag.Regions = _regionsHandler.GetSelectedListRegionsWithSelection(comission.RegionId); return(View(comission)); }
public int DeleteCommission(Comission service) { int count = 0; Command = new SqlCommand("Delete tbl_CommssionMaster where CommissionID= @CommissionID ", Connection); Command.CommandType = CommandType.Text; Command.Parameters.AddWithValue("@CommissionID", service.CommissionId); count += Command.ExecuteNonQuery(); return(count); }
public MessageModel DeleteCommission(Comission aService) { int saveService = new DoctorWisePatientGatway().DeleteCommission(aService); if (saveService > 0) { messageModel.MessageBody = " Delete successfully!"; messageModel.MessageTitle = "Successfull"; } return(messageModel); }
public async Task <IActionResult> DeleteConfirmed(int id) { Comission comission = _context.Comissions.FirstOrDefault(a => a.Id == id); if (comission != null) { _context.Comissions.Remove(comission); await _context.SaveChangesAsync(); } return(RedirectToAction(nameof(Index))); }
public override XElement ToXml() { var xml = new XElement("Объект", new XAttribute("Нпп", Id), new XAttribute("Тип", Type), new XAttribute("ИмяПравила", RuleName) ); xml.Add(Reference.ToXml()); xml.Add(Comission.ToXml()); xml.Add(Tables[0].ToXml()); Properties.ForEach(prop => xml.Add(prop.ToXml())); xml.Add(Tables[1].ToXml()); return(xml); }
private void simpleButton4_Click(object sender, EventArgs e) { Comission saveService = new Comission(); saveService.CommissionId = txtCommissionID.Text; saveService.ReffId = Reff; saveService.Date = dateCommission.Value; saveService.Remarks = txtRemarks.Text; saveService.Inword = lblInward.Text; saveService.Amount = Convert.ToDecimal(txtTotalAmount.Text); saveService.UserId = MainWindow.userName; saveService.Status = Chk; MessageModel message = new DoctorWisePatientManager().UpdateCommission(saveService); MessageBox.Show(message.MessageBody, message.MessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); Clear(); }
public int UpdateCommission(Comission service) { int count = 0; Command = new SqlCommand("Update tbl_CommssionMaster set Date=@Date,ReffId=@ReffId,Amount=@Amount,Remarks=@Remarks,UserId=@UserId,InWord=@InWord,Status=@Status where CommissionID= @CommissionID ", Connection); Command.CommandType = CommandType.Text; Command.Parameters.AddWithValue("@CommissionID", service.CommissionId); Command.Parameters.AddWithValue("@Date", service.Date); Command.Parameters.AddWithValue("@ReffId", service.ReffId); Command.Parameters.AddWithValue("@Amount", service.Amount); Command.Parameters.AddWithValue("@Remarks", service.Remarks); Command.Parameters.AddWithValue("@UserId", service.UserId); Command.Parameters.AddWithValue("@InWord", service.Inword); Command.Parameters.AddWithValue("@Status", service.Status); count += Command.ExecuteNonQuery(); return(count); }
public ActionResult withdraw(Withdraw withdraw) { withdraw.userId = (Session["userProfile"] as User).userId; withdraw.shopId = (Session["shopProfile"] as Shop).shopId; if (withdraw.amount == null) { TempData["empty"] = "Must insert amount"; return(RedirectToAction("withdraw")); } else if (withdraw.amount < 20) { TempData["empty"] = "You don't have enought money to withdraw"; return(RedirectToAction("withdraw")); } else if (withdraw.amount > (Session["shopProfile"] as Shop).balance) { TempData["empty"] = "Please write a valid amount"; return(RedirectToAction("withdraw")); } var balance = (Session["shopProfile"] as Shop).balance - withdraw.amount; Shop shop = new Shop(); shop = (Session["shopProfile"] as Shop); shop.balance = balance; //Comission set Comission comission = new Comission(); comission.amount = withdraw.amount * (Convert.ToDouble((Session["shopProfile"] as Shop).setComission) / 100); comission.date = DateTime.Today.ToString(); comission.shopId = (Session["shopProfile"] as Shop).shopId; comissionRepository.Insert(comission); //Update shop balance shopRepository.Update(shop); //insert withdraw history withdrawRepository.Insert(withdraw); TempData["withdraw"] = (withdraw.amount - comission.amount) + " Tk withdrawal successful with " + comission.amount + " TK comission"; return(RedirectToAction("withdraw")); }
/// <summary> /// 佣金数据 /// </summary> /// <returns></returns> public ActionResult getProfit(string mobile, string openid) { var agentEntity = agentBll.GetEntityByOpenId(openid); if (agentEntity != null) { decimal?direct = 0; decimal?indirect = 0; Dictionary <string, Comission> dataCom = new Dictionary <string, Comission>(); var entityList = tlbll.GetList("{\"Telphones\":\"" + mobile + "\"}"); if (entityList.Count() > 0) { foreach (var telEntity in entityList) { if (telEntity.Price != null) { telEntity.Price = telEntity.Price * OperatorAgentProvider.Provider.Current().FuDong * 0.01M;//浮动 //获取返佣金额 getDirectDH(telEntity.OrganizeId, agentEntity.Category, out direct, out indirect); Comission comission = new Comission() { direct = telEntity.Price * direct, indirect = telEntity.Price * indirect }; dataCom.Add(telEntity.Telphone, comission); } } } dynamic obj = new ExpandoObject(); obj.code = 200; obj.msg = "success"; obj.data = dataCom; string json = JsonConvert.SerializeObject(obj); return(Content(json, "text/json")); } else { return(null); } }
public int SaveCommission(Comission service) { int count = 0; Command = new SqlCommand("INSERT INTO tbl_CommssionMaster (CommissionID,Date,ReffId,Amount,Remarks,UserId,InWord,Status)" + "VALUES(@CommissionID,@Date,@ReffId,@Amount,@Remarks,@UserId,@InWord,@Status)", Connection); Command.CommandType = CommandType.Text; Command.Parameters.AddWithValue("@CommissionID", service.CommissionId); Command.Parameters.AddWithValue("@Date", service.Date); Command.Parameters.AddWithValue("@ReffId", service.ReffId); Command.Parameters.AddWithValue("@Amount", service.Amount); Command.Parameters.AddWithValue("@Remarks", service.Remarks); Command.Parameters.AddWithValue("@UserId", service.UserId); Command.Parameters.AddWithValue("@InWord", service.Inword); Command.Parameters.AddWithValue("@Status", service.Status); count += Command.ExecuteNonQuery(); return(count); }
public int GetComissionValue(Comission com) { switch (com) { case Comission.Ahorros: return 80; case Comission.Corriente: return 60; case Comission.Nómina: return 0; case Comission.Remunerada: return 72; default: return 0; } }
public void OnOnComissionEntry() { Comission comission = Repository.All <Comission>(c => c.CommissionTime > DateTime.Now && c.Type == ComissionType.Comission) .First(); if (comission.ProjectIds == null) { comission.ProjectIds = new List <string>(); } if (!comission.ProjectIds.Contains(CurrentProject._id)) { comission.ProjectIds.Add(CurrentProject._id); Repository.Update(comission); } InvestorNotification.Comission(comission, CurrentProject); AdminNotification.Comission(comission, CurrentProject); ProcessMoving(ProjectWorkflow.State.OnComission, "Проект ожидает комиссию"); }
public void OnOnIspolcomEntry() { Comission comission = Repository.All <Comission>(c => c.CommissionTime > DateTime.Now && c.Type == ComissionType.Ispolcom) .First(); if (comission.ProjectIds == null) { comission.ProjectIds = new List <string>(); } if (!comission.ProjectIds.Contains(CurrentProject._id)) { comission.ProjectIds.Add(CurrentProject._id); Repository.Update(comission); } AdminNotification.OnIspolcom(comission, CurrentProject); InvestorNotification.OnIspolcom(comission, CurrentProject); ProcessMoving(ProjectWorkflow.State.OnIspolcom, "Переход в состояние на исполкоме"); }
public void SetComission(string typeCuenta) { switch (typeCuenta) { case "Ahorros": comission = Comission.Ahorros; break; case "Corriente": comission = Comission.Corriente; break; case "Nómina": comission = Comission.Nómina; break; case "Remunerada": comission = Comission.Remunerada; break; } }
public async Task <IActionResult> Create(string[] sportman, [Bind("Id, Name, RegionId")] Comission comission) { if (ModelState.IsValid) { if (sportman.Length != 0) { foreach (var sportmanId in sportman) { comission.SportmanComissions.Add(new SportmanComission() { SportmanId = int.Parse(sportmanId) }); } } _context.Add(comission); await _context.SaveChangesAsync(); _logger.LogInformation("Comissions Created."); return(RedirectToAction(nameof(Index))); } ViewBag.Regions = _regionsHandler.GetSelectedListRegionsWithSelection(comission.RegionId); return(View(comission)); }
public IActionResult SetComission([FromBody] ComissionDto value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var id = User.Claims.FirstOrDefault(c => c.Type == Helpers.Constants.Strings.JwtClaimIdentifiers.Id)?.Value; var root = _usersRepository.GetUser(id); var res = Comission.GetCommision(new ComissionControllerPattern() { Comission = value.Value }, new User() { PrivateKey = root.PrivateKey }, ModelState); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(NoContent()); }
public void OnIspolcom(Comission comission, Project project) { SendMailFromDb(project, project, ProjectWorkflow.Trigger.Ispolcom, UserType.Investor); }
//метод формирования строки удаления записи public string AddQuery() { roundParams(); int iTradeClosed = 0; if (TradeClosed == false) { iTradeClosed = 0; } else { iTradeClosed = 1; } int iTradeType = 0; int iInstrumentType = 0; switch (InstrumentType.ToString()) { case "Валюта": iInstrumentType = 0; break; case "Акция": iInstrumentType = 1; break; case "Фьючерс": iInstrumentType = 2; break; } switch (TradeType.ToString()) { case "Long": iTradeType = 0; break; case "Short": iTradeType = 1; break; } string query = "INSERT INTO `" + Schema + "`.`" + Table + "` " + "(`instrument_name`, " + "`instrument_class`, " + "`instrument_ticker`, " + "`trade_type`, " + "`opening_price`, " + "`trade_volume`, " + "`trade_sum`, " + "`trade_closed`, " + "`closing_price`, " + "`comissions`, " + "`taxes`, " + "`profit`) " + "VALUES ('" + InstrumentName + "', '" + iInstrumentType.ToString() + "', '" + Ticker + "', '" + iTradeType.ToString() + "', '" + OpeningPrice.ToString().Replace(",", ".") + "', '" + TradeSize.ToString() + "', '" + TradeSum.ToString().Replace(",", ".") + "', '" + iTradeClosed.ToString() + "', '" + ClosingPrice.ToString().Replace(",", ".") + "', '" + Comission.ToString().Replace(",", ".") + "', '" + Taxes.ToString().Replace(",", ".") + "', '" + Profit.ToString().Replace(",", ".") + "');"; return(query); }
public double calcStockGrade(Stock s, double investedMoney, List <double> ARList, List <double> earnLossList, History history, int roundNum, Comission comm) { double earningProbability = 1.0 / s.getEarningsCount(); List <double> earnings = s.getEarnings(); double sum = 0; List <HistoryRecord> investmentsRecords = history.getInvestmentsHistory(); double currTotalMoney = investmentsRecords[investmentsRecords.Count - 1]._currMoney; foreach (double earning in earnings) { earnLossList.Add(earning); double earnMoney = (1 + earning) * investedMoney; double commissionPercent = comm.takeCommision(investedMoney, earning).Item2; double commissionMoney = comm.takeCommision(investedMoney, earning).Item1; double endInvestmentMoney = earnMoney - commissionMoney; double endMoney = currTotalMoney - investedMoney + endInvestmentMoney; InvestmentData investmentData = new InvestmentData(s._id, investedMoney, earning, earnMoney, commissionMoney, commissionPercent, endInvestmentMoney); history.addRecord(new HistoryRecord(investmentData, currTotalMoney, endMoney, roundNum)); double expectedAdoptionRate = _predictor.predict(endMoney, roundNum + 1, history); sum += expectedAdoptionRate * earningProbability; // sum += (currTotalMoney - investedMoney + investedMoney * (1 + earning)) * expectedAdoptionRate * earningProbability; } return(sum); }
public string EditQuery() { roundParams(); int iTradeClosed = 0; if (TradeClosed == false) { iTradeClosed = 0; ClosingPrice = 0; Comission = 0; Taxes = 0; Profit = 0; } else { iTradeClosed = 1; } int iTradeType = 0; int iInstrumentType = 0; switch (InstrumentType.ToString()) { case "Валюта": iInstrumentType = 0; break; case "Акция": iInstrumentType = 1; break; case "Фьючерс": iInstrumentType = 2; break; } switch (TradeType.ToString()) { case "Long": iTradeType = 0; break; case "Short": iTradeType = 1; break; } //UPDATE `tradesassistant`.`trades` SET `trade_type`='0', `trade_sum`='2120.00' WHERE `id`='6'; string query = "UPDATE `" + Schema + "`.`" + Table + "` SET " + "`instrument_name`='" + InstrumentName + "', " + "`instrument_class`='" + iInstrumentType.ToString() + "', " + "`instrument_ticker`='" + Ticker + "', " + "`trade_type`='" + iTradeType.ToString() + "', " + "`opening_price`='" + OpeningPrice.ToString().Replace(",", ".") + "', " + "`trade_volume`='" + TradeSize.ToString() + "', " + "`trade_sum`='" + TradeSum.ToString().Replace(",", ".") + "', " + "`trade_closed`='" + iTradeClosed.ToString() + "', " + "`closing_price`='" + ClosingPrice.ToString().Replace(",", ".") + "', " + "`comissions`='" + Comission.ToString().Replace(",", ".") + "', " + "`taxes`='" + Taxes.ToString().Replace(",", ".") + "', " + "`profit`='" + Profit.ToString().Replace(",", ".") + "' " + "WHERE `id`='" + TradeId + "';"; return(query); }
public void Comission(Comission comission, Project project) { SendMailFromDb(project, project, ProjectWorkflow.Trigger.Comission, UserType.Admin); }
public IActionResult InsertComission(InsertComissionDto input) { try { var userId = ClaimPrincipalFactory.GetUserId(User); #region Validation var validator = new ParamValidator(); validator.ValidateNull(input.Title, General.Messages_.NullInputMessages_.GeneralNullMessage("عنوان")) .ValidateNull(input.Value, General.Messages_.NullInputMessages_.GeneralNullMessage("مقدار کمیسیون")) .Throw(General.Results_.FieldNullErrorCode()); if (input.Value > 70) { throw new BusinessException("مقدار کمیسیون نباید بیشتر از 70 باشد.", 1001); } if (input.ProductIdList.Count == 0) { throw new BusinessException("محصولی انتخاب نشده است.", 1001); } #endregion var productIdList = new List <Product>(); var comission = new Comission { Cdate = DateTime.Now.Ticks, CuserId = userId, SendEmail = input.SendEmail, SendSms = input.SendSms, Title = input.Title, Value = input.Value, ProductComission = new List <ProductComission>() }; input.ProductIdList.ForEach(c => { #region Change Product Status var product = _repository.Product.FindByCondition(x => x.Id == c).Include(c => c.Seller).FirstOrDefault(); if (product == null) { throw new BusinessException("کد محصولات صحیح نیست", 1001); } productIdList.Add(product); product.FinalStatusId = 7; _repository.Product.Update(product); #endregion #region Deactive Previous Comission var _productComission = _repository.ProductComission .FindByCondition(x => x.ProductId == c && x.DaDate == null).FirstOrDefault(); if (_productComission != null) { _productComission.DaDate = DateTime.Now.Ticks; _productComission.DaUserId = userId; _repository.ProductComission.Update(_productComission); } #endregion var productComission = new ProductComission { CuserId = userId, Cdate = DateTime.Now.Ticks, ProductId = c, }; comission.ProductComission.Add(productComission); }); #region SendSms if (input.SendSms) { productIdList.ForEach(c => { var sms = new SendSMS(); sms.SendChangeComissionSms(c.Seller.Mobile.Value, c.Seller.Name + " " + c.Seller.Fname, c.Name, comission.Value.Value); }); } #endregion #region SendEmail if (input.SendEmail) { productIdList.ForEach(c => { var email = new SendEmail(); email.SendChangeComissionEmail(c.Seller.Email, c.Seller.Name + " " + c.Seller.Fname, c.Name, comission.Value.Value); }); } #endregion _repository.Comission.Create(comission); _repository.Save(); _logger.LogData(MethodBase.GetCurrentMethod(), comission.Id, null, input); return(Ok(comission.Id)); } catch (Exception e) { _logger.LogError(e, MethodBase.GetCurrentMethod(), input); return(BadRequest(e.Message)); } }