public void DateWiseReport(DateTime DateFrom) { using (MarwariContext db = new MarwariContext()) { stdt = DateFrom; dateTimePicker1.Value = DateFrom; this.Text = "Registration Report, " + DateFrom.ToString(Database.dformat); bs.DataSource = db.Accounts.Select(rpt => new { Registration_No = rpt.Pat_id, Name = rpt.Name, Room_Number = rpt.Number, Gender = rpt.Sex, Age = rpt.Age, Date = rpt.RDate, Time = rpt.RTime, pay = rpt.Pay }).Where(p1 => p1.Date == stdt).OrderByDescending(d => d.Registration_No).ToList(); dataGridView1.DataSource = bs; dataGridView1.Columns["Registration_No"].Width = 100; dataGridView1.Columns["Name"].Width = 150; dataGridView1.Columns["Room_Number"].Width = 110; dataGridView1.Columns["Gender"].Width = 130; dataGridView1.Columns["Age"].Width = 150; dataGridView1.Columns["Date"].Width = 100; dataGridView1.Columns["Time"].Width = 100; dataGridView1.Columns["Pay"].Width = 100; } }
public Report() { InitializeComponent(); dateTimePicker1.CustomFormat = "dd-MMM-yyyy"; using (MarwariContext db = new MarwariContext()) { comp_record = db.Companies.First(); } }
public void save() { using (MarwariContext db = new MarwariContext()) { user_record.UPass = textBox2.Text; db.UserInfos.AddOrUpdate(user_record); db.SaveChanges(); this.Close(); this.Dispose(); System.Drawing.Icon appIcon = System.Drawing.Icon.ExtractAssociatedIcon(Application.StartupPath + "\\DHospital.exe"); notifyIcon.Icon = appIcon; notifyIcon.Visible = true; notifyIcon.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info; notifyIcon.BalloonTipTitle = "Saved"; notifyIcon.BalloonTipText = "Saved Successfully"; notifyIcon.ShowBalloonTip(1000); } }
private void Button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Enter username"); textBox1.Focus(); return; } else if (textBox2.Text == "") { MessageBox.Show("Enter password"); textBox2.Focus(); return; } using (MarwariContext db = new MarwariContext()) { int count = db.UserInfos.Count(); //MessageBox.Show(count.ToString()); bool Exists = db.UserInfos.Any(contact => contact.UName.Equals(textBox1.Text) && contact.UPass.Equals(textBox2.Text)); if (Exists) { user_record = db.UserInfos.Where(p1 => p1.UName.Equals(textBox1.Text) && p1.UPass.Equals(textBox2.Text)).First(); Company company = db.Companies.FirstOrDefault(); Database.setVariable(textBox3.Text, textBox4.Text, textBox1.Text, user_record.UType, DateTime.Parse(company.StartFrom.ToString("dd-MMM-yyyy")), DateTime.Parse(company.EndAt.ToString("dd-MMM-yyyy"))); Database.ldate = DateTime.Parse(dateTimePicker1.Text); frm_main frm = new frm_main(); frm.Show(); this.Hide(); } else { MessageBox.Show("Invalid username or password"); textBox1.Focus(); } } //db.Connection.Close(); }
public void LoadData(string str, string frmCaption) { using (MarwariContext db = new MarwariContext()) { gstr = str; this.Text = frmCaption; if (str == "Patient") { //bs.DataSource = db.ACCOUNTs // .Select(rpt => new { pat_id = rpt.pat_id, name = rpt.name, number = rpt.number, sex = rpt.sex, age = rpt.age, rdate = rpt.rdate, pay = rpt.pay, Ac_id = rpt.Ac_id }) // .OrderByDescending(d => d.pat_id).ToList() // .Select(rpt => new { Registration = rpt.pat_id, Patient = rpt.name, RoomNumber = rpt.number, Gender = rpt.sex, Age = rpt.age, Date = DateTime.Parse(rpt.rdate.ToString()).ToString("dd-MMM-yyyy"), Payment = rpt.pay, Ac_id = rpt.Ac_id }).ToList(); //dataGridView1.DataSource = bs; // bs.DataSource = db.ACCOUNTs.Select(rpt => new { Registration_No = rpt.pat_id, Name = rpt.name, Room_Number = rpt.number, Gender = rpt.sex, Age = rpt.age, Date = rpt.rdate, Pay = rpt.pay, Ac_id = rpt.Ac_id }).Where(p1 => p1.Date >= dateTimePicker1.Value.Date && p1.Date <= dateTimePicker2.Value.Date).OrderByDescending(d => d.Registration_No); bs.DataSource = db.Accounts .Select(rpt => new { Registration = rpt.Pat_id, Name1 = rpt.Name, RoomNumber1 = rpt.Number, Gender1 = rpt.Sex, Age1 = rpt.Age, Date1 = rpt.RDate, Pay1 = rpt.Pay, Ac_id = rpt.Ac_id }).Where(p1 => p1.Date1 >= dateTimePicker1.Value.Date && p1.Date1 <= dateTimePicker2.Value.Date) .OrderByDescending(d => d.Registration).ToList() .Select(rpt => new { Registration_No = rpt.Registration, Name = rpt.Name1, Room_Number = rpt.RoomNumber1, Gender = rpt.Gender1, Age = rpt.Age1, Date = DateTime.Parse(rpt.Date1.ToString()).ToString("dd-MMM-yyyy"), Pay = rpt.Pay1, Ac_id = rpt.Ac_id }) .ToList(); dataGridView1.DataSource = bs.DataSource; dataGridView1.Columns["Registration_No"].Width = 100; dataGridView1.Columns["Name"].Width = 150; dataGridView1.Columns["Room_Number"].Width = 110; dataGridView1.Columns["Gender"].Width = 100; dataGridView1.Columns["Age"].Width = 80; dataGridView1.Columns["Date"].Width = 100; dataGridView1.Columns["Pay"].Width = 100; label3.Text = dataGridView1.Rows.Count.ToString(); button1.Text = "New Patients"; label2.Text = "List of Patients"; dataGridView1.Columns["Ac_id"].Visible = false; } dataGridView1.Columns["print1"].DataGridView.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView1.Columns["print1"].DisplayIndex = dataGridView1.Columns.Count - 2 + 1; } }
public void LoadData(string uname, string FrmCaption) { using (MarwariContext db = new MarwariContext()) { gStr = uname; bool Exists = db.UserInfos.Any(contact => contact.UName.Equals(gStr)); this.Text = FrmCaption; if (Exists) { user_record = db.UserInfos.Where(p1 => p1.UName.Equals(gStr)).First(); textBox1.Text = user_record.UName; textBox2.Text = user_record.UPass; } else { textBox1.Text = ""; textBox2.Text = ""; } } }
private void Button1_Click(object sender, EventArgs e) { if (validate() == true) { using (MarwariContext db = new MarwariContext()) { if (Exists == true && send == false) { string maxdate = DateTime.Parse(db.Accounts.Max(p => p.RDate).ToString()).ToString("dd-MMM-yyyy"); rdate = DateTime.Parse(Record.RDate.ToString()).ToString("dd-MMM-yyyy"); if (maxdate != rdate) { int randomno = RandomNumber(111111, 999999); //MessageBox.Show(randomno.ToString()); WhatsApp.Send("Patient Id: " + patid + "\nDated: " + rdate + "\nOTP for Printing is " + randomno.ToString()); send = true; InputBox box = new InputBox("Type OTP", "", false); box.outStr = "OTP"; box.random = randomno; box.ShowInTaskbar = false; box.ShowDialog(this); if (box.match == true) { //save(); //ac_id = Record.Ac_id; //System.Drawing.Printing.PaperSize ps = new System.Drawing.Printing.PaperSize(); //ps.RawKind = (int)System.Drawing.Printing.PaperKind.A4; //printDocument1.DefaultPageSettings.PaperSize = ps; //printDocument1.DefaultPageSettings.Landscape = true; //printDocument1.PrintController = new System.Drawing.Printing.StandardPrintController(); //var thread = new Thread(printDocument1.Print); //thread.SetApartmentState(ApartmentState.STA); //thread.Start(); // this.Close(); // this.Dispose(); } else if (box.match == false) { this.Close(); this.Dispose(); return; } } } save(); ac_id = Record.Ac_id; System.Drawing.Printing.PaperSize ps = new System.Drawing.Printing.PaperSize(); ps.RawKind = (int)System.Drawing.Printing.PaperKind.A4; printDocument1.DefaultPageSettings.PaperSize = ps; printDocument1.DefaultPageSettings.Landscape = true; printDocument1.PrintController = new System.Drawing.Printing.StandardPrintController(); var thread = new Thread(printDocument1.Print); thread.SetApartmentState(ApartmentState.STA); thread.Start(); if (gStr == "0") { LoadData("0", this.Text); TextBox1.Focus(); } else { this.Close(); this.Dispose(); } garbage(); GC.Collect(); } } }
public void Print(System.Drawing.Printing.PrintPageEventArgs e, int ac_id) { using (MarwariContext db = new MarwariContext()) { Account print_record = db.Accounts.Where(po => po.Ac_id == ac_id).First(); int w = 590; int x = 0; int y = 0; Font printFontExtraBold = new Font("Arial", 20, FontStyle.Bold); Font printFontB = new Font("Arial", 12, FontStyle.Bold); Font printFontN = new Font("Arial", 10); Graphics g = e.Graphics; SolidBrush Brush = new SolidBrush(Color.Black); y = y + 20; g.DrawString("स्वामी कल्याण देव राजकीय जिला चिकित्सालय", printFontExtraBold, Brush, 10, y); y = y + 50; g.DrawString("जनपद - मुज़फ्फरनगर", printFontB, Brush, (w - g.MeasureString("जनपद - मुज़फ्फरनगर", printFontB).Width) / 2, y); y = y + 30; g.DrawString("बाह्य रोगी टिकट", printFontB, Brush, (w - g.MeasureString("बाह्य रोगी टिकट", printFontB).Width) / 2, y); string s = "abc"; y = y + 30; g.DrawString("पंजीकरण संख्या-", printFontN, Brush, 10, y); g.DrawString(print_record.Pat_id.ToString().PadLeft(7, '0'), printFontB, Brush, 110, y); g.DrawString("दिनाक-", printFontN, Brush, 300, y); g.DrawString(DateTime.Parse(print_record.RDate.ToString()).ToString(Database.dformat), printFontB, Brush, 370, y); y = y + 20; g.DrawString("रोगी का नाम-", printFontN, Brush, 10, y); g.DrawString(print_record.Name.ToString(), printFontB, Brush, 110, y); g.DrawString("समय-", printFontN, Brush, 300, y); string atime = print_record.RTime.ToString(); int ahour = int.Parse(atime.Split(':')[0].ToString()); int amin = int.Parse(atime.Split(':')[1].ToString()); int asec = int.Parse(atime.Split(':')[2].ToString()); DateTime acctime = new DateTime(2016, 1, 1, ahour, amin, asec); g.DrawString(acctime.ToString("HH:mm:ss"), printFontB, Brush, 370, y); // g.DrawString(rtime, printFontB, Brush, 370, y); y = y + 20; g.DrawString("आयु-", printFontN, Brush, 10, y); g.DrawString(print_record.Age.ToString(), printFontB, Brush, 110, y); g.DrawString("कमरा संख्या-", printFontN, Brush, 300, y); g.DrawString(print_record.Number.ToString(), printFontB, Brush, 400, y); y = y + 20; g.DrawString("लिंग-", printFontN, Brush, 10, y); g.DrawString(print_record.Sex.ToString(), printFontB, Brush, 110, y); g.DrawString("भुगतान-", printFontN, Brush, 300, y); g.DrawString(print_record.Pay.ToString(), printFontB, Brush, 400, y); y = y + 30; Pen p = new Pen(Color.Black); p.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; Point p1 = new Point(10, y); Point p2 = new Point(520, y); g.DrawLine(p, p1, p2); p1 = new Point(10, y); p2 = new Point(10, y + 545); g.DrawLine(p, p1, p2); p1 = new Point(100, y); p2 = new Point(100, y + 545); g.DrawLine(p, p1, p2); p1 = new Point(520, y); p2 = new Point(520, y + 545); g.DrawLine(p, p1, p2); p1 = new Point(10, y); p2 = new Point(520, y); g.DrawLine(p, p1, p2); p1 = new Point(10, y + 30); p2 = new Point(520, y + 30); g.DrawLine(p, p1, p2); p1 = new Point(10, y + 30); p2 = new Point(520, y + 30); g.DrawLine(p, p1, p2); p1 = new Point(10, y + 545); p2 = new Point(520, y + 545); g.DrawLine(p, p1, p2); g.DrawString("दिनाक", printFontB, Brush, 10, y); g.DrawString("उपचार", printFontB, Brush, 260, y); y = y + 545; g.DrawString("नोट: यह पर्ची केवल 15 दिन तक मान्य है", printFontB, Brush, (w - g.MeasureString("नोट: यह पर्ची केवल 15 दिन तक मान्य है", printFontB).Width) / 2, y); System.Drawing.Image img = System.Drawing.Image.FromFile(Application.StartupPath + "\\1.jpg"); Point loc = new Point(470, 60); e.Graphics.DrawImage(img, loc); } }
public void LoadData(String str, String frmCaption) { gStr = str; patid = 0; int ID = int.Parse(gStr); this.Text = frmCaption; using (MarwariContext db = new MarwariContext()) { Exists = db.Accounts.Any(p => p.Ac_id == ID); if (Exists) { logrecord = new Log(); Record = db.Accounts.Where(p1 => p1.Ac_id == ID).First(); rdate = DateTime.Parse(Record.RDate.ToString()).ToString("dd-MMM-yyyy"); rtime = DateTime.Parse(Record.RTime.ToString()).ToString("HH:mm:ss"); TextBox1.Enabled = false; textBox2.Enabled = false; textBox3.Enabled = false; label3.Visible = true; textBox4.Visible = true; textBox4.Enabled = false; groupBox2.Enabled = false; groupBox3.Enabled = false; textBox3.Text = Record.Number; textBox4.Text = rtime; oldname = Record.Name; } else { Record = new Account(); } } patid = Record.Pat_id; TextBox1.Text = Record.Name; textBox2.Text = Record.Age; if (Record.Sex == "Male") { radioButton1.Checked = true; } else if (Record.Sex == "Female") { radioButton2.Checked = true; } else if (Record.Sex == "Third Gender") { radioButton3.Checked = true; } if (Record.Pay == "Paid") { radioButton4.Checked = true; } else if (Record.Pay == "U.T. Free") { radioButton5.Checked = true; } else if (Record.Pay == "Free (Other)") { radioButton6.Checked = true; } }
private void save() { using (MarwariContext db = new MarwariContext()) { using (TransactionScope s = new TransactionScope()) { if (rdate == "" || rdate == null) { rdate = System.DateTime.Now.ToString("dd-MMM-yyyy"); rtime = System.DateTime.Now.ToString("HH:mm:ss"); } rtime = label9.Text; int ID = int.Parse(gStr); Exists = db.Accounts.Any(p => p.Ac_id == ID); if (Exists) { Record = db.Accounts.Where(p1 => p1.Ac_id == ID).First(); rtime = DateTime.Parse(Record.RTime.ToString()).ToString("HH:mm:ss"); } else { } Record.Name = TextBox1.Text; Record.Age = textBox2.Text; Record.Number = textBox3.Text; if (radioButton1.Checked == true) { Record.Sex = "Male"; } else if (radioButton2.Checked == true) { Record.Sex = "Female"; } else if (radioButton3.Checked == true) { Record.Sex = "Third Gender"; } Record.RDate = DateTime.Now; if (radioButton4.Checked == true) { Record.Pay = "Paid"; } else if (radioButton5.Checked == true) { Record.Pay = "U.T. Free"; } else if (radioButton6.Checked == true) { Record.Pay = "Free (Other)"; } Record.Other = ""; Record.RDate = DateTime.Parse(rdate.ToString()); Record.RTime = rtime; if (!Exists) //add { Record.Pat_id = db.Accounts.Max(p => p.Pat_id) + 1; db.Accounts.Add(Record); } else { // Record.rtime = textBox4.Text; // acid = Record.Ac_id; } // db.SaveChanges(); rdate = System.DateTime.Now.ToString("dd-MMM-yyyy"); rtime = System.DateTime.Now.ToString("HH:mm:ss"); if (alter == true) { logrecord.RegNo = Record.Pat_id; logrecord.RDate = DateTime.Now.Date; logrecord.RTime = DateTime.Now.ToString("HH:mm:ss"); logrecord.OldName = CryptoEngine.Encrypt(oldname, "Marwari-Software"); logrecord.NewName = CryptoEngine.Encrypt(Record.Name, "Marwari-Software"); //db.Logs.Add(logrecord); db.Logs.AddOrUpdate(logrecord); } db.SaveChanges(); s.Complete(); } } GC.Collect(); System.Drawing.Icon appIcon = System.Drawing.Icon.ExtractAssociatedIcon(Application.StartupPath + "\\DHospital.exe"); notifyIcon.Icon = appIcon; notifyIcon.Visible = true; notifyIcon.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info; notifyIcon.BalloonTipTitle = "Saved"; notifyIcon.BalloonTipText = "Saved Successfully"; notifyIcon.ShowBalloonTip(1000); }
public void filter() { String strTemp = textBox1.Text; strTemp = strTemp.Replace("%", "?"); strTemp = strTemp.Replace("[", string.Empty); strTemp = strTemp.Replace("]", string.Empty); //string strfilter = ""; //for (int i = 0; i < dataGridView1.ColumnCount; i++) //{ // if (strfilter != "") // { // strfilter += " or "; // } // strfilter += "(" + dataGridView1.Columns[i].HeaderCell.Value.ToString() + " like *" + strTemp + "* " + ")"; //} // bs.Filter = null; //bs.Filter = strfilter; //dataGridView1.DataSource = null; //dataGridView1.DataSource = bs; //bs.DataSource = db.ACCOUNTs // .Select(rpt => new { pat_id = rpt.pat_id, name = rpt.name, number = rpt.number, sex = rpt.sex, age = rpt.age, rdate = rpt.rdate, pay = rpt.pay, Ac_id = rpt.Ac_id }) // .OrderByDescending(d => d.pat_id).ToList() // .Select(rpt => new { Registration = rpt.pat_id, Patient = rpt.name, RoomNumber = rpt.number, Gender = rpt.sex, Age = rpt.age, Date = DateTime.Parse(rpt.rdate.ToString()).ToString("dd-MMM-yyyy"), Payment = rpt.pay, Ac_id = rpt.Ac_id }) // .Where(w => w.Gender.Contains(textBox1.Text)).ToList(); using (MarwariContext db = new MarwariContext()) { if (textBox1.Text.Trim() == "") { bs.DataSource = db.Accounts .Select(rpt => new { Registration = rpt.Pat_id, Name1 = rpt.Name, RoomNumber1 = rpt.Number, Gender1 = rpt.Sex, Age1 = rpt.Age, Date1 = rpt.RDate, Pay1 = rpt.Pay, Ac_id = rpt.Ac_id }).Where(p1 => p1.Date1 >= dateTimePicker1.Value.Date && p1.Date1 <= dateTimePicker2.Value.Date) .OrderByDescending(d => d.Registration).ToList() .Select(rpt => new { Registration_No = rpt.Registration, Name = rpt.Name1, Room_Number = rpt.RoomNumber1, Gender = rpt.Gender1, Age = rpt.Age1, Date = DateTime.Parse(rpt.Date1.ToString()).ToString("dd-MMM-yyyy"), Pay = rpt.Pay1, Ac_id = rpt.Ac_id }) .ToList(); } else { bs.DataSource = db.Accounts .Select(rpt => new { Registration = rpt.Pat_id, Name1 = rpt.Name, RoomNumber1 = rpt.Number, Gender1 = rpt.Sex, Age1 = rpt.Age, Date1 = rpt.RDate, Pay1 = rpt.Pay, Ac_id = rpt.Ac_id }).Where(p1 => p1.Date1 >= dateTimePicker1.Value.Date && p1.Date1 <= dateTimePicker2.Value.Date) .OrderByDescending(d => d.Registration).ToList() .Select(rpt => new { Registration_No = rpt.Registration, Name = rpt.Name1, Room_Number = rpt.RoomNumber1, Gender = rpt.Gender1, Age = rpt.Age1, Date = DateTime.Parse(rpt.Date1.ToString()).ToString("dd-MMM-yyyy"), Pay = rpt.Pay1, Ac_id = rpt.Ac_id }) .Where(w => w.Name.Contains(textBox1.Text.ToUpper())).ToList(); } dataGridView1.DataSource = bs.DataSource; dataGridView1.Columns["Registration_No"].Width = 100; dataGridView1.Columns["Name"].Width = 150; dataGridView1.Columns["Room_Number"].Width = 110; dataGridView1.Columns["Gender"].Width = 100; dataGridView1.Columns["Age"].Width = 80; dataGridView1.Columns["Date"].Width = 100; dataGridView1.Columns["Pay"].Width = 100; label3.Text = dataGridView1.Rows.Count.ToString(); dataGridView1.Columns["Ac_id"].Visible = false; dataGridView1.Columns["print1"].DataGridView.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView1.Columns["print1"].DisplayIndex = dataGridView1.Columns.Count - 2 + 1; } }