سلام استاد وقتتون بخیر خسته نباشید.
بنده اولین پروژه عملی دوره رو انجام دادم که قطعا باز هم ریفکتور میشه . ممنون میشم از شما که نظر بدید در چه سطحی هست تمیزی خطم و خود پروژه ای که زدم . ممنون میشم اگه انتقادی هست در این رابطه لطف کنید بگید که بتونم به لول بهتری برسم.
در این پروژه بنده سعی کردم چینش بخش های مختلف جوری باشه که ارتباطشون تا جایی که میشه مشخص باشه.
سپاس از شما که با آموزش های عالیتون مارو در این مسیر راهنمایی میکنید.

فرم اصلی

لیست بیماران

پذیرش بیمار

پرداخت هزینه خدمت. فرق پرداخت کامل هزینه و پرداخت هزینه این است که وقتی کاربر پرداخت کامل هزینه رو میزنه هزینه کامل خدمتی که در تکست باکس بالا هست روی تکست باکس پرداخت مبلغ نشون داده میشه که دیگه نیاز نیست کاربر اون قیمت رو تایپ کنه
با یک کلیک هزینه کامل خدمت روی تکست باکس می افته و پرداخت هزینه رو وقتی بزنه هزینه ثبت میشه . ولی پرداخت هایی که کامل نیست، به این معنا که بیمار بدهکار به کلینیک میشه باید تایپ بشه میزان واریزی مبلغ.

در این قسمت کاربر بیمار هزینه خودش رو میتونه به طور کامل و یا مقداری از اون رو پرداخت کنه

لیست پرسنل کارمند در کلینیک هست

افزودن پرسنل به کلینیک

لیست سیاه بیمارن

تنظیمات کلینیک

افزودن تخصص برای دکتر های کلینیک

تنظیمات مالی برای خدمت های کلینیک

افزودن خدمت جدید به کلینیک

درآمد های کلینیک

لیست بیمارانی که بدهکار هستند

تسویه بیماران بدهکار

بیمارانی که ترخیص شده اند

public class Patient
{
[Key]
public int PatientId { get; set; }
[MaxLength(70)]
public string Name { get; set; }
[MaxLength(70)]
public string Family { get; set; }
[MaxLength(11)]
public string NationalCode { get; set; }
[MaxLength(70)]
public string Email { get; set; }
public bool Gender { get; set; }
[Range(1, 130)]
public int Age { get; set; }
[MaxLength(11)]
public string? Mobile { get; set; }
public bool IsBlacked { get; set; } = false;
//تاریخ ویرایش اطلاعات بیمار
public DateTime? PatientInformationEditDate { get; set; }
public List<AdmittedPatients>? AdmittedPatients { get; set; }
}
}
public class Employee
{
[Key]
public int PersonId { get; set; }
[MaxLength(50)]
public string Name { get; set; }
[MaxLength(50)]
public string Family { get; set; }
public bool IsDoctor { get; set; }
public bool IsActive { get; set; } = true;
[MaxLength(30)]
public string? MedicalRegistrationCode { get; set; }
//تخصص دکتر
public int? SpecializationId { get; set; }
public List<AdmittedPatients>? AdmittedPatients { get; set; }
[ForeignKey("SpecializationId")]
public DoctorSpecialization? DoctorSpecialization { get; set; }
}public class DoctorSpecialization
{
[Key]
public int SpecializationId { get; set; }
[MaxLength(50)]
public string SpecializationName { get; set; }
public List<Employee>? Employee { get; set; }
}public class AdmittedPatients
{
[Key]
public int AdmittedId { get; set; }
public int PatientId { get; set; }
public int EmployeeId { get; set; }
public int ServiceId { get; set; }
public bool IsDischarged { get; set; } = false;
public DateTime AdmittedDate { get; set; }
[ForeignKey("PatientId")]
public Patient? Patient { get; set; }
[ForeignKey("EmployeeId")]
public Employee? Employee { get; set; }
[ForeignKey("ServiceId")]
public Service? Service { get; set; }
public List<PaymentManage>? PaymentManage { get; set; }
} public class PaymentManage
{
[Key]
public int PayId { get; set; }
public bool IsPay { get; set; } = false;
public int ServiceId { get; set; }
public int AdmittedId { get; set; }
public int ServicePrice { get; set; }
public int Debt { get; set; }
public DateTime PayDate { get; set; }
[ForeignKey("AdmittedId")]
public AdmittedPatients? AdmittedPatients { get; set; }
}public class Service
{
[Key]
public int ServiceId { get; set; }
[MaxLength(50)]
public string ServiceName { get; set; }
public int ServicePrice { get; set; }
public DateTime UpdatePrice { get; set; }
public List<AdmittedPatients>? AdmittedPatients { get; set; }
}کلاس های Utiliti
namespace Utiliti.Convertor
{
public static class DateConvert
{
public static string ToShamsi(this DateTime date)
{
PersianCalendar pc = new PersianCalendar();
var result = pc.GetYear(date) + "/" + pc.GetMonth(date) + "/" + pc.GetDayOfMonth(date);
return result;
}
}
}
namespace Utiliti.CustomType
{
public class PatientList
{
public int PatientId { get; set; }
public string FullName { get; set; }
public string NationalCode { get; set; }
public bool Gender { get; set; }
public int Age { get; set; }
public bool PayStatus { get; set; }
public string ServiceName { get; set; }
public string DoctorName { get; set; }
public DateTime AddmissoinDate { get; set; }
public DateTime PatientInformationEditDate { get; set; } = DateTime.Now;
}
}
public class PersonList
{
public int personId { get; set; }
public string FullName { get; set; }
public string Status { get; set; }
public string PersonType { get; set; }
public string? SpecializationName { get; set; }
public string? MedicalRegistrationCode { get; set; }
}namespace Utiliti.Separator
{
public static class DigitSeparator
{
public static string ToThereDigit(this int seprator)
{
string result = seprator.ToString("N0");
return result;
}
public static string ToThereDigit(this long seprator)
{
string result = seprator.ToString("N0");
return result;
}
}
}Context
public class ClinicCenter_Db_Context:DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer("Data Source=DESKTOP-LAER236\\SQL2022;Initial Catalog=MedicineClinicCenter_Db;Integrated Security=True;TrustServerCertificate=True");
}
#region DbSets
public DbSet<Patient> Patients { get; set; }
public DbSet<Employee> Employees { get; set; }
public DbSet<AdmittedPatients> AdmittedPatients { get; set; }
public DbSet<Service> Services { get; set; }
public DbSet<DoctorSpecialization> DoctorSpecializations { get; set; }
public DbSet<PaymentManage> paymentManages { get; set; }
#endregion
}Code Forms
using ClinicCenter.ClinicSetting;
using ClinicCenter.Doctors;
using ClinicCenter.Patients;
using DataLayer.Context;
using Microsoft.EntityFrameworkCore;
using Utiliti.Convertor;
namespace ClinicCenter;
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
private void frmMain_Load(object sender, EventArgs e)
{
lblDate.Text = DateTime.Now.ToShamsi();
lblTime.Text = DateTime.Now.ToLongTimeString();
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
lblAdmittedCount.Text = _Context.AdmittedPatients.AsNoTracking().Where(a => a.IsDischarged == false &amp;amp;&amp;amp; a.Patient.IsBlacked == false).Count().ToString();
lblDischargPatientCount.Text = _Context.AdmittedPatients.AsNoTracking().Where(a => a.IsDischarged == true).Count().ToString();
lblDoctorsCount.Text = _Context.Employees.AsNoTracking().Where(e => e.IsDoctor == true).Count().ToString();
lblPatientDebtCount.Text = _Context.paymentManages.AsNoTracking().Where(p => p.IsPay == false).Count().ToString();
lblServicesCount.Text = _Context.Services.Count().ToString();
lblBlockPatientCount.Text = _Context.Patients.AsNoTracking().Where(p => p.IsBlacked == true).Count().ToString();
}
}
private void lblDate_Click(object sender, EventArgs e)
{
}
private void lblTime_Click(object sender, EventArgs e)
{
}
private void timerSystem_Tick(object sender, EventArgs e)
{
lblDate.Text = DateTime.Now.ToShamsi();
lblTime.Text = DateTime.Now.ToLongTimeString();
}
private void btnPatientList_Click(object sender, EventArgs e)
{
frmListPatients listPatients = new frmListPatients();
listPatients.ShowDialog();
}
private void btnClinicDoctorsList_Click(object sender, EventArgs e)
{
frmDoctorList doctorList = new frmDoctorList();
doctorList.ShowDialog();
}
private void btnSettings_Click(object sender, EventArgs e)
{
frmClinicSetting clinicSetting = new frmClinicSetting();
clinicSetting.ShowDialog();
}
private void btnBlacklist_Click(object sender, EventArgs e)
{
frmBlackListPatient blackListPatient = new frmBlackListPatient();
blackListPatient.ShowDialog();
}
private void btnDischargedList_Click(object sender, EventArgs e)
{
frmDischargedList dischargedList = new frmDischargedList();
dischargedList.ShowDialog();
}
private void btnIndebtedPatient_Click(object sender, EventArgs e)
{
frmIndebtedPatient indebtedPatient = new frmIndebtedPatient();
indebtedPatient.ShowDialog();
}
}
using DataLayer.Context;
using Microsoft.EntityFrameworkCore;
using persian_MsBox;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Utiliti.Convertor;
using Utiliti.CustomType;
namespace ClinicCenter.Patients
{
public partial class frmListPatients : Form
{
List<PatientList> list = new List<PatientList>();
public frmListPatients()
{
InitializeComponent();
}
private void frmListPatients_Load(object sender, EventArgs e)
{
tmLoadingTime.Enabled = true;
}
private void btnAddPatientInBlackList_Click(object sender, EventArgs e)
{
if (dgvPatientsList.CurrentRow != null)
{
string id = dgvPatientsList.CurrentRow.Cells[0].Value.ToString();
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
int patientId = Convert.ToInt32(id);
var patient = _Context.Patients.Find(patientId);
patient.IsBlacked = true;
_Context.Patients.Update(patient);
_Context.SaveChanges();
}
BindDgvPatient();
}
}
private void btnPatientAdmission_Click(object sender, EventArgs e)
{
frmAddOrEditePatient admission = new frmAddOrEditePatient();
var dialog = admission.ShowDialog();
if (dialog == DialogResult.Cancel)
{
BindDgvPatient();
}
}
private void btnEditPatient_Click(object sender, EventArgs e)
{
if (dgvPatientsList.CurrentRow != null)
{
string id = dgvPatientsList.CurrentRow.Cells[0].Value.ToString();
int patientId = Convert.ToInt32(id);
frmAddOrEditePatient frmAddOrEdite = new frmAddOrEditePatient(patientId);
var dialog = frmAddOrEdite.ShowDialog();
if (dialog == DialogResult.OK)
{
BindDgvPatient();
}
}
}
private void btnDeletePatient_Click(object sender, EventArgs e)
{
if (dgvPatientsList.CurrentRow != null)
{
string id = dgvPatientsList.CurrentRow.Cells[0].Value.ToString();
string fullName = dgvPatientsList.CurrentRow.Cells[1].Value.ToString();
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
int patientId = Convert.ToInt32(id);
var patient = _Context.Patients.Include(p => p.AdmittedPatients).Single(s => s.PatientId == patientId);
_Context.Remove(patient);
var message = PersianMsBox.Show($"درصورت حذف {fullName} تمام اطلاعات ایشان از سیستم حذف خواهد شد آیا اطمینان دارید؟", "هشدار", PersianMsbox_button.YesNo, PersianMsBox_Icons.Warning);
if (message == DialogResult.Yes)
{
var payment = _Context.AdmittedPatients.Where(p => p.PatientId == patientId).Include(s => s.PaymentManage).Single();
_Context.Remove(payment);
_Context.SaveChanges();
}
}
BindDgvPatient();
}
}
private void txtSearch_TextChanged(object sender, EventArgs e)
{
dgvPatientsList.Rows.Clear();
var data = list.Where(l => l.FullName.Contains(txtSearch.Text) ||
l.NationalCode.Contains(txtSearch.Text) ||
l.ServiceName.Contains(txtSearch.Text) ||
l.DoctorName.Contains(txtSearch.Text)
).ToList();
foreach (var item in data)
{
dgvPatientsList.Rows.Add(item.PatientId
, item.FullName
, item.NationalCode
, item.Age
, item.Gender ? "مرد" : "زن"
, item.ServiceName
, item.DoctorName
, item.AddmissoinDate.ToShamsi());
}
}
private void tmLoadingTime_Tick(object sender, EventArgs e)
{
tmLoadingTime.Enabled = false;
BindDgvPatient();
}
private void btnUpdateList_Click(object sender, EventArgs e)
{
BindDgvPatient();
}
private void treeSearchPatient_AfterSelect(object sender, TreeViewEventArgs e)
{
if (e.Node.Level == 1)
{
string nodeText = e.Node.Text;
TreeSortData(nodeText);
}
}
#region Bind Data Dgv Patient Addmission
void BindDgvPatient()
{
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
dgvPatientsList.Rows.Clear();
list = _Context.AdmittedPatients.AsNoTracking().Where(p => p.IsDischarged == false &amp;amp;&amp;amp; p.Patient.IsBlacked == false).Select(p => new PatientList
{
PatientId = p.PatientId,
FullName = p.Patient.Name + " " + p.Patient.Family,
NationalCode = p.Patient.NationalCode,
PayStatus= p.PaymentManage.Select(p=>p.IsPay).Single(),
Age = p.Patient.Age,
Gender = p.Patient.Gender,
ServiceName = p.Patient.AdmittedPatients.Select(s => s.Service.ServiceName).SingleOrDefault(),
DoctorName = p.Patient.AdmittedPatients.Select(s => s.Employee.Name + " " + s.Employee.Family).SingleOrDefault(),
AddmissoinDate = p.Patient.AdmittedPatients.Select(s => s.AdmittedDate).SingleOrDefault(),
}).ToList();
foreach (var item in list)
{
dgvPatientsList.Rows.Add(item.PatientId
, item.FullName
, item.NationalCode
,item.PayStatus?"پرداخت شده":"بدهکار"
, item.Age
, item.Gender ? "مرد" : "زن"
, item.ServiceName
, item.DoctorName
, item.AddmissoinDate.ToShamsi());
}
}
}
#endregion
#region Filter Dgv With Tree View
void TreeSortData(string nodeText)
{
dgvPatientsList.Rows.Clear();
switch (nodeText)
{
case "بزرگترین به کوچکترین":
{
list = list.OrderByDescending(l => l.Age).ToList();
break;
}
case "کوچکترین به بزرگترین":
{
list = list.OrderBy(l => l.Age).ToList();
break;
}
case "مرد":
{
list = list.OrderByDescending(l => l.Gender == true).ToList();
break;
}
case "زن":
{
list = list.OrderByDescending(l => l.Gender == false).ToList();
break;
}
case "جدید به قدیم":
{
list = list.OrderByDescending(l => l.AddmissoinDate.ToShamsi()).ToList();
break;
}
case "قدیم به جدید":
{
list = list.OrderBy(l => l.AddmissoinDate.ToShamsi()).ToList();
break;
}
default:
{
list = list.ToList();
break;
}
}
foreach (var item in list)
{
dgvPatientsList.Rows.Add(item.PatientId
, item.FullName
, item.NationalCode
, item.Age
, item.Gender ? "مرد" : "زن"
, item.ServiceName
, item.DoctorName
, item.AddmissoinDate.ToShamsi());
}
}
#endregion
private void btnNonFilter_Click(object sender, EventArgs e)
{
BindDgvPatient();
}
private void btnDischarged_Click(object sender, EventArgs e)
{
if (dgvPatientsList.CurrentRow != null)
{
string id = dgvPatientsList.CurrentRow.Cells[0].Value.ToString();
string fullName = dgvPatientsList.CurrentRow.Cells[1].Value.ToString();
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
int patientId = Convert.ToInt32(id);
var data = _Context.AdmittedPatients.Single(s => s.PatientId == patientId);
data.IsDischarged = true;
var message = PersianMsBox.Show($"آیا از ترخیص {fullName} اطمینان دارید؟", "هشدار", PersianMsbox_button.YesNo, PersianMsBox_Icons.Warning);
if (message == DialogResult.Yes)
{
_Context.AdmittedPatients.Update(data);
_Context.SaveChanges();
BindDgvPatient();
}
}
BindDgvPatient();
}
}
}
}
using ClinicCenter.PaymentPage;
using DataLayer.Context;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ClinicCenter.Patients
{
public partial class frmIndebtedPatient : Form
{
int _Servicerice;
public frmIndebtedPatient()
{
InitializeComponent();
}
private void frmIndebtedPatient_Load(object sender, EventArgs e)
{
BindDgvIndebtedPatient();
}
private void btnSettlement_Click(object sender, EventArgs e)
{
if (dgvIndebtedPatient.CurrentRow != null)
{
string id = dgvIndebtedPatient.CurrentRow.Cells[0].Value.ToString();
int payId = Convert.ToInt32(id);
frmPay frmPay = new frmPay(payId);
var dialog = frmPay.ShowDialog();
if (dialog == DialogResult.OK)
{
BindDgvIndebtedPatient();
}
}
}
private void btnHelp_Click(object sender, EventArgs e)
{
}
private void btnCancele_Click(object sender, EventArgs e)
{
this.Close();
}
#region Bind Dgv IndebtedPatient List
void BindDgvIndebtedPatient()
{
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
dgvIndebtedPatient.Rows.Clear();
var data = _Context.paymentManages.Where(p => p.IsPay == false).Select(a => new
{
a.PayId,
a.AdmittedPatients.Patient.PatientId,
FullName = a.AdmittedPatients.Patient.Name + " " + a.AdmittedPatients.Patient.Family,
NationalCode = a.AdmittedPatients.Patient.NationalCode,
ServiceName = a.AdmittedPatients.Service.ServiceName,
ServicePrice = a.ServicePrice,
Pay = a.ServicePrice - a.Debt,
Debt = a.Debt
}).ToList();
foreach (var item in data)
{
dgvIndebtedPatient.Rows.Add(item.PayId, item.PatientId, item.FullName, item.NationalCode, item.ServiceName, item.ServicePrice, item.Pay, item.Debt);
}
}
}
#endregion
}
}
using DataLayer.Context;
using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Protocols;
using persian_MsBox;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Utiliti.Convertor;
namespace ClinicCenter.Patients
{
public partial class frmDischargedList : Form
{
public frmDischargedList()
{
InitializeComponent();
}
private void btnDelete_Click(object sender, EventArgs e)
{
if (DgvDischargedPatient.CurrentRow != null)
{
string id = DgvDischargedPatient.CurrentRow.Cells[0].Value.ToString();
string fullName = DgvDischargedPatient.CurrentRow.Cells[1].Value.ToString();
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
int patientId = Convert.ToInt32(id);
var message = PersianMsBox.Show($"درصورت حذف {fullName} تمام اطلاعات ایشان از سیستم حذف خواهد شد آیا اطمینان دارید؟", "هشدار", PersianMsbox_button.YesNo, PersianMsBox_Icons.Warning);
if (message == DialogResult.Yes)
{
var data = _Context.Patients.Include(p => p.AdmittedPatients).Single(a => a.PatientId == patientId);
_Context.Remove(data);
_Context.SaveChanges();
}
}
BindDgvDischarged();
}
}
private void tmLoading_Tick(object sender, EventArgs e)
{
tmLoading.Enabled = false;
BindDgvDischarged();
}
#region Bind DGV Discharged Patients
void BindDgvDischarged()
{
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
DgvDischargedPatient.Rows.Clear();
var data = _Context.AdmittedPatients.Where(a => a.IsDischarged == true).Select(s => new
{
s.Patient.PatientId,
FullName = s.Patient.Name + " " + s.Patient.Family,
s.Patient.NationalCode,
s.Patient.Gender,
s.Service.ServiceName,
s.AdmittedDate
}).ToList();
foreach (var item in data)
{
DgvDischargedPatient.Rows.Add(item.PatientId
, item.FullName,
item.NationalCode,
item.Gender ? "مرد" : "زن",
item.ServiceName,
item.AdmittedDate.ToShamsi());
}
}
}
#endregion
}
}
using DataLayer.Context;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ClinicCenter.Patients
{
public partial class frmBlackListPatient : Form
{
public frmBlackListPatient()
{
InitializeComponent();
}
private void frmBlackListPatient_Load(object sender, EventArgs e)
{
}
private void btnUnBlock_Click(object sender, EventArgs e)
{
if (dgvBlackList.CurrentRow != null)
{
string id = dgvBlackList.CurrentRow.Cells[0].Value.ToString();
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
int patientId = Convert.ToInt32(id);
var patient = _Context.Patients.Find(patientId);
patient.IsBlacked = false;
_Context.Update(patient);
_Context.SaveChanges();
}
BindDgvBlackList();
}
this.DialogResult = DialogResult.OK;
}
private void btnCancele_Click(object sender, EventArgs e)
{
this.Close();
}
private void tmLoading_Tick(object sender, EventArgs e)
{
tmLoading.Enabled = false;
BindDgvBlackList();
}
#region Bind Dgv BlockPatient
void BindDgvBlackList()
{
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
dgvBlackList.Rows.Clear();
var data = _Context.Patients.Where(p => p.IsBlacked == true).Select(s => new
{
s.PatientId,
FullName = s.Name + " " + s.Family,
s.NationalCode
});
foreach (var item in data)
{
dgvBlackList.Rows.Add(item.PatientId, item.FullName, item.NationalCode);
}
}
}
#endregion
}
}
using ClinicCenter.Model;
using ClinicCenter.PaymentPage;
using DataLayer.Context;
using DataLayer.Model;
using Microsoft.EntityFrameworkCore;
using persian_MsBox;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ClinicCenter.Patients
{
public partial class frmAddOrEditePatient : Form
{
int _patientId;
bool isEdite = false;
public frmAddOrEditePatient(int? patientId = 0)
{
InitializeComponent();
_patientId = (int)patientId;
}
private void btnEnterAdmission_Click(object sender, EventArgs e)
{
if (ValidateInput())
{
Patient patient = new Patient();
patient.Name = txtPatientName.Text;
patient.Family = txtPatientFamily.Text;
patient.NationalCode = txtPatientNationalCode.Text;
patient.Email = txtPatientEmail.Text;
patient.Mobile = txtPatientMobile.Text;
patient.Age = (int)txtAge.Value;
patient.IsBlacked = false;
if (rbMale.Checked)
{
patient.Gender = true; // مرد
}
else
{
patient.Gender = false; // زن
}
using (ClinicCenter_Db_Context _context = new ClinicCenter_Db_Context())
{
if (isEdite == false)
{
_context.Patients.Add(patient);
_context.SaveChanges();
int serviceId = Convert.ToInt32(cboServiceType.SelectedValue);
int doctorId = Convert.ToInt32(cboDoctors.SelectedValue);
var service = _context.Services.Where(s => s.ServiceId == serviceId).Single();
frmPay frmPay = new frmPay(patient.PatientId, service.ServicePrice, service.ServiceId, doctorId);
var dialog = frmPay.ShowDialog();
if (dialog == DialogResult.OK)
{
this.Close();
}
}
else
{
patient.PatientId = _patientId;
patient.PatientInformationEditDate = DateTime.Now;
_context.Patients.Update(patient);
_context.SaveChanges();
PersianMsBox.Show("کاربر با موفقیت ویرایش شد", "عملیات موفق", PersianMsbox_button.Ok, PersianMsBox_Icons.information);
this.DialogResult = DialogResult.OK;
}
}
}
}
private void btnCancle_Click(object sender, EventArgs e)
{
this.Close();
}
private void frmPatientAdmission_Load(object sender, EventArgs e)
{
BindComboServiceType();
BindCboDoctors();
if (_patientId != 0)
{
isEdite = true;
this.Text = "ویرایش اطلاعات بیمار";
btnEnterAdmission.Text = "ثبت ویرایش";
cboServiceType.Enabled = false;
cboDoctors.Enabled = false;
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
var admitted = _Context.AdmittedPatients.AsNoTracking().Where(a => a.PatientId == _patientId).Single();
var data = _Context.Patients.Find(_patientId);
cboDoctors.SelectedValue = admitted.EmployeeId;
cboServiceType.SelectedValue = admitted.ServiceId;
txtPatientName.Text = data.Name;
txtPatientFamily.Text = data.Family;
txtPatientNationalCode.Text = data.NationalCode;
txtPatientEmail.Text = data.Email;
txtPatientMobile.Text = data.Mobile;
txtAge.Value = data.Age;
if (data.Gender == true) // مرد
{
rbMale.Checked = true;
}
else
{
rbFemale.Checked = true;
}
}
}
else
{
this.Text = "پذیرش بیمار";
isEdite = false;
btnEnterAdmission.Text = "ثبت پذیرش";
}
}
private void txtPatientNationalCode_TextChanged(object sender, EventArgs e)
{
try
{
int nationalCode = Convert.ToInt32(txtPatientNationalCode.Text);
}
catch
{
txtPatientNationalCode.Text = "";
}
}
#region Validate Input
bool ValidateInput()
{
bool isValid;
if (cboServiceType.SelectedItem == null)
{
lblValidateServiceType.Visible = true;
isValid = false;
}
else
{
lblValidateServiceType.Visible = false;
isValid = true;
}
if (string.IsNullOrEmpty(txtPatientName.Text))
{
lblValidateName.Visible = true;
isValid = false;
}
else
{
lblValidateName.Visible = false;
isValid = true;
}
if (string.IsNullOrEmpty(txtPatientFamily.Text))
{
lblValidateFamily.Visible = true;
isValid = false;
}
else
{
lblValidateFamily.Visible = false;
isValid = true;
}
if (string.IsNullOrEmpty(txtPatientNationalCode.Text))
{
lblValidateNationalCode.Visible = true;
isValid = false;
}
else
{
lblValidateNationalCode.Visible = false;
isValid = true;
}
if (string.IsNullOrEmpty(txtPatientMobile.Text))
{
lblValidateMobile.Visible = true;
isValid = false;
}
else
{
lblValidateMobile.Visible = false;
isValid = true;
}
if (string.IsNullOrEmpty(txtAge.Value.ToString()) || txtAge.Value < 1)
{
lblValidateAge.Visible = true;
isValid = false;
}
else
{
lblValidateAge.Visible = false;
isValid = true;
}
return isValid;
}
#endregion
#region Bind Combo Doctors
void BindCboDoctors()
{
using (ClinicCenter_Db_Context _context = new ClinicCenter_Db_Context())
{
cboDoctors.DataSource = _context.Employees.AsNoTracking().Where(e => e.IsDoctor == true &amp;amp;&amp;amp; e.IsActive == true).Select(s => new
{
s.PersonId,
DoctorOption = s.Name + " " + s.Family + " | " + _context.DoctorSpecializations.AsNoTracking()
.Where(d => d.SpecializationId == s.SpecializationId)
.Select(f => f.SpecializationName).Single()
}).ToList();
cboDoctors.ValueMember = "PersonId";
cboDoctors.DisplayMember = "DoctorOption";
}
}
#endregion
#region Bind Combo Service
void BindComboServiceType()
{
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
cboServiceType.DataSource = _Context.Services.AsNoTracking().Select(s => new
{
s.ServiceId,
s.ServiceName,
}).ToList();
cboServiceType.ValueMember = "ServiceId";
cboServiceType.DisplayMember = "ServiceName";
}
}
#endregion
}
}
using DataLayer.Context;
using Microsoft.EntityFrameworkCore;
using persian_MsBox;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Utiliti.Convertor;
using Utiliti.CustomType;
namespace ClinicCenter.Doctors
{
public partial class frmDoctorList : Form
{
public frmDoctorList()
{
InitializeComponent();
}
List<PersonList> lists = new List<PersonList>();
private void frmDoctorList_Load(object sender, EventArgs e)
{
}
private void btnAdd_Click(object sender, EventArgs e)
{
frmAddOrEditeDoctor addOrEditeDoctor = new frmAddOrEditeDoctor();
var dialog = addOrEditeDoctor.ShowDialog();
if (dialog == DialogResult.Cancel)
{
BindDgvPerson();
}
}
private void btnEdit_Click(object sender, EventArgs e)
{
if (dgvEmployeeList.CurrentRow != null)
{
string id = dgvEmployeeList.CurrentRow.Cells[0].Value.ToString();
int employeeId = Convert.ToInt32(id);
frmAddOrEditeDoctor addOrEditeDoctor = new frmAddOrEditeDoctor(employeeId);
var dialog = addOrEditeDoctor.ShowDialog();
if (dialog == DialogResult.OK)
{
BindDgvPerson();
}
}
}
private void tmTimeFormPerson_Tick(object sender, EventArgs e)
{
tmTimeFormPerson.Enabled = false;
BindDgvPerson();
}
private void txtSearch_TextChanged(object sender, EventArgs e)
{
dgvEmployeeList.Rows.Clear();
var result = lists.Where(f => f.FullName.Contains(txtSearch.Text) ||
f.SpecializationName.Contains(txtSearch.Text) ||
f.PersonType.Contains(txtSearch.Text) ||
f.SpecializationName.Contains(txtSearch.Text) ||
f.MedicalRegistrationCode.Contains(txtSearch.Text)).ToList();
foreach (var item in result)
{
dgvEmployeeList.Rows.Add(item.personId, item.FullName, item.PersonType, item.SpecializationName, item.MedicalRegistrationCode);
}
}
private void btnChangeStatus_Click(object sender, EventArgs e)
{
if (dgvEmployeeList.CurrentRow != null)
{
string id = dgvEmployeeList.CurrentRow.Cells[0].Value.ToString();
string fullname = dgvEmployeeList.CurrentRow.Cells[1].Value.ToString();
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
int personId = Convert.ToInt32(id);
var data = _Context.Employees.Find(personId);
if (data.IsActive == true)
{
var message = PersianMsBox.Show($"آیا از غیرفعال کاربر {fullname} اطمینان دارید؟", "توجه", PersianMsbox_button.YesNo, PersianMsBox_Icons.Warning);
if (message == DialogResult.Yes)
{
data.IsActive = false;
_Context.Employees.Update(data);
_Context.SaveChanges();
}
}
else
{
var message = PersianMsBox.Show($"آیا از فعال کاربر {fullname} اطمینان دارید؟", "توجه", PersianMsbox_button.YesNo, PersianMsBox_Icons.Warning);
if (message == DialogResult.Yes)
{
data.IsActive = true;
_Context.Update(data);
_Context.SaveChanges();
}
}
}
BindDgvPerson();
}
}
#region Bind Data GridView PersonList
void BindDgvPerson()
{
dgvEmployeeList.Rows.Clear();
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
lists = _Context.Employees.AsNoTracking().OrderByDescending(o => o.IsDoctor == true).Select(e => new PersonList
{
personId = e.PersonId,
FullName = e.Name + " " + e.Family,
Status = e.IsActive ? "فعال" : "غیرفعال",
PersonType = e.IsDoctor ? "دکتر" : "تکنسین",
SpecializationName = _Context.DoctorSpecializations.AsNoTracking().Where(s => s.SpecializationId == e.SpecializationId)
.Select(s => s.SpecializationName).SingleOrDefault() ?? "", // این کاراکتر به این معناست که اگر نال بود از این چیزی که بهات میدم جایگذینش کن ??
MedicalRegistrationCode = e.MedicalRegistrationCode ?? "",
}).ToList();
foreach (var item in lists)
{
dgvEmployeeList.Rows.Add(item.personId,
item.FullName,
item.Status,
item.PersonType,
item.SpecializationName,
item.MedicalRegistrationCode);
}
}
}
#endregion
}
}
using ClinicCenter.Model;
using DataLayer.Context;
using DataLayer.Model;
using Microsoft.EntityFrameworkCore;
using persian_MsBox;
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ClinicCenter.Doctors
{
public partial class frmAddOrEditeDoctor : Form
{
int? _employeeId;
bool isEditeMode = false;
bool isDoctor = true;
public frmAddOrEditeDoctor(int? employeeId = 0)
{
_employeeId = employeeId;
InitializeComponent();
}
private void btnEnter_Click(object sender, EventArgs e)
{
if (ValidateInput() == true)
{
Employee employee = new Employee();
employee.Name = txtName.Text;
employee.Family = txtFamily.Text;
if (isDoctor == true)
{
employee.IsDoctor = true;
employee.MedicalRegistrationCode = txtMedicalRegistrationCode.Text;
employee.SpecializationId = Convert.ToInt32(cboSpecializationDoc.SelectedValue);
}
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
if (isEditeMode == false)
{
_Context.Employees.Add(employee);
var dialog = PersianMsBox.Show($"کاربر با موفقیت ثبت شد.\r آیا مایلید کاربر دیگری را ثبت نمایید؟", "ثبت موفق", PersianMsbox_button.YesNo, PersianMsBox_Icons.information);
if (dialog == DialogResult.Yes)
{
this.Close();
frmAddOrEditeDoctor frmAddOrEdite = new frmAddOrEditeDoctor();
frmAddOrEdite.ShowDialog();
}
else
{
this.Close();
}
_Context.SaveChanges();
}
else
{
employee.PersonId = (int)_employeeId;
_Context.Employees.Update(employee);
_Context.SaveChanges();
var result = PersianMsBox.Show("ویرایش کاربر با موفقیت انجام شد", "عملیات موفق", PersianMsbox_button.Ok, PersianMsBox_Icons.information);
this.Close();
}
this.DialogResult = DialogResult.OK;
}
}
}
private void btnCancle_Click(object sender, EventArgs e)
{
this.Close();
}
private void frmAddOrEditeDoctor_Load(object sender, EventArgs e)
{
BindComboSpecialization();
if (_employeeId != 0)
{
isEditeMode = true;
this.Text = "ویرایش پرسنل";
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
var data = _Context.Employees.Find(_employeeId);
txtName.Text = data.Name;
txtFamily.Text = data.Family;
txtMedicalRegistrationCode.Text = data.MedicalRegistrationCode;
if (data.IsDoctor == true)
{
rbDocor.Checked = true;
}
else
{
rbTechnician.Checked = true;
}
}
}
else
{
this.Text = "افزودن پرسنل";
}
}
private void frmAddOrEditeDoctor_Activated(object sender, EventArgs e)
{
}
#region Position Employee RadioButtons
private void rbTechnician_CheckedChanged(object sender, EventArgs e)
{
isDoctor = false;
lblValidateSpecializations.Enabled = false;
lblValidateRegistrationCode.Enabled = false;
cboSpecializationDoc.Enabled = false;
txtMedicalRegistrationCode.Enabled = false;
}
private void rbDocor_CheckedChanged(object sender, EventArgs e)
{
isDoctor = true;
lblValidateSpecializations.Enabled = true;
lblValidateRegistrationCode.Enabled = true;
cboSpecializationDoc.Enabled = true;
txtMedicalRegistrationCode.Enabled = true;
}
#endregion
#region Validate Input
bool ValidateInput()
{
bool isValid;
if (string.IsNullOrEmpty(txtName.Text))
{
lblValidateName.Visible = true;
isValid = false;
}
else
{
lblValidateName.Visible = false;
isValid = true;
}
if (string.IsNullOrEmpty(txtFamily.Text))
{
lblValidateFamily.Visible = true;
isValid = false;
}
else
{
lblValidateFamily.Visible = false;
isValid = true;
}
if (isDoctor == true)
{
if (cboSpecializationDoc.SelectedItem == null)
{
lblValidateSpecializations.Visible = true;
isValid = false;
}
else
{
lblValidateSpecializations.Visible = false;
isValid = true;
}
if (string.IsNullOrEmpty(txtMedicalRegistrationCode.Text))
{
lblValidateRegistrationCode.Visible = true;
isValid = false;
}
else
{
lblValidateRegistrationCode.Visible = false;
isValid = true;
}
}
return isValid;
}
#endregion
#region Bind Combo Box Specialization
void BindComboSpecialization()
{
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
cboSpecializationDoc.DataSource = _Context.DoctorSpecializations.Select(s => new
{
s.SpecializationName,
s.SpecializationId,
}).ToList();
cboSpecializationDoc.DisplayMember = "SpecializationName";
cboSpecializationDoc.ValueMember = "SpecializationId";
}
}
#endregion
}
}using DataLayer.Context;
using DataLayer.Model;
using Microsoft.EntityFrameworkCore;
using persian_MsBox;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Utiliti.Separator;
namespace ClinicCenter.PaymentPage
{
public partial class frmPay : Form
{
int _patientId;
int _serviceId;
int _servicePrice;
int _debt;
int _doctorId;
int _payId;
bool isSettlementMode = false;
public frmPay(int patientId, int servicePrice, int serviceId, int doctorId)
{
InitializeComponent();
_patientId = patientId;
_servicePrice = servicePrice;
_serviceId = serviceId;
_doctorId = doctorId;
}
public frmPay(int payId)
{
InitializeComponent();
_payId = payId;
isSettlementMode = true;
}
private void frmPay_Load(object sender, EventArgs e)
{
if (isSettlementMode == true)
{
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
var data = _Context.paymentManages.AsNoTracking().Where(p => p.PayId == _payId).Include(p => p.AdmittedPatients).Single();
this.Text = "تسویه هزینه بیمار";
txtPrice.Text = data.Debt.ToThereDigit().ToString();
_debt = Convert.ToInt32(txtPrice.Text.Replace(",", ""));
}
}
else
{
txtPrice.Text = _servicePrice.ToThereDigit().ToString();
int price = Convert.ToInt32(txtPrice.Text.Replace(",", ""));
}
}
private void btnPayPrice_Click(object sender, EventArgs e)
{
if (isSettlementMode == true)
{
int newPay = Convert.ToInt32(txtInputPrice.Text);
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
var data = _Context.paymentManages.Find(_payId);
if (!string.IsNullOrEmpty(txtInputPrice.Text))
{
int pay = data.Debt - newPay;
if (pay < 0)
{
var messsage = PersianMsBox.Show("هزینه پرداختی بیشتر از بدهکاری بیمار است.", "هشدار محاسباتی", PersianMsbox_button.Ok, PersianMsBox_Icons.information);
pay = 0;
if (messsage == DialogResult.OK)
{
this.DialogResult = DialogResult.Cancel;
}
}
else if (pay == 0)
{
var message = PersianMsBox.Show("پرداخت با موفقیت انجان شد . بدهی بیمار به طور کامل تسویه شد.", "پرداخت موفق", PersianMsbox_button.Ok, PersianMsBox_Icons.information);
data.Debt = pay;
data.IsPay = true;
if (message == DialogResult.OK)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
}
else
{
data.Debt = pay;
var message = PersianMsBox.Show($"پرداخت با موفقیت انجام شد میزان بدهی شما {data.Debt} میباشد در اسرع وقت بدهکاری با کلینیک را تسویه کنید.", "پرداخت موفق", PersianMsbox_button.Ok, PersianMsBox_Icons.information);
if (message == DialogResult.OK)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
}
_Context.paymentManages.Update(data);
_Context.SaveChanges();
}
}
}
else
{
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
AdmittedPatients admitted = new AdmittedPatients();
admitted.PatientId = _patientId;
admitted.ServiceId = _serviceId;
admitted.EmployeeId = _doctorId;
admitted.AdmittedDate = DateTime.Now;
_Context.AdmittedPatients.Add(admitted);
_Context.SaveChanges();
if (!string.IsNullOrEmpty(txtInputPrice.Text))
{
_debt = Convert.ToInt32(txtInputPrice.Text);
if (CheckInput() == true)
{
PaymentManage payment = new PaymentManage();
payment.ServicePrice = _servicePrice;
payment.ServiceId = _serviceId;
payment.AdmittedId = admitted.AdmittedId;
payment.PayDate = DateTime.Now;
if (ComparisonPrice() == true)
{
payment.IsPay = true;
payment.Debt = _debt;
PersianMsBox.Show("پرداخت موفقیت آمیز.\r بیمار با موفقیت پذیرش شد", "عملیات موفق", PersianMsbox_button.Ok, PersianMsBox_Icons.information);
}
else
{
payment.IsPay = false;
payment.Debt = _debt;
PersianMsBox.Show($"پرداخت موفقیت آمیز.\r بیمار با موفقیت پذیرش شد.\r میزان بدهی شما به کلینیک {_debt.ToThereDigit()}ریال است در اسرع وقت پرداخت شود .", "عملیات موفق", PersianMsbox_button.Ok, PersianMsBox_Icons.information);
}
_Context.paymentManages.Add(payment);
_Context.SaveChanges();
this.DialogResult = DialogResult.OK;
}
}
}
}
}
private void btnPayAllPrice_Click(object sender, EventArgs e)
{
if (isSettlementMode == true)
{
if (txtInputPrice.Text == "")
{
txtInputPrice.Text = _debt.ToString();
}
else
{
txtInputPrice.Text = "";
txtInputPrice.Text = _debt.ToString();
}
}
else
{
if (txtInputPrice.Text == "")
{
txtInputPrice.Text = _servicePrice.ToString();
}
else
{
txtInputPrice.Text = "";
txtInputPrice.Text = _servicePrice.ToString();
}
}
}
private void btnCancele_Click(object sender, EventArgs e)
{
this.Close();
}
private void txtInputPrice_TextChanged(object sender, EventArgs e)
{
try
{
int price = Convert.ToInt32(txtInputPrice.Text);
}
catch
{
txtInputPrice.Text = "";
}
}
#region Calc Of The Price Payable
bool ComparisonPrice()
{
bool isPay = false;
int result = _servicePrice - _debt;
if (result == 0)
{
isPay = true;
_debt = result;
}
else
{
isPay = false;
_debt = result;
}
return isPay;
}
#endregion
#region Check Out Of Range Price
bool CheckInput()
{
bool isCheckd;
if (_debt > _servicePrice)
{
isCheckd = false;
txtInputPrice.Text = "";
_debt = 0;
}
else
{
isCheckd = true;
}
return isCheckd;
}
#endregion
}
}using DataLayer.Context;
using DataLayer.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Utiliti.Convertor;
namespace ClinicCenter.ClinicSetting
{
public partial class frmAddServices : Form
{
public frmAddServices()
{
InitializeComponent();
}
private void frmAddServices_Load(object sender, EventArgs e)
{
}
private void btnEnter_Click(object sender, EventArgs e)
{
if (ValidateInput() == true)
{
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
Service service = new Service();
service.ServiceName = txtInputServiceName.Text;
service.ServicePrice = Convert.ToInt32(txtInputServicePrice.Text);
service.UpdatePrice = DateTime.Now;
_Context.Services.Add(service);
_Context.SaveChanges();
this.Close();
}
}
}
private void btnCancele_Click(object sender, EventArgs e)
{
this.Close();
}
#region Validate Input
bool ValidateInput()
{
bool isValid;
if (string.IsNullOrEmpty(txtInputServiceName.Text))
{
lblValidateName.Visible = true;
isValid = false;
}
else
{
lblValidateName.Visible = false;
isValid = true;
}
if (string.IsNullOrEmpty(txtInputServicePrice.Text))
{
lblValidatePrice.Visible = true;
isValid = false;
}
else
{
lblValidatePrice.Visible = false;
isValid = true;
}
return isValid;
}
#endregion
private void txtInputServicePrice_TextChanged(object sender, EventArgs e)
{
}
}
}
using DataLayer.Context;
using DataLayer.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ClinicCenter.ClinicSetting
{
public partial class frmAddSpecialization : Form
{
public frmAddSpecialization()
{
InitializeComponent();
}
private void btnEnter_Click(object sender, EventArgs e)
{
if (ValidateInput() == true)
{
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
DoctorSpecialization specialization = new DoctorSpecialization()
{
SpecializationName = txtSpecializationName.Text
};
_Context.DoctorSpecializations.Add(specialization);
_Context.SaveChanges();
}
this.Close();
}
}
private void btnCancele_Click(object sender, EventArgs e)
{
this.Close();
}
#region Validate Input
bool ValidateInput()
{
bool isValid;
if (string.IsNullOrEmpty(txtSpecializationName.Text))
{
lblValidateName.Visible = true;
isValid = false;
}
else
{
lblValidateName.Visible = false;
isValid = true;
}
return isValid;
}
#endregion
}
}
using DataLayer.Context;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Net.Http.Headers;
using System.Text;
using System.Windows.Forms;
namespace ClinicCenter.ClinicSetting
{
public partial class frmClinicSetting : Form
{
public frmClinicSetting()
{
InitializeComponent();
}
private void btnAddSpecialization_Click(object sender, EventArgs e)
{
frmAddSpecialization specialization = new frmAddSpecialization();
specialization.ShowDialog();
}
private void btnAppearance_Click(object sender, EventArgs e)
{
}
private void btnServiceSettings_Click(object sender, EventArgs e)
{
frmServiceFinancialSettings FinancialSettings = new frmServiceFinancialSettings();
FinancialSettings.ShowDialog();
}
private void frmClinicSetting_Load(object sender, EventArgs e)
{
BindlistInformationList();
}
#region Bind ListBox Specializations And Services
void BindlistInformationList()
{
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
lstSpecializationList.Items.Clear();
var specializationData = _Context.DoctorSpecializations.AsNoTracking().Select(d => d.SpecializationName).ToList();
foreach (var item in specializationData)
{
lstSpecializationList.Items.Add(item);
}
lstServicesList.Items.Clear();
var servicesData = _Context.Services.AsNoTracking().Select(s => s.ServiceName).ToList();
foreach (var item in servicesData)
{
lstServicesList.Items.Add(item);
}
}
}
#endregion
private void frmClinicSetting_Activated(object sender, EventArgs e)
{
BindlistInformationList();
}
private void btnClinicFinances_Click(object sender, EventArgs e)
{
frmFinances finances = new frmFinances();
finances.ShowDialog();
}
}
}
using DataLayer.Context;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Utiliti.Separator;
namespace ClinicCenter.ClinicSetting
{
public partial class frmFinances : Form
{
public frmFinances()
{
InitializeComponent();
}
long _Introduction;
long _DebtPatient;
private void frmFinances_Load(object sender, EventArgs e)
{
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
_Introduction = _Context.paymentManages.Sum(p => p.ServicePrice);
lblIntroduction.Text = _Introduction.ToThereDigit();
_DebtPatient = _Context.paymentManages.Sum(d => d.Debt);
lblDebtPatient.Text = _DebtPatient.ToThereDigit();
long result = _Introduction - _DebtPatient;
lblProfit.Text = result.ToThereDigit();
}
}
private void btnCancele_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
using DataLayer.Context;
using DataLayer.Model;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Utiliti.Convertor;
using Utiliti.Separator;
using persian_MsBox;
namespace ClinicCenter.ClinicSetting
{
public partial class frmServiceFinancialSettings : Form
{
private int _servicesId;
public frmServiceFinancialSettings()
{
InitializeComponent();
}
private void frmServiceFinancialSettings_Load(object sender, EventArgs e)
{
}
private void btnAddServices_Click(object sender, EventArgs e)
{
frmAddServices addServices = new frmAddServices();
addServices.ShowDialog();
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
private void frmServiceFinancialSettings_Activated(object sender, EventArgs e)
{
BindGridServicesInfo();
}
#region Bind DGV Services Information
void BindGridServicesInfo()
{
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
dgvServiceList.Rows.Clear();
var data = _Context.Services.AsNoTracking().ToList();
foreach (var item in data)
{
dgvServiceList.Rows.Add(item.ServiceId, item.ServiceName, item.ServicePrice.ToThereDigit(), item.UpdatePrice.ToShamsi());
}
}
}
#endregion
private void btnEnter_Click(object sender, EventArgs e)
{
if (txtServiceName.Text != "" &amp;&amp; txtServicePrice.Text != "")
{
using (ClinicCenter_Db_Context _Context = new ClinicCenter_Db_Context())
{
try
{
var data = _Context.Services.Find(_servicesId);
int servicePrice = Convert.ToInt32(txtServicePrice.Text);
data.ServicePrice = servicePrice;
data.ServiceName = txtServiceName.Text;
int newPrice = _Context.Services.Where(a => a.ServiceId == _servicesId).Select(a => a.ServicePrice).Single();
if (servicePrice != newPrice)
{
data.UpdatePrice = DateTime.Now;
}
_Context.Services.Update(data);
_Context.SaveChanges();
}
catch (DbUpdateException)
{
PersianMsBox.Show("خطا در اپدیت هزینه خدمت ها", "خطا", PersianMsbox_button.Ok, PersianMsBox_Icons.Error);
}
catch (FormatException)
{
PersianMsBox.Show("لطفا در هنگام به روزرسانی قیمت خدمت مد نظر فقط عدد وارد شود ", "خطا فرمت ورودی هزینه قیمت", PersianMsbox_button.Ok, PersianMsBox_Icons.Error);
}
}
BindGridServicesInfo();
}
}
private void dgvServiceList_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
string id = dgvServiceList.CurrentRow.Cells[0].Value.ToString();
string name = dgvServiceList.CurrentRow.Cells[1].Value.ToString();
string price = dgvServiceList.CurrentRow.Cells[2].Value.ToString().Replace(",", "");
_servicesId = Convert.ToInt32(id);
txtServiceName.Text = name;
txtServicePrice.Text = price;
}
private void btnHelp_Click(object sender, EventArgs e)
{
MessageBox.Show("برای بروزرسانی قیمت خدمت ها, ابتدا روی خدمت مورد نظر خود دوبار کلیک نمایید. سپس در کادر پایین مشخصات ظاهر میشود که میتوانید هزینه مد نظر را وارد نمایی و سپس گزینه ثبت تغییرات را کلیک کنید", "راهنما");
}
}
}

بسیار عالی
از دیدن کد هات و تصاویر بسیار لذت بردم
سپاس از شما استاد مدائنی عزیز
تلاشم این بود که نسبت به وسعت پروژه تمیز کد بزنم ، نمیدونم حالا تا حدودی درست عمل کردم یا نه . امیدوارم که کد هام قابل قبول باشه
خیلی ممنونم از نظر دلگرم کنندتون استاد🌹
بسیار عالی بودن و کاملا قابل قبول
بسیار ممنونم از نظر دلگرم کننده شما که قطعا باعث تلاش بیشتر بنده خواهد بود که هرروز بهتر از روز قبل خودم باشم🌹🌹🌹