Exemplo n.º 1
0
        private void NewCategory()
        {
            if (this.CategoryTree.SelectedNode.Tag is Categories)
            {
                Categories cparent = (Categories)(CategoryTree.SelectedNode.Tag);

                NewCategoryForm ncf = new NewCategoryForm();
                if (ncf.ShowDialog() == DialogResult.OK)
                {
                    Categories c = new Categories {
                        CategoryName = ncf.CategoryName, CategoryDesc = ncf.CategoryDesc, CategoryParent = cparent.CategoryID
                    };
                    db.Categories.InsertOnSubmit(c);
                    db.SubmitChanges();

                    TreeNode tn = new TreeNode();
                    tn.Tag         = c;
                    tn.Text        = c.CategoryName;
                    tn.ToolTipText = c.CategoryDesc;

                    CreateSonNode(this.CategoryTree.SelectedNode); // 起码要初始化

                    this.CategoryTree.SelectedNode.Nodes.Add(tn);  // 完成节点添加
                }
            }
        }
        public IActionResult Categories()
        {
            NewCategoryForm newCategory = new NewCategoryForm();

            newCategory.CurrentCatogories = dbContext.Categories.ToList();
            return(View(newCategory));
        }
Exemplo n.º 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            NewCategoryForm ncf = new NewCategoryForm(category.Categorys.Payment);

            if (ncf.ShowDialog() == DialogResult.OK)
            {
                loadData();
            }
            else
            {
                XtraMessageBox.Show("Categoria não cadastrada!");
            }
        }
Exemplo n.º 4
0
        private void NewKeyword()
        {
            if (this.CategoryTree.SelectedNode.Tag is Categories)
            {
                Categories target = (Categories)(this.CategoryTree.SelectedNode.Tag);

                // 这里先借用新建类别的对话框
                NewCategoryForm nkf = new NewCategoryForm();
                nkf.Text = "新建关键字";
                if (nkf.ShowDialog() == DialogResult.OK)
                {
                    Keywords nk = new Keywords {
                        KeywordName = nkf.CategoryName,
                        KeywordDesc = nkf.CategoryDesc,
                        KeywordRate = 3,
                        Categories  = target
                    };// 注意这里Categories的赋值
                    nk.KeywordSubPath = JianLi3FileServiceManager.Default.CreateSubFolderInLib(nk.KeywordName);
                    db.Keywords.InsertOnSubmit(nk);
                    db.SubmitChanges();

                    KeywordAndUser ku = new KeywordAndUser();
                    ku.Keyword     = nk;
                    ku.UserKeyword = JianLiLinq.Default.GetUserKeyword(nk);

                    db.SubmitChanges();

                    TreeNode tn = new TreeNode();
                    tn.Tag         = ku;
                    tn.Text        = nk.KeywordName;
                    tn.ToolTipText = nk.KeywordDesc;

                    tn.ForeColor = Color.Blue;

                    CreateSonNode(CategoryTree.SelectedNode);

                    CategoryTree.SelectedNode.Nodes.Add(tn);
                }
            }
        }
        public IActionResult NewCategory(NewCategoryForm returnCategory)
        {
            if ((!ModelState.IsValid) || ((ModelState.IsValid) && (dbContext.Categories.Any(u => u.Name == returnCategory.Name))))
            {
                if (ModelState.IsValid)
                {
                    ModelState.AddModelError("Name", "Category already existed!");
                }
                NewCategoryForm newCategory = new NewCategoryForm();
                newCategory.CurrentCatogories = dbContext.Categories.ToList();
                return(View("Categories", newCategory));
            }

            else
            {
                Category newcategory = new Category();
                newcategory.Name = returnCategory.Name;
                dbContext.Categories.Add(newcategory);
                dbContext.SaveChanges();
                return(Redirect("/categories"));
            }
        }
Exemplo n.º 6
0
        private void EditCategory()
        {
            if (CategoryTree.SelectedNode.Tag is Categories)
            {
                Categories      target = (Categories)(CategoryTree.SelectedNode.Tag);
                NewCategoryForm cf     = new NewCategoryForm();
                cf.Text         = "编辑类别";
                cf.CategoryDesc = target.CategoryDesc;
                cf.CategoryName = target.CategoryName;

                if (cf.ShowDialog() == DialogResult.OK)
                {
                    target.CategoryName = cf.CategoryName;
                    target.CategoryDesc = cf.CategoryDesc;

                    CategoryTree.SelectedNode.Text        = target.CategoryName;
                    CategoryTree.SelectedNode.ToolTipText = target.CategoryDesc;

                    db.SubmitChanges();
                }
            }
        }
