private void btnDelLeaf_Click(object sender, EventArgs e) { //delete this leaf lblStat.Text = DAL.delete_Leaf(txtLeafId.Text); }
private void fill_Cbo() { try { //fill TREE cbo with current unique trees List <DTO.cboItem> lstUTrees = DAL.get_Unique_Trees(); if (lstUTrees.Count() > 0) { lstUTrees.Insert(0, new DTO.cboItem("Please select a Tree to get TreeId", "0")); } else { lstUTrees.Insert(0, new DTO.cboItem("None", "0")); } BindingSource bs = new BindingSource(); bs.DataSource = lstUTrees; cboUTrees.DataSource = bs; cboUTrees.DisplayMember = "Name"; cboUTrees.ValueMember = "Id"; //cboUTrees.SelectionChanged += new SelectionChangedEventHandler(cboUTrees_SelectionChanged); //fill CATEGORY cbo with unique categories from DB List <DTO.cboItem> lstUCats = DAL.get_Unique_Leaf_Categories(); if (lstUCats.Count() > 0) { lstUCats.Insert(0, new DTO.cboItem("Please select a Category", "0")); } else { lstUCats.Insert(0, new DTO.cboItem("None", "0")); } BindingSource bs2 = new BindingSource(); bs2.DataSource = lstUCats; cboLeafCategory.DataSource = bs2; cboLeafCategory.DisplayMember = "Name"; cboLeafCategory.ValueMember = "Id"; //fill SUB-CATEGORY cbo with unique sub-categories from DB List <DTO.cboItem> lstUSubCats = DAL.get_Unique_Sub_Categories(); if (lstUSubCats.Count() > 0) { lstUSubCats.Insert(0, new DTO.cboItem("Please select a Sub-Category", "0")); } else { lstUSubCats.Insert(0, new DTO.cboItem("None", "0")); } BindingSource bs3 = new BindingSource(); bs3.DataSource = lstUSubCats; cboLeafSubCat.DataSource = bs3; cboLeafSubCat.DisplayMember = "Name"; cboLeafSubCat.ValueMember = "Id"; //fill LEAF TYPE cbo with unique leaf Types from DB List <DTO.cboItem> lstLeafTypes = DAL.get_Unique_Leaf_Types(); if (lstLeafTypes.Count() > 0) { lstLeafTypes.Insert(0, new DTO.cboItem("Please select a Leaf Type", "0")); } else { lstLeafTypes.Insert(0, new DTO.cboItem("None", "0")); } BindingSource bs4 = new BindingSource(); bs4.DataSource = lstLeafTypes; cboLeafType.DataSource = bs4; cboLeafType.DisplayMember = "Name"; cboLeafType.ValueMember = "Id"; //fill SEARCH cbo with unique leaf NAME from DB List <DTO.cboItem> lstLeafNames = DAL.get_Unique_Leaf_Names(); if (lstLeafNames.Count() > 0) { lstLeafNames.Insert(0, new DTO.cboItem("Please select a Leaf Name", "0")); } else { lstLeafNames.Insert(0, new DTO.cboItem("None", "0")); } BindingSource bs5 = new BindingSource(); bs5.DataSource = lstLeafNames; cboSearchName.DisplayMember = "Name"; cboSearchName.ValueMember = "Id"; cboSearchName.DataSource = bs5; //fill SEARCH cbo with unique leaf CATEGORY from DB List <DTO.cboItem> lstLeafCategory = DAL.get_Unique_Leaf_Categories(); if (lstLeafCategory.Count() > 0) { lstLeafCategory.Insert(0, new DTO.cboItem("Please select a Leaf Category", "0")); } else { lstLeafCategory.Insert(0, new DTO.cboItem("None", "0")); } BindingSource bs6 = new BindingSource(); bs6.DataSource = lstLeafCategory; cboSearchCategory.DisplayMember = "Name"; cboSearchCategory.ValueMember = "Id"; cboSearchCategory.DataSource = bs6; } catch (Exception ex) { string crap = "yup"; } txtTreeId.Text = ""; }
private void btnDelTree_Click(object sender, EventArgs e) { //delete this tree lblStat.Text = DAL.delete_Tree(txtTreeId.Text); }
private string saveTreeToDb() { //save tree to db string strRetMsg = "Save to DB failed."; string[] filesToImport; try { //set up treeview //now do listview stuff int iCnt = 0; //set up the list view lvFiles.Clear(); lvFiles.Columns.Add("Name", -2, HorizontalAlignment.Left); lvFiles.Columns[0].Width = 300; //lvFiles.Columns[0].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); lvFiles.Columns.Add("Size", -2, HorizontalAlignment.Left); if (!Util.FileOrDirectoryExists(txtRootPath.Text)) { strRetMsg = String.Format("Invalid tree root path (" + txtRootPath.Text + "). Ready."); return(strRetMsg); } if (string.IsNullOrEmpty(txtTreeName.Text)) { DateTime dt = DateTime.UtcNow; txtTreeName.Text = String.Format("Default Tree Name_{0}", dt.ToString("yyyyMMddHHMMss")); } string selectedPath = txtRootPath.Text.Replace("'", ""); txtRootPath.Text = selectedPath; if (chkFiles.Checked) { filesToImport = Directory.GetFiles(selectedPath, "*", SearchOption.AllDirectories); } else { filesToImport = Directory.GetDirectories(selectedPath, "*", SearchOption.AllDirectories); } string strTreeId = Guid.NewGuid().ToString(); string strTreeCreateDate = DateTime.UtcNow.ToString(); txtTreeId.Text = strTreeId; //first save the new tree DTO.DocTree inDocTree = new DTO.DocTree { TreeId = strTreeId, TreeName = txtTreeName.Text, TreeRoot = selectedPath, TreeCreateDate = strTreeCreateDate, TreeComment = txtComment.Text, TreeType = "Video" }; lblStat.Text = "Saving Tree to db . . ."; Application.DoEvents(); strRetMsg = DAL.save_One_New_Tree(inDocTree); //got path, iterate folders foreach (var filePath in filesToImport) { iCnt++; var file = new FileInfo(filePath); string[] treePath = filePath.Replace(selectedPath, "").Split('\\'); var folderSize = GetDirectorySize(filePath); var folderName = file.Name.Replace("'", "").Replace(",", "_"); DTO.DocTree newDocFold = new DTO.DocTree { TreeId = strTreeId, TreeName = txtTreeName.Text, TreeCreateDate = strTreeCreateDate, TreeComment = txtComment.Text, TreeType = Guid.NewGuid().ToString(), TreeRoot = selectedPath.Replace("'", ""), LeafId = Guid.NewGuid().ToString(), LeafName = folderName, LeafCreated = file.CreationTime.ToString(), LeafCreatUser = file.FullName.Replace("'", ""), LeafPath = file.Directory.ToString().Replace("'", ""), LeafSize = folderSize.ToString(), LeafCategory = "Imported", LeafSubCategory = "None", LeafLocation = txtLocation.Text, LeafType = "Video", LeafViewed = "false", LeafComment = txtLeafComment.Text }; //save the new leaf strRetMsg = DAL.save_One_New_Leaf(newDocFold); //add the leaf to the listview var lvFolder = new ListViewItem(new[] { newDocFold.LeafName, newDocFold.LeafSize }); lvFolder.Tag = newDocFold; lvFiles.Items.Add(lvFolder); lblStat.Text = lblStat.Text + " ."; Application.DoEvents(); } //completed tree & leaf save operation Application.DoEvents(); lblStat.Text = "Done saving Tree and Leaf's (" + iCnt.ToString() + "). Ready."; } catch (Exception ex) { lblStat.Text = "Error saving tree to DB: " + ex.Message + "."; } return(strRetMsg); }