private void frm_patient_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F3)
            {
                Button1_Click(sender, e);
            }
            else if (e.Alt && e.Control && e.KeyCode == Keys.A)
            {
                int randomno = RandomNumber(111111, 999999);
                //MessageBox.Show(randomno.ToString());
                WhatsApp.Send("Patient Id: " + patid + "\nDated: " + rdate + "\nOTP for Modification 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)
                {
                    TextBox1.Enabled = true;
                    // textBox4.Enabled = true;
                    TextBox1.TextBoxEnter();
                    TextBox1.Focus();

                    alter = true;
                }
            }

            if (e.KeyCode == Keys.Escape)
            {
                if (TextBox1.Text != "")
                {
                    DialogResult chk = MessageBox.Show("Are u sure?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                    if (chk == DialogResult.No)
                    {
                        e.Handled = false;
                    }
                    else
                    {
                        this.Dispose();
                    }
                }
                else
                {
                    this.Dispose();
                }
            }
        }
        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();
                }
            }
        }