Exemplo n.º 7
0
        void credit()
        {
            Dictionary <string, double?> result_map = new Dictionary <string, double?>();
            Dictionary <string, int?>    shops      = new Dictionary <string, int?>();

            textBox2.Text = "";

            if (string.IsNullOrEmpty(creditCardPath))
            {
                Microsoft.VisualBasic.Interaction.MsgBox("Please choose credit card file");
                return;
            }

            Excel.Application excel      = new Excel.Application();
            Excel.Workbook    wb         = excel.Workbooks.Open(creditCardPath);
            Excel.Worksheet   excelSheet = wb.ActiveSheet;

            try
            {
                double sum   = 0;
                double money = 0;
                string date;
                int    row = 0, first_col = 0, second_col = 0, date_col = -1;
                String shop_name = "";

                if (string.IsNullOrEmpty(bankChosen))
                {
                    Microsoft.VisualBasic.Interaction.MsgBox("Please choose bank");
                    return;
                }

                //excel = new Excel.Application();
                //            wb = excel.Workbooks.Open(creditCardPath);
                //            excelSheet = wb.ActiveSheet;

                bankData bankDataChosen = banks_hash[bankChosen];
                row        = bankDataChosen.startRow;
                first_col  = bankDataChosen.shop;
                second_col = bankDataChosen.money;
                date_col   = bankDataChosen.date;

                shop_name = excelSheet.Cells[row, first_col].Value.ToString();
                string moneyTextValue = excelSheet.Cells[row, second_col].Value.ToString();
                string moneyText      = Regex.Replace(moneyTextValue, @"[^0-9*.-]+", "");
                money = double.Parse(moneyText, CultureInfo.InvariantCulture);
                //money = excelSheet.Cells[row, second_col].Value;
                date = excelSheet.Cells[row, date_col].Value.ToString();
                //date = date.Substring(0, date.IndexOf(" ") + 1);

                while (!String.IsNullOrEmpty(shop_name))
                {
                    if (shop_category_hash.ContainsKey(shop_name))
                    {
                        if (shops.ContainsKey(shop_name))
                        {
                            shops[shop_name] = shops[shop_name] + 1;
                        }
                        else
                        {
                            shops[shop_name] = 1;
                        }
                        string cat = shop_category_hash[shop_name];
                        add_shop_to_result(result_map, cat, money);

                        // add to sum
                        sum += money;
                    }
                    else
                    {
                        NewCategoryForm categoryForm = new NewCategoryForm(sortedCategories, shop_name, money, date);
                        categoryForm.StartPosition = FormStartPosition.CenterParent;
                        categoryForm.ShowDialog();
                        string cat = categoryForm.result;

                        //string cat = Microsoft.VisualBasic.Interaction.InputBox("Enter new category for " + shop_name + "\nSum: " + money + "\nDate: " + date, "New category", "Enter category here", 450, 300).ToString();
                        if (!String.IsNullOrEmpty(cat) && !cat.Equals("Enter category here") && !categoryForm.ignoreRecord)
                        {
                            try
                            {
                                using (StreamWriter sw = new StreamWriter(data_dir + shops_file, true, System.Text.Encoding.GetEncoding(1255), 512))
                                {
                                    sw.WriteLine(shop_name + "#" + cat);
                                    shop_category_hash[shop_name] = cat;
                                    add_shop_to_result(result_map, cat, money);

                                    if (categoryForm.isNew)
                                    {
                                        sortedCategories.Add(cat);
                                        sortedCategories.Sort();
                                    }

                                    // add to sum
                                    sum += money;
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }

                    // prepare next record
                    row++;
                    shop_name = excelSheet.Cells[row, first_col].Value;

                    //finished
                    if (String.IsNullOrEmpty(shop_name))
                    {
                        break;
                    }

                    date = excelSheet.Cells[row, date_col].Value.ToString();

                    if (excelSheet.Cells[row, second_col].Value != null && !excelSheet.Cells[row, second_col].Value.Equals(""))
                    {
                        moneyText = Regex.Replace(excelSheet.Cells[row, second_col].Value.ToString(), @"[^0-9*.-]+", "");
                        money     = double.Parse(moneyText, CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        money = 0;
                    }
                }

                print_result(result_map);
                print_attention(shops);
                textBox2.Text += "Total amount: " + sum;
                //closeAllFiles(excel, wb, excelSheet);
                string user = Console.ReadLine();

                saveToExolidit(result_map, exolidit_hash);
            }
            catch (FileNotFoundException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
            catch (IOException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
            catch (Exception ex)
            {
                String msg = "";
                if (!String.IsNullOrEmpty(bankSuspected))
                {
                    msg = String.Format("Credit card is suspected to be of type [{0}] or invalid", bankSuspected);
                }
                else
                {
                    msg = "Credit card file is unknown or invalid";
                }

                Microsoft.VisualBasic.Interaction.MsgBox(msg, Microsoft.VisualBasic.MsgBoxStyle.OkOnly, "Credit card");
            }

            closeAllFiles(excel, wb, excelSheet);
        }