private void copyAndPasteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (trvAssetCatogryTree.SelectedNode != null && trvAssetCatogryTree.SelectedNode.ToString() != "")
     {
         CrAssetCatogry = AssetCatogry.FindByAstCatId(Convert.ToInt32(trvAssetCatogryTree.SelectedNode.Tag.ToString()));
         CrAssetCatogry.IsNew = true;
         CrAssetCatogry.IsCopy = true;
         CrAssetCatogry.AstCatId = Convert.ToInt32(null);
         ShowGUI();
         this.FormStatus = FormStatusEnum.Edit;
     }
 }
 private void addToolStripMenuItem_Click(object sender, EventArgs e)
 {
     CrAssetCatogry = new BackOfficeBL.Accounting.AssetCatogry();
     if (trvAssetCatogryTree.SelectedNode != null && trvAssetCatogryTree.SelectedNode.ToString() != "")
     {
         var parent = AssetCatogry.FindByAstCatId(Convert.ToInt32(trvAssetCatogryTree.SelectedNode.Tag.ToString()));
         CrAssetCatogry.ParentId = (Convert.ToInt32(trvAssetCatogryTree.SelectedNode.Tag.ToString()));
     }
     ShowGUI();
     this.FormStatus = FormStatusEnum.AddNew;
     //trvAssetCatogryTree.Enabled = false;
 }
 public static AssetCatogry FindByAstCatId(int? _VaidationID)
 {
     NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
     var dbAssetCatogrys = from u in newAppsCnn.Ast_AssetCatogry where u.AstCatId == _VaidationID select u;
     if (dbAssetCatogrys.Count() > 0)
     {
         Ast_AssetCatogry dbAssetCatogry = dbAssetCatogrys.First();
         AssetCatogry account = new AssetCatogry();
         account.FromDbAssetCatogry(dbAssetCatogry);
         account.IsNew = false;
         account.IsCopy = false;
         return account;
     }
     else
         return null;
 }
 public static List<AssetCatogry> GetAllAssetCatogryTree()
 {
     List<AssetCatogry> result = new List<AssetCatogry>();
     NewAppsCnn newAppsCnn = new NewAppsCnn(AppSettings.CrAppSettings.NewAppsConnectionString);
     var dbAssetCatogrys = from g in newAppsCnn.Ast_AssetCatogry select g;
     foreach (var dbAssetCatogry in dbAssetCatogrys)
     {
         AssetCatogry account = new AssetCatogry();
         account.FromDbAssetCatogry(dbAssetCatogry);
         result.Add(account);
     }
     return result;
 }
 private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (trvAssetCatogryTree.SelectedNode != null && trvAssetCatogryTree.SelectedNode.ToString() != "")
     {
         CrAssetCatogry = AssetCatogry.FindByAstCatId(Convert.ToInt32(trvAssetCatogryTree.SelectedNode.Tag));
         DataDeleteResult result = CrAssetCatogry.Delete();
         if (result.DeleteStatus == false)
         {
             MessageBox.Show(result.ErrorMessage);
         }
         else
         {
             CrAssetCatogry = null;
             ShowGUI();
             this.FormStatus = FormStatusEnum.DataPreview;
         }
     }
 }
 private void trvAssetCatogryTree_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (this.FormStatus == FormStatusEnum.Edit)
     {
         trvAssetCatogryTree.SelectedNode = trvAssetCatogryTree.Nodes.Find(trvAssetCatogryTree.SelectedNode.Tag.ToString(), true)[0];
         return;
     }
     string AssetCatogryNo = trvAssetCatogryTree.SelectedNode != null ? trvAssetCatogryTree.SelectedNode.Tag.ToString() : "";
     if (AssetCatogryNo != "")
     {
         CrAssetCatogry = AssetCatogry.FindByAstCatId(Convert.ToInt32(trvAssetCatogryTree.SelectedNode.Tag.ToString()));
         ShowGUI();
     }
     trvAssetCatogryTree.Focus();
 }
 private void frmAssetCatogry_Save(object sender, ref bool _status)
 {
     GetDataFromGUI();
     DataSaveResult saveResult = CrAssetCatogry.Save();
     if (saveResult.SaveStatus == false)
     {
         _status = false;
     }
     else
     {
         CrAssetCatogry = null;
         ShowGUI();
     }
     trvAssetCatogryTree.Enabled = true;
 }
 private void frmAssetCatogry_Edit(object sender, ref bool _status)
 {
     CrAssetCatogry = AssetCatogry.FindByAstCatId(Convert.ToInt32(trvAssetCatogryTree.SelectedNode.Tag));
     if (CrAssetCatogry == null)
     {
         _status = false;
     }
     else
     {
         if (CrAssetCatogry.IsNew == true)
         {
             _status = false;
         }
         else
         {
             ShowGUI();
         }
     }
 }
        private void frmAssetCatogry_Delete(object sender, ref bool _status)
        {
            CrAssetCatogry = AssetCatogry.FindByAstCatId(Convert.ToInt32(trvAssetCatogryTree.SelectedNode.Tag));
            DataDeleteResult result = CrAssetCatogry.Delete();

            _status = result.DeleteStatus;
            if (result.DeleteStatus == false)
            {
                MessageBox.Show(result.ErrorMessage);
            }
            else
            {
                CrAssetCatogry = null;
                ShowGUI();
            }
            trvAssetCatogryTree.Enabled = true;
        }
 private void frmAssetCatogry_Cancel(object sender)
 {
     CrAssetCatogry = null;
     ShowGUI();
     trvAssetCatogryTree.Enabled = true;
 }
 private void frmAssetCatogry_AddNew(object sender, ref bool _status)
 {
     CrAssetCatogry = new BackOfficeBL.Accounting.AssetCatogry();
 }