public void CreateUserAccessItemsFromButtons() { try { foreach (var record in context.tbl_glb_user_access_items.ToList()) { if (record.tbl_glb_user_access.Count == 0) { context.tbl_glb_user_access_items.DeleteObject(record); } } context.SaveChanges(); CreateUserAccessItemsFromButtons_Rec(SubSystemsPanel, "سیستم ها"); CreateUserAccessItemsFromButtons_Rec(grpGlobal, "اطلاعات پایه"); CreateUserAccessItemsFromButtons_Rec(grpAccounting, "حسابداری"); CreateUserAccessItemsFromButtons_Rec(grpInventory, "انبارداری"); CreateUserAccessItemsFromButtons_Rec(grpInventoryAccounting, "حسابداری انبار"); CreateUserAccessItemsFromButtons_Rec(grpSahaam, "سهام"); CreateUserAccessItemsFromButtons_Rec(grpTools, "ابزار ها و تنظیمات"); context.SaveChanges(); Messages.SuccessMessage("عملیات به روز رسانی کلیه آیتم ها"); } catch (Exception exception) { Messages.ExceptionMessage(exception); } }
public override void Window_Loaded(object sender, System.Windows.RoutedEventArgs e) { SahaamEntities dataBase = DDB.NewContext(); base.Window_Loaded(sender, e); if (allRecords.Count == 0) { dataBase.tbl_gnt_settings.AddObject( new tbl_gnt_settings() { gnt_settings_credit_meters = 1000, gnt_settings_total_credit_count = 1, gnt_settings_total_credit_price = 1, gnt_settings_accountant_name = "-", gnt_settings_chairman_name = "-", gnt_settings_executive_manager_name = "-" }); dataBase.SaveChanges(); APMTools.Messages.InformationMessage("تنظیمات به طور خودکار اضافه شد"); RefreshClick(); } CalculateOneCreditPrice(); }
public void UpdateAccountForPublicCosts() { try { SahaamEntities db = DDB.NewContext(); var creditor = db.tbl_gnt_creditor.First(x => x.gnt_creditor_id == this.gnt_creditor_id); var fiscalYear = db.tbl_glb_fiscal_year.First(x => x.glb_fiscal_year_id == GlobalVariables.current_fiscal_year_id); var publicCosts = db.tbl_gnt_cost_type.Where ( x => x.gnt_cost_type_glb_fiscal_year_id == fiscalYear.glb_fiscal_year_id && x.gnt_cost_type_is_public == true ).ToList(); if (publicCosts.Count == 0) { throw new Exception("در دوره انتخاب شده هزینه عمومی تعریف نشده است"); } var creditorAccounts = db .tbl_gnt_creditor_account .Where ( x => x.gnt_creditor_account_gnt_creditor_id == creditor.gnt_creditor_id && x.gnt_creditor_account_is_public_cost == true && x.gnt_creditor_account_glb_fiscal_year_id == fiscalYear.glb_fiscal_year_id ) .ToList(); foreach (var creditorAccount in creditorAccounts) { db.tbl_gnt_creditor_account.DeleteObject(creditorAccount); } foreach (tbl_gnt_cost_type cost in publicCosts) { creditor.tbl_gnt_creditor_account.Add(new tbl_gnt_creditor_account() { gnt_creditor_account_title = cost.gnt_cost_type_name, gnt_creditor_account_date = fiscalYear.glb_fiscal_year_start_date.Replace("/", ""), gnt_creditor_account_debt = RoundPrice(cost.gnt_cost_type_price * creditor.gnt_creditor_sum_credit), gnt_creditor_account_credit = 0, gnt_creditor_account_description = "هزینه های عمومی سهامداران", gnt_creditor_account_glb_fiscal_year_id = fiscalYear.glb_fiscal_year_id, gnt_creditor_account_is_public_cost = true }); } db.SaveChanges(); } catch (Exception exception) { while (exception.InnerException != null) { exception = exception.InnerException; } throw new Exception("خطا در اعمال هزینه های عمومی در حساب سهامدر. متن خطا : \n" + exception.Message); } }