private void btnModify_ItemClick(object sender, ItemClickEventArgs e) { try { DALLayer.Accounts ac = acc.Get(txtAccCode.Text); ac.accName = txtAccName.Text; ac.accLevel = int.Parse(txtAccLevel.Text); ac.MainAccCode = txtMainAccountCode.Text == "" ? null : txtMainAccountCode.Tag.ToString(); ac.typeCode = int.Parse(AccountType.EditValue.ToString()); ac.AllowManualEntry = AllowManualEntry.Checked; acc.Update(ac); MessageBox.Show("success"); node.Text = txtAccCode.Text + "--" + txtAccName.Text; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnDelete_ItemClick(object sender, ItemClickEventArgs e) { try { if (txtAccLevel.Text == "1") { MessageBox.Show("You Can't Delete This Account "); return; } DALLayer.Accounts ac = acc.Get(txtAccCode.Text); acc.Delete(ac); MessageBox.Show("Success"); AccountTree.Nodes.Remove(node); AccountTree_AfterSelect(null, null); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void AccountTree_AfterSelect(object sender, TreeViewEventArgs e) { try { node = AccountTree.SelectedNode; txtAccCode.Text = node.Tag.ToString(); txtAccName.Text = node.Text.Split('-')[2]; DALLayer.Accounts ac = acc.Get(txtAccCode.Text); txtMainAccountCode.Text = ac.MainAccCode == null ? "" : acc.Get(ac.MainAccCode).accName; txtMainAccountCode.Tag = ac.MainAccCode == null ? "" : acc.Get(ac.MainAccCode).accCode; AccountType.EditValue = ac.typeCode; txtAccLevel.Text = ac.accLevel.ToString(); AllowManualEntry.Checked = (bool)ac.AllowManualEntry; btnSave.Enabled = false; btnAddNew.Enabled = btnModify.Enabled = btnDelete.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } }