public LogInInfo GetUserName(String name)
 {
     HomeoPathFramework db = new HomeoPathFramework();
     SqlCommand cmd = db.GetCommand("select * from User_Doctor where User_Name like '%" + name + "%'");
     LogInInfo ob = GetData(cmd);
     return ob;
 }
        public bool OldPatient(OldPatientInfo obj)
        {
            HomeoPathFramework ob = new HomeoPathFramework();
            SqlCommand cmd = ob.GetCommand("Update Patient_Medicine set Medicine_Name =@MedicineName,Amount=@Amount,Paid=@Paid,Have_To_Paid=@Have_To_Paid,Visit_Date=@Date where Patient_Id=@PatientId");
            SqlParameter p0 = new SqlParameter(@"PatientId", SqlDbType.Int);
            p0.Value = obj.PatientId;
            
            SqlParameter p1 = new SqlParameter(@"MedicineName", SqlDbType.VarChar, 50);
            p1.Value = obj.MedicineName;
            SqlParameter p2 = new SqlParameter(@"Amount", SqlDbType.Int);
            p2.Value = obj.Amount;
            SqlParameter p3 = new SqlParameter(@"Paid", SqlDbType.Int);
            p3.Value = obj.Paid;
            SqlParameter p4 = new SqlParameter(@"Have_To_Paid", SqlDbType.Int);
            p4.Value = obj.Have_To_Paid;
            cmd.Parameters.AddWithValue("@Date", DateTime.Now);
            cmd.Parameters.Add(p0);
            cmd.Parameters.Add(p4);
            cmd.Parameters.Add(p1);
            cmd.Parameters.Add(p2);
            cmd.Parameters.Add(p3);

            cmd.Connection.Open();

            int val = cmd.ExecuteNonQuery();
            cmd.Connection.Close();
            return val > 0;
        }
 public List<SearchInfo> GetPatientDetailsName(string name)
 {
     HomeoPathFramework da = new HomeoPathFramework();
     SqlCommand cmd = da.GetCommand("select * from  Patient_Medicine where  Patient_Name like '%" + name + "%'");
     List<SearchInfo> ob = GetData(cmd);
     return ob;
 }
 public List<SearchInfo> GetPatientDetails(int id) 
 {
     HomeoPathFramework da = new HomeoPathFramework();
     SqlCommand cmd = da.GetCommand("select * from  Patient_Medicine where  Patient_Id =" + id + "");
     List<SearchInfo> ob = GetData(cmd);
     return ob;
 }
 public bool NewPatient(NewPatientInfo obj)
 {
     HomeoPathFramework hf = new HomeoPathFramework();
     SqlCommand cmd = hf.GetCommand("insert into [dbo].[Patient_Medicine] ([Patient_Name],[Medicine_Name],[Amount],[Paid],[Have_To_Paid],[Visit_Date],[Symptoms])" + "values(@PatientName,@MedicineName,@Amount,@Paid,@Have_To_Paid,@Date,@symptom)");
     SqlParameter p = new SqlParameter(@"PatientName",SqlDbType.VarChar,50 );
     p.Value = obj.PatientName;
     SqlParameter p1 = new SqlParameter(@"MedicineName",SqlDbType.VarChar,50);
     p1.Value = obj.MedicineName;
     SqlParameter p2 = new SqlParameter(@"Amount", SqlDbType.Int);
     p2.Value = obj.Amount;
     SqlParameter p3 = new SqlParameter(@"Paid", SqlDbType.Int);
     p3.Value = obj.Paid;
     SqlParameter p4 = new SqlParameter(@"Have_To_Paid", SqlDbType.Int);
     p4.Value = obj.Have_To_Paid;
     cmd.Parameters.AddWithValue("@Date", DateTime.Now);
     SqlParameter p5 = new SqlParameter(@"symptom",SqlDbType.VarChar,50);
     p5.Value = obj.Symptom;
     cmd.Parameters.Add(p);
     cmd.Parameters.Add(p1);
     cmd.Parameters.Add(p2);
     cmd.Parameters.Add(p3);
     cmd.Parameters.Add(p4);
     cmd.Parameters.Add(p5);
     cmd.Connection.Open();
     int val = cmd.ExecuteNonQuery();
     cmd.Connection.Close();
     return val>0;
 }
          public TotalInfo  GetTotalIncome()
          {
              HomeoPathFramework da = new HomeoPathFramework();
              SqlCommand cmd = da.GetCommand("select SUM(Paid) from Patient_Medicine where CAST(Visit_Date as date)=@date");
              cmd.Parameters.AddWithValue("@date", DateTime.Now.Date);                
              TotalInfo ob=GetData(cmd);
              return ob;
 
          }
        public bool RemovePatient(int id)
        {
            HomeoPathFramework ob = new HomeoPathFramework();
            SqlCommand cmd = ob.GetCommand("delete from  [dbo].[Patient_Medicine] where Patient_Id=@Id");
            SqlParameter p = new SqlParameter(@"Id", SqlDbType.Int);
            p.Value = id;
            cmd.Parameters.Add(p);
            cmd.Connection.Open();
            int val = cmd.ExecuteNonQuery();
            cmd.Connection.Close();
            return val > 0;
            

        }
 public bool ChangePassword(string name, string password)
 {
     HomeoPathFramework da = new HomeoPathFramework();
     SqlCommand cmd = da.GetCommand("update [dbo].[User_Doctor] set User_Password=@password where User_Name=@name");
     SqlParameter p = new SqlParameter("@password", SqlDbType.VarChar, 50);
     p.Value = password;
     SqlParameter p1 = new SqlParameter("@name", SqlDbType.VarChar, 50);
     p1.Value = name; ;
     cmd.Parameters.Add(p);
     cmd.Parameters.Add(p1);
     cmd.Connection.Open();
     int val = cmd.ExecuteNonQuery();
     cmd.Connection.Close();
     return val > 0;
 }
        public bool Insert(RegistrationInfo obj)
        {
            HomeoPathFramework da = new HomeoPathFramework();
            SqlCommand cmd = da.GetCommand("insert into [dbo].[User_Doctor] ([User_Name],[User_Password])" + "values(@Name,@Password)");
            SqlParameter p = new SqlParameter("@Name", SqlDbType.VarChar, 50);
            p.Value = obj.UserName;
            SqlParameter p1 = new SqlParameter("@Password", SqlDbType.VarChar, 50);
            p1.Value = obj.Password;
          
            cmd.Parameters.Add(p);
            cmd.Parameters.Add(p1);
            
            cmd.Connection.Open();
            int val = cmd.ExecuteNonQuery();
            cmd.Connection.Close();
            return val > 0;

        }