private void btnDeleteCostRule_Click(object sender, EventArgs e) { try { if (costRule != null) { int result = CRUDStatusCode.ERROR; _costRuleService = new CostRuleService(); result = _costRuleService.DeleteCostRule(costRule.Id); if (result == CRUDStatusCode.SUCCESS) { Utilities.ShowMessage(CommonMessage.DELETE_SUCESSFULLY); LoadDGV(); Logging.LogBusiness(string.Format("{0} {1} {2}", Common.Session.GetUserName(), Common.Constants.LogAction.Delete, "giá tiền " + costRule.Length + " loại hình " + costRule.ShowTypeId + " của thời điểm " + model.Code), Common.Constants.BusinessLogType.Delete); } } } catch (Exception) { throw; } finally { _costRuleService = null; } }
private void LoadDGV() { try { _costRuleService = new CostRuleService(); List <CostRuleViewModel> costRuleVMs = _costRuleService.GetAllForList(model.Id); SortableBindingList <CostRuleViewModel> sbl = new SortableBindingList <CostRuleViewModel>(costRuleVMs); bs = new BindingSource(); bs.DataSource = sbl; adgv.DataSource = bs; adgv.ClearSelection(); adgv.Columns["Id"].Visible = false; adgv.Columns["TimeSlotId"].Visible = false; adgv.Columns["Length"].HeaderText = ADGVText.Duration; adgv.Columns["Length"].Width = ControlsAttribute.GV_WIDTH_NORMAL; adgv.Columns["ShowType"].HeaderText = ADGVText.ShowType; adgv.Columns["ShowType"].Width = ControlsAttribute.GV_WIDTH_NORMAL; adgv.Columns["Price"].HeaderText = ADGVText.Cost; adgv.Columns["Price"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } catch (Exception ex) { throw; } finally { _costRuleService = null; } }
private void GetCostRule() { try { if (CompleteLoadData >= 1) { _costRuleService = new CostRuleService(); var costRule = _costRuleService.GetCostRule((int)cboTimeSlot.SelectedValue, model.ShowTypeId, model.TimeSlotLength); if (costRule != null) { CostRulePrice = costRule.Price; txtCost.Text = Utilities.DoubleMoneyToText(costRule.Price); } } } catch (Exception ex) { throw; } finally { CompleteLoadData = 2; _costRuleService = null; } }
private void btnSaveCostRule_Click(object sender, EventArgs e) { try { if (costRule != null) { //Edit int result = CRUDStatusCode.ERROR; costRule.ShowTypeId = (int)cboShowType.SelectedValue; costRule.Price = (double)txtPrice.MoneyValue; costRule.Length = (int)cboDuration.SelectedValue; _costRuleService = new CostRuleService(); result = _costRuleService.EditCostRule(costRule); if (result == CRUDStatusCode.SUCCESS) { LoadDGV(); Utilities.ShowMessage(CommonMessage.EDIT_SUCESSFULLY); Logging.LogBusiness(string.Format("{0} {1} {2}", Common.Session.GetUserName(), Common.Constants.LogAction.Update, "giá tiền " + costRule.Length + " loại hình " + costRule.ShowTypeId + " của thời điểm " + model.Code), Common.Constants.BusinessLogType.Update); } } else { //Add int result = CRUDStatusCode.ERROR; _costRuleService = new CostRuleService(); CostRule newCodeRule = new CostRule() { Length = (int)cboDuration.SelectedValue, Price = (double)txtPrice.MoneyValue, TimeSlotId = model.Id, ShowTypeId = (int)cboShowType.SelectedValue }; result = _costRuleService.AddCostRule(newCodeRule); if (result == CRUDStatusCode.SUCCESS) { Utilities.ShowMessage(CommonMessage.ADD_SUCESSFULLY); LoadDGV(); Logging.LogBusiness(string.Format("{0} {1} {2}", Common.Session.GetUserName(), Common.Constants.LogAction.Create, "giá tiền " + newCodeRule.Length + " loại hình " + newCodeRule.ShowTypeId + " của thời điểm " + model.Code), Common.Constants.BusinessLogType.Create); } } } catch (Exception ex) { throw; } finally { _costRuleService = null; } }
private CostRule GetCostRuleById(int id) { try { _costRuleService = new CostRuleService(); CostRule costRule = _costRuleService.GetById(id); return(costRule); } catch (Exception) { throw; } finally { _costRuleService = null; } }