protected void dgItemAccount_ItemCommand(object source, DataGridCommandEventArgs e) { ItemAccount ItemAccount = new ItemAccount(); if (e.CommandName == "AddNew") { try { TextBox txtFItemAccountName = e.Item.FindControl("txtFItemAccountName") as TextBox; ItemAccount.AccountName = txtFItemAccountName.Text; TextBox txtFItemAccountCode = e.Item.FindControl("txtFItemAccountCode") as TextBox; ItemAccount.AccountCode = txtFItemAccountCode.Text; ItemAccount.Status = "Active"; SaveItemAccount(ItemAccount); dgItemAccount.EditItemIndex = -1; BindItemAccount(); } catch (Exception ex) { Master.ShowMessage(new AppMessage("Error: Unable to Add Item Account " + ex.Message, RMessageType.Error)); ExceptionUtility.LogException(ex, ex.Source); ExceptionUtility.NotifySystemOps(ex, _presenter.CurrentUser().FullName); } } }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { this._presenter.OnViewInitialized(); BindItemAccount(); } this._presenter.OnViewLoaded(); _ItemAccount = Session["ItemAccount"] as ItemAccount; }
public void Update(int id, string accountNo, string description, int?parentID, bool isActive) { ItemAccount obj = ctx.ItemAccounts.Single(row => row.ID == id); obj.AccountNo = accountNo; obj.Description = description; obj.ParentID = parentID; obj.IsActive = isActive; EntityHelper.SetAuditFieldForInsert(obj, HttpContext.Current.User.Identity.Name); ctx.SubmitChanges(); }
public void Add(string accountNo, string description, int?parentID, bool isActive) { ItemAccount obj = new ItemAccount(); obj.AccountNo = accountNo; obj.Description = description; obj.ParentID = parentID; obj.IsActive = isActive; EntityHelper.SetAuditFieldForInsert(obj, HttpContext.Current.User.Identity.Name); ctx.ItemAccounts.InsertOnSubmit(obj); ctx.SubmitChanges(); }
protected void dgItemAccount_SelectedIndexChanged(object sender, EventArgs e) { int itemAccountID = (int)dgItemAccount.DataKeys[dgItemAccount.SelectedIndex]; Session["itemAccountID"] = itemAccountID; dgItemAccount.SelectedItemStyle.BackColor = System.Drawing.Color.BurlyWood; accountDiv.Visible = true; _ItemAccount = _presenter.GetItemAccountById(itemAccountID); Session["ItemAccount"] = _ItemAccount; PnlChecklists.Visible = true; BindChecklists(); }
public void Add(string accountNo, string description, int?parentID, bool isActive) { ItemAccount obj = new ItemAccount(); obj.AccountNo = accountNo; obj.Description = description; obj.ParentID = parentID; obj.IsActive = isActive; EntityHelper.SetAuditFieldForInsert(obj, principal.Identity.Name); context.Add(obj); context.SaveChanges(); }
protected void tvwAccount_SelectedNodeChanged(object sender, EventArgs e) { int id = Convert.ToInt32(tvwAccount.SelectedNode.Value); RowID = id; ItemAccount account = ItemAccountService.Get(id); txtAccountNo.Text = account.AccountNo; txtAccountDescription.Text = account.Description; chkActive.Checked = account.IsActive; chkCascade.Checked = false; ddlParentAccount.SelectedValue = account.ParentID.HasValue ? account.ParentID.Value.ToString() : "0"; }
protected void dgTravelAdvanceRequestCost_UpdateCommand(object source, DataGridCommandEventArgs e) { tac = Session["tac"] as TravelAdvanceRequestDetail; int id = (int)dgTravelAdvanceRequestCost.DataKeys[e.Item.ItemIndex]; TravelAdvanceCost taCost; decimal pretacost = 0; if (id > 0) { taCost = tac.GetTravelAdvanceCost(id); } else { taCost = tac.TravelAdvanceCosts[e.Item.ItemIndex]; } try { taCost.TravelAdvanceRequestDetail = taCost.TravelAdvanceRequestDetail; DropDownList ddlEdtAccountDescription = e.Item.FindControl("ddlEdtAccountDescription") as DropDownList; ItemAccount itemEdtAccount = _presenter.GetItemAccount(Convert.ToInt32(ddlEdtAccountDescription.SelectedValue)); taCost.ItemAccount = itemEdtAccount; taCost.AccountCode = itemEdtAccount.AccountCode; DropDownList ddlExpenseType = e.Item.FindControl("ddlEdtExpenseType") as DropDownList; ExpenseType expensetype = _presenter.GetExpenseType(int.Parse(ddlExpenseType.SelectedValue)); taCost.ExpenseType = expensetype; TextBox txtEdtDays = e.Item.FindControl("txtEdtDays") as TextBox; taCost.Days = Convert.ToInt32(txtEdtDays.Text); TextBox txtEdtUnitCost = e.Item.FindControl("txtEdtUnitCost") as TextBox; taCost.UnitCost = Convert.ToDecimal(txtEdtUnitCost.Text); TextBox txtEdtNoOfUnits = e.Item.FindControl("txtEdtNoOfUnits") as TextBox; taCost.NoOfUnits = Convert.ToInt32(txtEdtNoOfUnits.Text); //TextBox txtEdtTotal = e.Item.FindControl("txtEdtTotal") as TextBox; pretacost = taCost.Total; taCost.Total = Convert.ToInt32(txtEdtDays.Text) * Convert.ToDecimal(txtEdtUnitCost.Text) * Convert.ToInt32(txtEdtNoOfUnits.Text); _presenter.CurrentTravelAdvanceRequest.TotalTravelAdvance = (_presenter.CurrentTravelAdvanceRequest.TotalTravelAdvance + taCost.Total) - pretacost; txtTotal.Text = (_presenter.CurrentTravelAdvanceRequest.TotalTravelAdvance).ToString(); dgTravelAdvanceRequestCost.EditItemIndex = -1; BindCostsGrid(taCost.TravelAdvanceRequestDetail); ScriptManager.RegisterStartupScript(this, GetType(), "showCostModal", "showCostModal();", true); Master.ShowMessage(new AppMessage("Travel Advance Cost Successfully Updated", RMessageType.Info)); } catch (Exception ex) { Master.ShowMessage(new AppMessage("Error: Unable to Update Travel Advance Cost " + ex.Message, RMessageType.Error)); ExceptionUtility.LogException(ex, ex.Source); ExceptionUtility.NotifySystemOps(ex, _presenter.CurrentUser().FullName); } }
private Stack <ItemAccount> _GetAccountHierarchy(Stack <ItemAccount> stack, string accountNo) { ItemAccount account = ctx.ItemAccounts.Single(row => row.AccountNo == accountNo); if (account.ParentID.HasValue) { stack.Push(account); _GetAccountHierarchy(stack, Get(account.ParentID.Value).AccountNo); } else { stack.Push(account); } return(stack); }
protected void dgTravelAdvanceRequestCost_ItemCommand(object source, DataGridCommandEventArgs e) { tac = Session["tac"] as TravelAdvanceRequestDetail; if (e.CommandName == "AddNew") { try { TravelAdvanceCost taCost = new TravelAdvanceCost(); taCost.TravelAdvanceRequestDetail = tac; DropDownList ddlAccountDescription = e.Item.FindControl("ddlAccountDescription") as DropDownList; ItemAccount itemAccount = _presenter.GetItemAccount(Convert.ToInt32(ddlAccountDescription.SelectedValue)); taCost.ItemAccount = itemAccount; taCost.AccountCode = itemAccount.AccountCode; DropDownList ddlExpenseType = e.Item.FindControl("ddlExpenseType") as DropDownList; ExpenseType expensetype = _presenter.GetExpenseType(int.Parse(ddlExpenseType.SelectedValue)); taCost.ExpenseType = expensetype; TextBox txtDays = e.Item.FindControl("txtDays") as TextBox; taCost.Days = Convert.ToInt32(txtDays.Text); TextBox txtUnitCost = e.Item.FindControl("txtUnitCost") as TextBox; taCost.UnitCost = Convert.ToDecimal(txtUnitCost.Text); TextBox txtNoOfUnits = e.Item.FindControl("txtNoOfUnits") as TextBox; taCost.NoOfUnits = Convert.ToInt32(txtNoOfUnits.Text); //TextBox txtTotal = e.Item.FindControl("txtTotal") as TextBox; taCost.Total = Convert.ToInt32(txtDays.Text) * Convert.ToDecimal(txtUnitCost.Text) * Convert.ToInt32(txtNoOfUnits.Text); _presenter.CurrentTravelAdvanceRequest.TotalTravelAdvance = _presenter.CurrentTravelAdvanceRequest.TotalTravelAdvance + taCost.Total; txtTotal.Text = (_presenter.CurrentTravelAdvanceRequest.TotalTravelAdvance).ToString(); if (_presenter.CurrentTravelAdvanceRequest.Id > 0) { _presenter.CurrentTravelAdvanceRequest.GetTravelAdvanceRequestDetail(Convert.ToInt32(hfDetailId.Value)).TravelAdvanceCosts.Add(taCost); } else { _presenter.CurrentTravelAdvanceRequest.TravelAdvanceRequestDetails[Convert.ToInt32(hfDetailId.Value)].TravelAdvanceCosts.Add(taCost); } dgTravelAdvanceRequestCost.EditItemIndex = -1; BindCostsGrid(taCost.TravelAdvanceRequestDetail); ScriptManager.RegisterStartupScript(this, GetType(), "showCostModal", "showCostModal();", true); } catch (Exception ex) { Master.ShowMessage(new AppMessage("Error: Unable to Save Travel Advance Cost " + ex.Message, RMessageType.Error)); ExceptionUtility.LogException(ex, ex.Source); ExceptionUtility.NotifySystemOps(ex, _presenter.CurrentUser().FullName); } } }
public void DisableAccountCascade(string accountNo, bool isActive) { ItemAccount account = Get(accountNo); account.IsActive = isActive; List <ItemAccount> accounts = GetChildAccount(accountNo).ToList(); if (accounts.Count() == 0) { return; } foreach (var item in accounts) { DisableAccountCascade(item.AccountNo, isActive); } ctx.SubmitChanges(); }
public void DisableAccountCascade(string accountNo, bool isActive) { ItemAccount account = Get(accountNo); account.IsActive = isActive; List <ItemAccount> accounts = GetChildAccount(accountNo).ToList(); if (!accounts.Any()) { return; } foreach (var item in accounts) { DisableAccountCascade(item.AccountNo, isActive); } context.SaveChanges(); }
protected void dgTravelAdvanceRequestCost_ItemCommand(object source, DataGridCommandEventArgs e) { tac = Session["tac"] as TravelAdvanceRequestDetail; if (e.CommandName == "AddNew") { try { TravelAdvanceCost taCost = new TravelAdvanceCost(); taCost.TravelAdvanceRequestDetail = tac; DropDownList ddlAccountDescription = e.Item.FindControl("ddlAccountDescription") as DropDownList; ItemAccount itemAccount = _presenter.GetItemAccount(Convert.ToInt32(ddlAccountDescription.SelectedValue)); taCost.ItemAccount = itemAccount; taCost.AccountCode = itemAccount.AccountCode; DropDownList ddlExpenseType = e.Item.FindControl("ddlExpenseType") as DropDownList; ExpenseType expensetype = _presenter.GetExpenseType(int.Parse(ddlExpenseType.SelectedValue)); taCost.ExpenseType = expensetype; TextBox txtDays = e.Item.FindControl("txtDays") as TextBox; taCost.Days = Convert.ToInt32(txtDays.Text); TextBox txtUnitCost = e.Item.FindControl("txtUnitCost") as TextBox; taCost.UnitCost = Convert.ToDecimal(txtUnitCost.Text); TextBox txtNoOfUnits = e.Item.FindControl("txtNoOfUnits") as TextBox; taCost.NoOfUnits = Convert.ToInt32(txtNoOfUnits.Text); //TextBox txtTotal = e.Item.FindControl("txtTotal") as TextBox; taCost.Total = Convert.ToInt32(txtDays.Text) * Convert.ToDecimal(txtUnitCost.Text) * Convert.ToInt32(txtNoOfUnits.Text); _presenter.CurrentTravelAdvanceRequest.TotalTravelAdvance = _presenter.CurrentTravelAdvanceRequest.TotalTravelAdvance + taCost.Total; txtTotal.Text = (_presenter.CurrentTravelAdvanceRequest.TotalTravelAdvance).ToString(); if (_presenter.CurrentTravelAdvanceRequest.Id > 0) { _presenter.CurrentTravelAdvanceRequest.GetTravelAdvanceRequestDetail(Convert.ToInt32(hfDetailId.Value)).TravelAdvanceCosts.Add(taCost); } else { _presenter.CurrentTravelAdvanceRequest.TravelAdvanceRequestDetails[Convert.ToInt32(hfDetailId.Value)].TravelAdvanceCosts.Add(taCost); } dgTravelAdvanceRequestCost.EditItemIndex = -1; BindCostsGrid(taCost.TravelAdvanceRequestDetail); pnlTACost_ModalPopupExtender.Show(); } catch (Exception ex) { Master.ShowMessage(new AppMessage("Error: Unable to Save Travel Advance Cost " + ex.Message, Chai.WorkflowManagment.Enums.RMessageType.Error)); } } }
protected void dgItemAccount_DeleteCommand(object source, DataGridCommandEventArgs e) { int id = (int)dgItemAccount.DataKeys[e.Item.ItemIndex]; ItemAccount ItemAccount = _presenter.GetItemAccountById(id); try { ItemAccount.Status = "InActive"; _presenter.SaveOrUpdateItemAccount(ItemAccount); BindItemAccount(); Master.ShowMessage(new AppMessage("Item Account was Removed Successfully", RMessageType.Info)); } catch (Exception ex) { Master.ShowMessage(new AppMessage("Error: Unable to delete Item Account. " + ex.Message, RMessageType.Error)); } }
private void RestoreTreeView(string fromAccountNo) { Stack <ItemAccount> stack = ItemAccountService.GetAccountHierarchy(fromAccountNo); TreeNodeCollection nodes = tvwAccount.Nodes; while (stack.Count > 0) { ItemAccount account = stack.Pop(); foreach (TreeNode node in nodes) { if (Convert.ToInt32(node.Value) == account.ID) { node.Expand(); nodes = node.ChildNodes; break; } } } }
protected void lnbDelete_Click(object sender, EventArgs e) { try { if (RowID > 0) { int id = Convert.ToInt32(tvwAccount.SelectedNode.Value); ItemAccount currentAccount = ItemAccountService.Get(id); IEnumerable <ItemAccount> account = ItemAccountService.GetChildAccount(id); if (account.Any()) { WebFormHelper.SetLabelTextWithCssClass( lblMessage, String.Format("Cannot delete account <b>{0}</b> since it has one or more child accounts", currentAccount.AccountNo), LabelStyleNames.ErrorMessage); } else { ItemAccountService.Delete(new[] { id }); RefreshTreeView(); WebFormHelper.SetLabelTextWithCssClass( lblMessage, String.Format("Account <b>{0}</b> has been deleted.", currentAccount.AccountNo), LabelStyleNames.AlternateMessage); } } else { WebFormHelper.SetLabelTextWithCssClass( lblMessage, "No account selected, select an account first.", LabelStyleNames.ErrorMessage); } RefreshTreeView(); } catch (Exception ex) { WebFormHelper.SetLabelTextWithCssClass(lblMessage, ex.Message, LabelStyleNames.ErrorMessage); LogService.ErrorException(GetType().FullName, ex); } }
protected void dgItemAccount_UpdateCommand(object source, DataGridCommandEventArgs e) { int id = (int)dgItemAccount.DataKeys[e.Item.ItemIndex]; ItemAccount ItemAccount = _presenter.GetItemAccountById(id); try { TextBox txtName = e.Item.FindControl("txtItemAccountName") as TextBox; ItemAccount.AccountName = txtName.Text; TextBox txtCode = e.Item.FindControl("txtItemAccountCode") as TextBox; ItemAccount.AccountCode = txtCode.Text; SaveItemAccount(ItemAccount); dgItemAccount.EditItemIndex = -1; BindItemAccount(); } catch (Exception ex) { Master.ShowMessage(new AppMessage("Error: Unable to Update Item Account. " + ex.Message, RMessageType.Error)); ExceptionUtility.LogException(ex, ex.Source); ExceptionUtility.NotifySystemOps(ex, _presenter.CurrentUser().FullName); } }
private void SaveItemAccount(ItemAccount ItemAccount) { try { if (ItemAccount.Id <= 0) { _presenter.SaveOrUpdateItemAccount(ItemAccount); Master.ShowMessage(new AppMessage("Item Account saved", RMessageType.Info)); //_presenter.CancelPage(); } else { _presenter.SaveOrUpdateItemAccount(ItemAccount); Master.ShowMessage(new AppMessage("Item Account Updated", RMessageType.Info)); // _presenter.CancelPage(); } } catch (Exception ex) { Master.ShowMessage(new AppMessage(ex.Message, RMessageType.Error)); } }
public void SaveOrUpdateItemAccount(ItemAccount ItemAccount) { _controller.SaveOrUpdateEntity(ItemAccount); }
//Code xử lý trung tâm public MainViewModel() { LoadedWindowCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => { Isloaded = true; p.Hide(); LoginWindow loginWindow = new LoginWindow(); loginWindow.ShowDialog(); if (loginWindow.DataContext == null) { return; } var LoginVM = loginWindow.DataContext as LoginViewModel; if (LoginVM.IsLogin) { p.Show(); } else { p.Close(); } } ); AccountCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { ItemAccount wd = new ItemAccount(); wd.ShowDialog(); }); ExitCommand = new RelayCommand <MainWindow>((p) => { return(true); }, (p) => { p.Close(); }); // Thoát chương trình bằng Exit }
private static List <ItemAccount> ReadItemsAccount(string commandText) { var command = Database.CreateCommand(); List <ItemAccount> itemAccountList = new List <ItemAccount>(); try { if (Database.State != ConnectionState.Open) { Database.Open(); } command.CommandText = commandText; // Criando as instâncias de mesas using (MySqlDataReader reader = command.ExecuteReader()) { if (reader == null) { return(null); } while (reader.Read()) { var itemRead = new ItemAccount() { Banco = "O Baratão", Mesa = Convert.ToInt32(reader["NR_MESA"]) }; itemAccountList.Add(itemRead); } } // Checando sua disponibilidade e conta foreach (var item in itemAccountList) { item.Disponivel = Convert.ToInt32(ExecuteScalar("SELECT COUNT(*) FROM CONTA WHERE CONTA.NR_MESA = " + item.Mesa + " AND CONTA.VALOR_RECEBIDO IS NULL AND CONTA.DATA_CONTA = CURDATE()")) <= 0 ? true : false; if (item.Disponivel == true) { item.Conta = 0; } else { item.Conta = Convert.ToInt32(ExecuteScalar("SELECT CONTA.NR_CONTA FROM CONTA WHERE CONTA.NR_MESA = " + item.Mesa + " AND CONTA.VALOR_RECEBIDO IS NULL AND CONTA.DATA_CONTA = CURDATE()")); } } return(itemAccountList); } finally { if (Database.State == ConnectionState.Open) { Database.Close(); } } }
protected void dgItemDetail_UpdateCommand(object source, DataGridCommandEventArgs e) { bidd = Session["bidd"] as Bidder; int id = (int)dgItemDetail.DataKeys[e.Item.ItemIndex]; BidderItemDetail biddet; // Chai.WorkflowManagment.CoreDomain.Requests.BidderItemDetail detail = _presenter.CurrentBidAnalysisRequest.GetBidder(bidd.Id).GetBidderItemDetail(id); if (id > 0) { biddet = bidd.GetBidderItemDetail(id); } else { biddet = bidd.BidderItemDetails[e.Item.ItemIndex]; } try { biddet.Bidder = biddet.Bidder; DropDownList ddlItem = e.Item.FindControl("ddlItemAcc") as DropDownList; ItemAccount itemEdtAccount = _presenter.GetItemAccount(Convert.ToInt32(ddlItem.SelectedValue)); biddet.ItemAccount = itemEdtAccount; TextBox txtItemDescription = e.Item.FindControl("txtDescription") as TextBox; biddet.ItemDescription = txtItemDescription.Text; TextBox txtQty = e.Item.FindControl("txtEdtQty") as TextBox; biddet.Qty = Convert.ToInt32(txtQty.Text); TextBox txtUnitCost = e.Item.FindControl("txtEdtUnitCost") as TextBox; biddet.UnitCost = Convert.ToDecimal(txtUnitCost.Text); biddet.TotalCost = Convert.ToInt32(txtQty.Text) * Convert.ToDecimal(txtUnitCost.Text); dgItemDetail.EditItemIndex = -1; BindItemdetailGrid(biddet.Bidder); decimal cost = 0; if (_presenter.CurrentBidAnalysisRequest.Bidders.Count > 0) { foreach (Bidder detail in _presenter.CurrentBidAnalysisRequest.Bidders) { if (detail.Rank == 1) { foreach (BidderItemDetail biddetail in detail.BidderItemDetails) { cost = cost + biddetail.TotalCost; } } ; } } _presenter.CurrentBidAnalysisRequest.TotalPrice = cost; txtTotal.Text = _presenter.CurrentBidAnalysisRequest.TotalPrice.ToString(); pnlBidItem_ModalPopupExtender.Show(); Master.ShowMessage(new AppMessage("Bidder Item Successfully Updated", Chai.WorkflowManagment.Enums.RMessageType.Info)); } catch (Exception ex) { Master.ShowMessage(new AppMessage("Error: Unable to Add BidderItem " + ex.Message, Chai.WorkflowManagment.Enums.RMessageType.Error)); } }
public void DeleteItemAccount(ItemAccount ItemAccount) { _controller.DeleteEntity(ItemAccount); }