Пример #1
0
        public ActionResult Edit(doctorModel ob)
        {
            SqlConnection con = new SqlConnection(constring);
            String        q   = "Update DoctorInfo set DoctorName = @name, Descriptions = @Description, speciality = @Speciality, chamber1 = @Chamber1, chamber2 = @Chamber2, chamber3 = @Chamber3, phone = @ContactNo, email = @Email where DoctorId = @id";

            con.Open();
            SqlCommand cmd = new SqlCommand(q, con);

            cmd.Parameters.AddWithValue("@id", ob.id);
            cmd.Parameters.AddWithValue("@name", ob.name);
            cmd.Parameters.AddWithValue("@Description", ob.name);
            cmd.Parameters.AddWithValue("@Speciality", ob.Speciality);
            cmd.Parameters.AddWithValue("@Chamber1", ob.Chamber1);
            cmd.Parameters.AddWithValue("@Chamber2", ob.Chamber2);
            cmd.Parameters.AddWithValue("@Chamber3", ob.Chamber3);
            cmd.Parameters.AddWithValue("@ContactNo", ob.ContactNo);
            cmd.Parameters.AddWithValue("@Email", ob.Email);



            cmd.ExecuteNonQuery();



            return(RedirectToAction("AdminDoctorInfo"));
        }
Пример #2
0
        //for showing image in edit page

        public ActionResult EditImg(int id)
        {
            SqlConnection con = new SqlConnection(constring);
            String        q   = "SELECT * from DoctorInfo where DoctorId=@id";

            con.Open();
            SqlCommand cmd = new SqlCommand(q, con);

            cmd.Parameters.AddWithValue("@id", id);

            cmd.ExecuteNonQuery();
            SqlDataAdapter adapter = new SqlDataAdapter(cmd);
            DataTable      dt      = new DataTable();

            adapter.Fill(dt);
            doctorModel ob = new doctorModel();

            if (dt.Rows.Count == 1)
            {
                ob.imgpath = dt.Rows[0][4].ToString();
            }

            ViewData["img"] = ob.imgpath;
            return(View(ob));
        }
Пример #3
0
        //for showing  info in edit page
        public ActionResult Edit(int id)
        {
            SqlConnection con = new SqlConnection(constring);
            String        q   = "SELECT * from DoctorInfo where DoctorId=@id";

            con.Open();
            SqlCommand cmd = new SqlCommand(q, con);

            cmd.Parameters.AddWithValue("@id", id);

            cmd.ExecuteNonQuery();
            SqlDataAdapter adapter = new SqlDataAdapter(cmd);
            DataTable      dt      = new DataTable();

            adapter.Fill(dt);
            doctorModel ob = new doctorModel();

            if (dt.Rows.Count == 1)
            {
                ob.id          = Convert.ToInt32(dt.Rows[0][0].ToString());
                ob.name        = dt.Rows[0][1].ToString();
                ob.Description = dt.Rows[0][2].ToString();
                ob.Speciality  = dt.Rows[0][3].ToString();
                ob.Chamber1    = dt.Rows[0][5].ToString();
                ob.Chamber2    = dt.Rows[0][6].ToString();
                ob.Chamber3    = dt.Rows[0][7].ToString();
                ob.ContactNo   = dt.Rows[0][8].ToString();
                ob.Email       = dt.Rows[0][9].ToString();
            }


            return(View(ob));
        }
Пример #4
0
        public ActionResult EditImg(doctorModel ob, HttpPostedFileBase file)
        {
            SqlConnection con = new SqlConnection(constring);
            String        q   = "Update DoctorInfo set  imgid=@imgid where DoctorId=@id";

            con.Open();
            SqlCommand cmd = new SqlCommand(q, con);

            cmd.Parameters.AddWithValue("@id", ob.id);


            if (file != null && file.ContentLength > 0)
            {
                string filename = Path.GetFileName(file.FileName);
                string imgpath  = Path.Combine(Server.MapPath("/doctorimages/"), filename);
                file.SaveAs(imgpath);
            }
            cmd.Parameters.AddWithValue("@imgid", "/doctorimages/" + file.FileName);

            ViewData["img"] = ob.imgpath;
            cmd.ExecuteNonQuery();
            return(RedirectToAction("AdminDoctorInfo"));
        }
Пример #5
0
        public ActionResult Create(doctorModel ob, categoryModel ob2, HttpPostedFileBase file)
        {
            SqlConnection con = new SqlConnection(constring);
            String        q   = "INSERT into DoctorInfo(DoctorName,Descriptions,Speciality,Imgid,Chamber1,Chamber2,Chamber3,Phone,Email) " +
                                "values(@name,@Description,@Speciality,@imgid,@Chamber1,@Chamber2,@Chamber3,@ContactNo,@Email)";

            SqlCommand cmd = new SqlCommand(q, con);

            con.Open();

            cmd.Parameters.AddWithValue("@name", ob.name);
            cmd.Parameters.AddWithValue("@Description", ob.Description);
            cmd.Parameters.AddWithValue("@Speciality", ob.Speciality);

            SqlParameter chamber1 = cmd.Parameters.AddWithValue("@Chamber1", ob.Chamber1);

            if (ob.Chamber1 == null)
            {
                chamber1.Value = "N/A";
            }
            SqlParameter chamber2 = cmd.Parameters.AddWithValue("@Chamber2", ob.Chamber2);

            if (ob.Chamber2 == null)
            {
                chamber2.Value = "N/A";
            }
            SqlParameter chamber3 = cmd.Parameters.AddWithValue("@Chamber3", ob.Chamber3);

            if (ob.Chamber3 == null)
            {
                chamber3.Value = "N/A";
            }
            cmd.Parameters.AddWithValue("@ContactNo", ob.ContactNo);
            cmd.Parameters.AddWithValue("@Email", ob.Email);

            if (file != null && file.ContentLength > 0)
            {
                string filename = Path.GetFileName(file.FileName);
                string imgpath  = Path.Combine(Server.MapPath("/doctorimages/"), filename);
                file.SaveAs(imgpath);
            }
            cmd.Parameters.AddWithValue("@imgid", "/doctorimages/" + file.FileName);



            cmd.ExecuteNonQuery();
            con.Close();

            String     q2   = "Select top 1 DoctorId from DoctorInfo order by DoctorId desc";
            SqlCommand cmd2 = new SqlCommand(q2, con);

            con.Open();
            int doctorid = Convert.ToInt32(cmd2.ExecuteScalar());


            cmd2.ExecuteNonQuery();
            con.Close();


            String q3 = "INSERT into Category(DoctorId,Category) " +
                        "values(@doctorid,@category)";

            SqlCommand cmd3 = new SqlCommand(q3, con);

            con.Open();

            cmd3.Parameters.AddWithValue("@doctorid", doctorid);
            cmd3.Parameters.AddWithValue("@category", ob2.category);
            cmd3.ExecuteNonQuery();
            con.Close();

            return(RedirectToAction("AdminDoctorInfo"));
        }
Пример #6
0
        //for creating a new record
        public ActionResult Create()
        {
            doctorModel ob = new doctorModel();

            return(View(ob));
        }