private int?CreateNewDocumentNo(SahaamEntities db, long fiscalYearId) { return(db.tbl_acc_document .Where (x => x.acc_document_no != null && x.acc_document_glb_fiscal_year_id == fiscalYearId ) .Max(x => x.acc_document_no) + 1); }
public static tbl_gnt_ownership FindRecord(SahaamEntities dataBase, long id) { var list = dataBase.tbl_gnt_ownership.Where(o => o.gnt_ownership_id == id); if (list.Count() == 0) { return(null); } return(list.First()); }
private static tbl_acc_document_type FindAccDocumentType(SahaamEntities db, string key) { if (db.tbl_acc_document_type.Count() == 0) { throw HelperMethods.CreateException("در جدول نوع سند حسابداری رکوردی وجود ندارد"); } var documentType = db.tbl_acc_document_type.First(); var list = db.tbl_acc_document_type.Where(x => x.acc_document_type_name.Contains(key)).ToList(); if (list.Count > 0) { documentType = list.First(); } return(documentType); }
private long CreateNewDocumentCode(SahaamEntities db, long fiscalYearId) { var list = db.tbl_acc_document .Where (x => x.acc_document_code != null && x.acc_document_code != "" && x.acc_document_glb_fiscal_year_id == fiscalYearId ) .Select(x => x.acc_document_code) .ToList() .Select(x => long.Parse(x)); if (list.Count() == 0) { return(1); } else { return(list.Max() + 1); } }
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(); }
private void CreateNewCode() { SahaamEntities db = DDB.NewContext(); long maxCode; if (db.tbl_gnt_creditor.Count() == 0) { maxCode = 1; } else { maxCode = long.Parse(db.tbl_gnt_creditor.Select(x => x.gnt_creditor_child_code).Max()); } var digitCount = db.tbl_glb_entity_type_option .Where(x => x.glb_entity_type_option_glb_entity_type_id == 12) .First() .glb_entity_type_option_digit_count; newCode = (maxCode + 1).ToString(); GlobalFunctions.PutZeroBeforeCode(newCode, digitCount); }
private void btnUpdateCreditorAccount_Click(object sender, RoutedEventArgs e) { try { if (selectedCreditorsCount == 0) { Messages.ErrorMessage("سهامداران انتخاب نشده اند"); return; } SahaamEntities db = DDB.NewContext(); if (chkSelectAllCreditors.IsChecked == true) { foreach (var creditor in db.tbl_gnt_creditor.ToArray()) { creditor.UpdateAccountForPublicCosts(); } } else { foreach (var oldcreditor in creditorsArticlePackage.ListAfterChange) { oldcreditor.ToEntity().UpdateAccountForPublicCosts(); } } Messages.SuccessMessage(string.Format("اعمال هزینه های عمومی در حساب {0} سهامدر", (selectedCreditorsCount == 1) ? "یک" : selectedCreditorsCount.ToString())); selectedCreditorsCount = 0; lbl_selected_creditors.Content = selectedCreditorsCount; chkSelectAllCreditors.IsChecked = false; creditorsArticlePackage.Clear(); } catch (Exception exception) { Messages.ErrorMessage(exception.CompleteMessages()); } }
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); } }