public Bank() { _accountantEntity = new AccountantEntity() { Value = 0, PrefixCode = "100120", Type = 3, Code="", IsReadOnly = true, Parent = 36 }; }
private void btnSearch_Click(object sender, EventArgs e) { try { _insurance = GetCurrentInsurance(); _from = GetFromDate(); _to = GetToDate(); if (ValidateQuery(_insurance, _from, _to)) { grvItems.DataSource = DataLayer.GetInsuranceReport(_insurance, _from, _to); } } catch (Exception exp) { Logger.Log(exp, "InsuranceReport - Query"); Methods.ShowStandardMsgBox(FormMessageType.Error, "خطا", "در حین گرفتن گزارش خطایی رخ داد."); } }
private void AddNode(AccountantEntity accountantEntity) { RadTreeNode parentNode = GetParentNode(accountantEntity, null); if (parentNode == null) { Methods.ShowStandardMsgBox (FormMessageType.Error, RscError.ValidationTitle, "دسته مشخص شده وجود ندارد. لطفا در وارد نمودن کد پدر دقت بفرمایید."); return; } AccountantEntity parentEntity = parentNode.Tag as AccountantEntity; if (accountantEntity.Type - 1 != parentEntity.Type) { Methods.ShowStandardMsgBox (FormMessageType.Error, RscError.ValidationTitle, "در سطح پدر، دسته مشخص شده وجود ندارد. لطفا در وارد نمودن کد پدر دقت بفرمایید."); return; } if (accountantEntity.Type == 3 && (parentEntity.Id == 36 || parentEntity.Id == 37 || parentEntity.Id == 39 || parentEntity.Id == 51 || parentEntity.Id == 53)) { Methods.ShowStandardMsgBox (FormMessageType.Error, RscError.ValidationTitle, "در دسته مشخص شده نمی توان حسابی اضافه نمود. سیستم به طور خودکار با این دسته کار می کند."); return; } RadTreeNode childNode = new RadTreeNode(CreateNodeName(accountantEntity)); childNode.Tag = accountantEntity; accountantEntity.Parent = parentEntity.Id; if (accountantEntity.Type == 3) accountantEntity.Value = 0; else accountantEntity.Value = null; parentNode.Nodes.Add(childNode); }
internal static bool HasSameEntity(AccountantEntity accountantEntity) { EntityModelContainer context = accountantEntity.Context; string code = accountantEntity.AccountantCode; if (context.ObjectStateManager.GetObjectStateEntries ((EntityState.Added | EntityState.Modified | EntityState.Unchanged)) .Select(e => e.Entity).OfType<AccountantEntity>() .Any(ae => (ae.PrefixCode + ae.Code) == code && (ae != accountantEntity))) return true; return false; }
public static void Insert(AccountantEntity entity) { EntityModelContainer context = GetContext(); if (entity.EntityState != EntityState.Added) context.AccountantEntities.AddObject(entity); }
public Bank(AccountantEntity accountantEntity) { _accountantEntity = accountantEntity; }
private void btnSearch_Click(object sender, EventArgs e) { try { _accountant = GetCurrentAccountant(); _from = GetFromDate(); _to = GetToDate(); if (ValidateQuery(_accountant, _from, _to)) { turnOverReportCollection = DataLayer.GetTurnOverReport(_accountant, _from, _to); grvItems.DataSource = turnOverReportCollection.Items; if (turnOverReportCollection.Items.Length > 0) { lblCredit.Text = string.Format("{0:0,0 ریال }", turnOverReportCollection.CreditSum); lblDebit.Text = string.Format("{0:0,0 ریال }", turnOverReportCollection.DebitSum); lblRemaining.Text = string.Format("{0:0,0 ریال }", turnOverReportCollection.Remaining); } else { Methods.ShowStandardMsgBox(FormMessageType.Error, "خطا", "موردی یافت نشد."); lblCredit.Text = string.Format("{0:0,0 ریال }", 0); lblDebit.Text = string.Format("{0:0,0 ریال }", 0); lblRemaining.Text = string.Format("{0:0,0 ریال }", 0); } } } catch (Exception exp) { Logger.Log(exp, "TurnOverReport - Query"); Methods.ShowStandardMsgBox(FormMessageType.Error, "خطا", "در حین گرفتن گزارش خطایی رخ داد."); } }
public static object GetInsuranceReport(AccountantEntity insurance, DateTime from, DateTime to) { EntityModelContainer context = GetContext(); VisitServiceInsurance[] visitReport = context.VisitServiceInsurances.Include("VisitService.Visit").Where( i => i.InsuranceDef.Insurance.AccountantEntityId==insurance.Id && i.VisitService.Visit.FromTime >= from && i.VisitService.Visit.FromTime <= to).ToArray(); List<InsuranceReport> lstReport = visitReport.Select(t => new InsuranceReport() { Bedehkari = t.Fee, Date = t.VisitService.Visit.Date }).ToList(); ChequeReception[] receptionReport = context.ChequeReceptions.Where(c => c.PayerId == insurance.Id && c.DueDate >= from && c.DueDate <= to).ToArray(); lstReport.AddRange(receptionReport.Select(t => new InsuranceReport() { Bestankari = t.Value, Date = t.DueDate, PageNumber = t.ReceptionDocument.Serial })); return lstReport.ToArray(); }
public static TurnOverReportCollection GetTurnOverReportSpecial(AccountantEntity accountEntity, DateTime from, DateTime to) { EntityModelContainer context = GetContext(); TurnOverReportCollection result = new TurnOverReportCollection(); //Cheque Payments Pay var queryChequePaymentPay = context.ChequePayments.Where( i => i.PayerId == accountEntity.Id && i.PayDate >= from && i.PayDate <= to && i.Status == (int)ChequeStatus.Unkown ); foreach (var item in queryChequePaymentPay) { result.Add(new TurnOverReportItem() { PageNumber = item.PaymentDocument.DocumentSerial.ToString(), Date = item.PayDate, PageTitle = "بابت شماره برگه " + item.PaymentDocument.DocumentSerial + "به خاطر پرداخت چک", PageDescription = item.Description, Credit = 0, Debit = item.Value }); } return result; }
public static TurnOverReportItem[] GetTurnOverMoneyReception(AccountantEntity accountEntity, DateTime from, DateTime to) { EntityModelContainer context = GetContext(); List<TurnOverReportItem> result = new List<TurnOverReportItem>(); //Money Receptions Pay var queryMoneyReceptionPay = context.MoneyReceptions.Where( i => i.ReceptionDocument.PayerId == accountEntity.Id && i.Date >= from && i.Date <= to ); foreach (var item in queryMoneyReceptionPay) { result.Add(new TurnOverReportItem() { PageNumber = item.ReceptionDocument.DocumentSerial.ToString(), Date = item.Date, PageTitle = String.Format("بابت شماره برگه {0} به خاطر {1}", item.ReceptionDocument.DocumentSerial, Constants.GetDocumentTypeTitle((DocumentType)item.ReceptionDocument.Type)), PageDescription = item.Description, Credit =item.Value, Debit = 0 }); } //Money Receptions Receive var queryMoneyReceptionReceive = context.MoneyReceptions.Where( i => i.RecieverId == accountEntity.Id && i.Date >= from && i.Date <= to ); foreach (var item in queryMoneyReceptionReceive) { result.Add(new TurnOverReportItem() { PageNumber = item.ReceptionDocument.DocumentSerial.ToString(), Date = item.Date, PageTitle = String.Format("بابت شماره برگه {0} به خاطر {1}", item.ReceptionDocument.DocumentSerial, Constants.GetDocumentTypeTitle((DocumentType)item.ReceptionDocument.Type)), PageDescription = item.Description, Credit = 0, Debit = item.Value }); } return result.ToArray(); }
private void AddDocumentToList(AccountantEntity accountantEntity) { DataLayer.Insert(accountantEntity); AddNode(accountantEntity); }
private RadTreeNode GetParentNode(AccountantEntity accountantEntity, RadTreeNode parentNode) { RadTreeNode[] nodes; if (parentNode == null) nodes = trvAccounts.Nodes.ToArray(); else nodes = parentNode.Nodes.ToArray(); for (int i = 0; i < nodes.Length; i++) { AccountantEntity entity = nodes[i].Tag as AccountantEntity; string prefix = ""; if (entity.Type == 0) prefix = entity.Code; else prefix = entity.AccountantCode; if (accountantEntity.AccountantCode.StartsWith(prefix) && accountantEntity.Type > entity.Type) return this.GetParentNode(accountantEntity, nodes[i]); } return parentNode; }
private void CreateTree(AccountantEntity[] entities, AccountantEntity entityParent, RadTreeNode nodeParent) { AccountantEntity[] children; if (entityParent == null) children = entities.Where(e => e.Type == 0).ToArray(); else children = entities.Where(e => e.Parent.HasValue && e.Parent.Value == entityParent.Id).ToArray(); for (int i = 0; i < children.Length; i++) { RadTreeNode childNode = new RadTreeNode(this.CreateNodeName(children[i])); if (nodeParent != null) { nodeParent.Nodes.Add(childNode); } else { trvAccounts.Nodes.Add(childNode); } childNode.Tag = children[i]; if (children[i].Type < 3) this.CreateTree(entities, children[i], childNode); } }
private string CreateNodeName(AccountantEntity accountantEntity) { string text = string.Format("{0} ({1})", accountantEntity.Name, accountantEntity.AccountantCode); return text; }
private void ClearPage() { AccountantEntity entity = new AccountantEntity(); entity.Context = DataLayer.GetContext(); srcAccountantEntity.DataSource = entity; btnNew.Enabled = false; btnAdd.Enabled = true; }
public static ChequePage GetChequePage(AccountantEntity bank, int chequePageSerial) { EntityModelContainer context = GetContext(); string serial = chequePageSerial.ToString(); ChequePage chequePage = context.ChequePages.Include("ChequeBunch").SingleOrDefault(cp => cp.ChequeBunch.BankId == bank.Id && cp.Serial == serial); return chequePage; }
public static DoctorSalaryReportCollection GetDoctorSalaryReport(AccountantEntity accountEntity, DateTime from, DateTime to) { EntityModelContainer context = GetContext(); DoctorSalaryReportCollection result = new DoctorSalaryReportCollection(); Employee employee = context.Employees.Where(p => p.AccountantEntityId == accountEntity.Id).First(); double monthlySalary = employee.MonthlySalary; double incomingPercentage = employee.IncomePercentage; var query = context.VisitServices.Where(p => p.Visit.EmployeeId == employee.Id && p.Visit.FromTime >= from && p.Visit.ToTime <= to); int loopCounter = 1; foreach (var item in query) { result.Add(new DoctorSalaryReportItem() { RowNumber = loopCounter++, VisitDate = item.Visit.FromTime, PatientName = item.Visit.Patient.ToString(), ServiceTooth = item.ToothDescription, FinalCost = item.FinalCost, Discount = item.Discount }); } result.TotalSalary = ((double)incomingPercentage * result.FinalCostSum); result.TotalSalary += monthlySalary; //result.TotalSalary = ((double)incomingPercentage * result.FinalCostSum); //result.TotalSalary += (monthlySalary * 12) * ((double)(to - from).TotalDays / 365); return result; }
/// <summary> /// Deprecated Method for adding a new object to the AccountantEntities EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToAccountantEntities(AccountantEntity accountantEntity) { base.AddObject("AccountantEntities", accountantEntity); }
public static TurnOverReportCollection GetTurnOverReport(AccountantEntity accountEntity, DateTime from, DateTime to) { if (accountEntity.Id == 67) return GetTurnOverReportSpecial(accountEntity, from, to); EntityModelContainer context = GetContext(); TurnOverReportCollection result = new TurnOverReportCollection(); TurnOverReportItem[] chequePayment = GetTurnOverChequePayment(accountEntity, from, to); foreach (var item in chequePayment) result.Add(item); TurnOverReportItem[] moneyPayment = GetTurnOverMoneyPayment(accountEntity, from, to); foreach (var item in moneyPayment) result.Add(item); TurnOverReportItem[] chequeReception = GetTurnOverChequeReception(accountEntity, from, to); foreach (var item in chequeReception) result.Add(item); TurnOverReportItem[] moneyReception = GetTurnOverMoneyReception(accountEntity, from, to); foreach (var item in moneyReception) result.Add(item); TurnOverReportItem[] visit = GetTurnOverVisit(accountEntity, from, to); foreach (var item in visit) result.Add(item); TurnOverReportItem[] visitInsurance = GetTurnOverVisitInsurance(accountEntity, from, to); foreach (var item in visitInsurance) result.Add(item); return result; }
/// <summary> /// Create a new AccountantEntity object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="type">Initial value of the Type property.</param> /// <param name="code">Initial value of the Code property.</param> /// <param name="isReadOnly">Initial value of the IsReadOnly property.</param> public static AccountantEntity CreateAccountantEntity(global::System.Int32 id, global::System.String name, global::System.Int32 type, global::System.String code, global::System.Boolean isReadOnly) { AccountantEntity accountantEntity = new AccountantEntity(); accountantEntity.Id = id; accountantEntity.Name = name; accountantEntity.Type = type; accountantEntity.Code = code; accountantEntity.IsReadOnly = isReadOnly; return accountantEntity; }
public static TurnOverReportItem[] GetTurnOverVisit(AccountantEntity accountEntity, DateTime from, DateTime to) { EntityModelContainer context = GetContext(); List<TurnOverReportItem> result = new List<TurnOverReportItem>(); //Visit Service var queryVisit = context.VisitServices.Where( i => i.Visit.Patient.AccountantEntityId == accountEntity.Id && i.Visit.FromTime >= from && i.Visit.ToTime <= to ); foreach (var item in queryVisit) { result.Add(new TurnOverReportItem() { PageNumber = "ویزیت", Date = item.Visit.FromTime, PageTitle = String.Format("در تاریخ {0} در ساعت {1} توسط دکتر {2} بابت خدمت به {3}", item.Visit.PersianDate, item.Visit.FromTime.ToShortTimeString(), item.Visit.Doctor.Name, item.Visit.Patient.PatientName), PageDescription = "", Credit = 0, Debit = item.FinalCost }); } return result.ToArray(); }
public static bool Validate(AccountantEntity accountantEntity) { if (accountantEntity.Type == -1) { Methods.ShowStandardMsgBox (FormMessageType.Error, RscError.ValidationTitle, "لطفا نوع حساب را مشخص بفرمایید."); return false; } if (accountantEntity.Id == 0 && (accountantEntity.Type == 0 || accountantEntity.Type == 1)) { Methods.ShowStandardMsgBox (FormMessageType.Error, RscError.ValidationTitle, "تنها می توانید حساب های معین و تفضیلی مشخص بفرمایید."); return false; } if (string.IsNullOrEmpty(accountantEntity.Name)) { Methods.ShowStandardMsgBox (FormMessageType.Error, RscError.ValidationTitle, "لطفا نام حساب را مشخص بفرمایید."); return false; } if (accountantEntity.Type != 0 && string.IsNullOrEmpty(accountantEntity.PrefixCode)) { Methods.ShowStandardMsgBox (FormMessageType.Error, RscError.ValidationTitle, "لطفا کد پدر را مشخص بفرمایید."); return false; } if (string.IsNullOrEmpty(accountantEntity.Code)) { Methods.ShowStandardMsgBox (FormMessageType.Error, RscError.ValidationTitle, "لطفا کد جزیی را مشخص بفرمایید."); return false; } if (DataLayer.HasSameEntity(accountantEntity)) { Methods.ShowStandardMsgBox (FormMessageType.Error, RscError.ValidationTitle, "قبلا موجودیتی با این کد ساخته شده است. در وارد نمودن کد دقت کنید."); return false; } return true; }
public static ReceptionDocument[] GetPatientPayments(bool loadFromDb, AccountantEntity patient) { EntityModelContainer context = GetContext(); if (loadFromDb) return context.ReceptionDocuments.Where(rd => rd.PayerId == patient.Id).ToArray(); else return context.ObjectStateManager.GetObjectStateEntries (EntityState.Added | EntityState.Modified | EntityState.Unchanged).Select(e => e.Entity).OfType<ReceptionDocument>().Where(x => x.PayerId == patient.Id).ToArray(); }
private void btnSearch_Click(object sender, EventArgs e) { try { _accountant = GetCurrentAccountantEmployee(); _from = GetFromDate(); _to = GetToDate(); if (ValidateQuery(_accountant, _from, _to)) { doctorSalaryReportCollection = DataLayer.GetDoctorSalaryReport(_accountant, _from, _to); grvItems.DataSource = doctorSalaryReportCollection.Items; if (doctorSalaryReportCollection.Items.Length > 0) { lblDiscount.Text = string.Format("{0:0,0} ریال", doctorSalaryReportCollection.DiscountSum); lblFinalCost.Text = string.Format("{0:0,0} ریال", doctorSalaryReportCollection.FinalCostSum); lblTotalSalary.Text = string.Format("{0:0,0} ریال", doctorSalaryReportCollection.TotalSalary); } else { Methods.ShowStandardMsgBox(FormMessageType.Error, "خطا", "موردی یافت نشد."); lblDiscount.Text = "0"; lblFinalCost.Text = "0"; lblTotalSalary.Text = "0"; } } } catch (Exception exp) { Logger.Log(exp, "DoctorSalaryReport - Query"); Methods.ShowStandardMsgBox(FormMessageType.Error, "خطا", "در حین گرفتن گزارش خطایی رخ داد."); } }
private bool ValidateQuery(AccountantEntity accountant, DateTime from, DateTime to) { if (accountant == null) { Methods.ShowStandardMsgBox(FormMessageType.Error, "خطا", "لطفا نام حساب را مشخص بفرمایید."); return false; } return true; }
private void SetTxtPayerValue(AccountantEntity accountantEntity) { if (accountantEntity == null) txtPayerValue.Text = ""; else txtPayerValue.Text = string.Format("{0:0,0} ریال", accountantEntity.Value); }