public void Load_Mer()
        {
            wizard1.SelectedTab     = tabPage4;
            tabControl1.SelectedTab = tabPage5;
            IniFile                 ini           = new IniFile(ClassSql.MMS_Path);
            R_Seabase_MER           R_SeabaseMER1 = new R_Seabase_MER();
            DataClasses2DataContext db            = new DataClasses2DataContext(Properties.Settings.Default.MyConString);
            DataTable               dt            = new ds_report2.sp_Seabase_Mer1_SubDataTable();
            var list  = db.sp_Seabase_Mer1_Sub(this.Tag.ToString()).ToList();
            var count = list.Count();

            foreach (var i in list)
            {
                dt.Rows.Add(i.lastname, i.firstname, i.middlename, i.address_1, i.position, i.marital_status, i.gender, i.birthdate, i.place_of_birth, i.employer, i.passport_no, i.seamansbook_no, i.nationality, i.religion, i.designation, i.picture.ToArray(), i.resultid, i.HEIGHT, i.WEIGHT, i.BP, i.PULSE, i.RESPIRATION, i.BODY_BUILD, i.FAR_OD_U, i.FAR_OD_C, i.FAR_OS_U, i.FAR_OS_C, i.NEAR_ODJ_U, i.NEAR_ODJ_C, i.NEAR_OSJ_U, i.NEAR_OSJ_C, i.ISHIHARA_U, i.ISHIHARA_C, i.HEARING_AD, i.HEARING_AS, i.CONVERSATIONAL_AS, i.HEARING_RIGHT, i.HEARING_LEFT, i.CLARITY_OF_SPEECH, i.BP_DIASTOLIC, i.RHYTHM, i.head_injury, i.frequent_headaches, i.frequent_dizziness, i.fainting_spells, i.insomnia, i.depression, i.trachoma, i.deafness, i.nose_throat_disorder, i.tuberculosis, i.other_lung_disorder, i.high_blood_pressure, i.heart_disease, i.rheumatic_fever, i.diabetes_mellitus, i.other_endocrine_disorder, i.cancer_tumor, i.blood_disorders, i.stomach_pain, i.other_abdominal_disorder, i.kidney_bladder_disorder, i.back_injury, i.genetic_hereditary, i.sexually_transmit_disease, i.asthma, i.allergies, i.gynecological_disorder, i.operations, i.operations_specify, i.schistosomiasis, i.last_menstrual_period, i.allergies_specify, i.other_abdominal_specify, i.column1, i.column2, i.column3, i.column4, i.column5, i.column6, i.column7, i.column7_comment, i.column8, i.column8_comment, i.column1_comment, i.column2_comment, i.column3_comment, i.column4_comment, i.column5_comment, i.column6_comment);
            }
            R_SeabaseMER1.SetDataSource(dt);
            TextObject FormNo = (TextObject)R_SeabaseMER1.ReportDefinition.ReportObjects["txt_formNo"];
            TextObject RevNo  = (TextObject)R_SeabaseMER1.ReportDefinition.ReportObjects["txt_RevNo"];
            TextObject Iso    = (TextObject)R_SeabaseMER1.ReportDefinition.ReportObjects["txt_iso"];

            FormNo.Text            = ini.IniReadValue("FORM", "Seafarer_MER");
            RevNo.Text             = ini.IniReadValue("REVISION", "Seafarer_MER");
            Iso.Text               = ini.IniReadValue("ISO", "Seafarer_MER");
            Viewer4_1.ReportSource = R_SeabaseMER1;
            RemoveTab(Viewer4_1);
        }
Esempio n. 2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            CheckBox cb = (CheckBox)GridView1.Rows[i].FindControl("Approve");
            if (cb.Checked == true)
            {
                string text1;
                int    projID;

                Label lb = (Label)GridView1.Rows[i].FindControl("Label1");
                text1  = lb.Text.ToString();
                projID = Convert.ToInt32(text1);

                DataClasses2DataContext dc = new DataClasses2DataContext();

                var Project = from q in dc.Projects
                              where
                              q.ProjectID == projID
                              select q;


                foreach (var Project1 in Project)
                {
                    Project1.Status = "approve";

                    // dc.Projects.InsertOnSubmit(Project1);
                    dc.SubmitChanges();
                }
            }
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["username"] != null && Session["admin"] != null && (int)Session["admin"] == 0)
     {
         try
         {
             DataClasses2DataContext dc = new DataClasses2DataContext();
             var query = from t1 in dc.exam_masters where t1.exam_id == (int)Session["exam_id"] select t1;
             if (query.Count() == 0)
             {
                 throw new Exception();
             }
             GridView1.DataSource = query;
             GridView1.DataBind();
         }
         catch (Exception ee)
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Something went wrong');window.location ='home.aspx';", true);
         }
     }
     else
     {
         ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Please login first');window.location ='login.aspx';", true);
     }
 }
Esempio n. 4
0
        private void frm_user_Load(object sender, EventArgs e)
        {
            db = new DataClasses2DataContext(Properties.Settings.Default.MyConString);
            LoadUserLevel();
            loaduser();

            //
        }
Esempio n. 5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            int flag = 0;
            DataClasses2DataContext dcd = new DataClasses2DataContext();
            var query = from t1 in dcd.user_masters where t1.username == TextBox1.Text select t1;

            if (query.Count() > 0)
            {
                flag        = 1;
                Label1.Text = "Username is already in use";
            }
            var query1 = from t1 in dcd.user_masters where t1.email == TextBox4.Text select t1;

            if (query1.Count() > 0)
            {
                flag        = 1;
                Label2.Text = "Email address is already in use";
            }

            if (flag == 0)
            {
                user_master us = new user_master();
                us.username     = TextBox1.Text;
                us.password     = Crypto.Hash(TextBox2.Text);
                us.email        = TextBox4.Text;
                us.sequrity_que = DropDownList1.SelectedItem.Text;
                us.sequrity_ans = TextBox5.Text;
                us.role_name    = "user";
                dcd.user_masters.InsertOnSubmit(us);
                try
                {
                    dcd.SubmitChanges();

                    //Random rndm = new Random();

                    MailMessage message = new MailMessage();
                    message.From = new MailAddress("*****@*****.**");
                    message.To.Add(new MailAddress(TextBox4.Text));
                    message.Subject    = "Welcome to ExamCenter";
                    message.Body       = "Your account created successfully.Test your self with different tests and improve your preparation for exams";
                    message.IsBodyHtml = true;

                    SmtpClient client = new SmtpClient();
                    client.Host = "smtp.gmail.com";
                    client.Port = 587;//Gmail port number
                    client.UseDefaultCredentials = true;
                    client.EnableSsl             = true;
                    client.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "nikhilkrishna");
                    client.Send(message);

                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Account created successfully!!login here');window.location ='login.aspx';", true);
                }
                catch (Exception ee)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('try again!');window.location ='createaccount.aspx';", true);
                }
            }
        }
        public static void InsertEventlist(List <Events> events)
        {
            using (var appDC = new DataClasses2DataContext())
            {
                appDC.Events.InsertAllOnSubmit(events.Select(c => c.ToTasteMakerEvent()));

                appDC.SubmitChanges();
            }
        }
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataClasses2DataContext dc = new DataClasses2DataContext();

            var query1 = from t2 in dc.exam_masters where t2.exam_type == DropDownList1.SelectedValue select t2.exam_name;

            DropDownList2.DataSource = query1;
            DropDownList2.DataBind();
        }
        public static void InsertGuestlist(List <GuestList> guestlists)
        {
            using (var appDC = new DataClasses2DataContext())
            {
                appDC.Guestlists.InsertAllOnSubmit(guestlists.Select(c => c.ToTasteMakerGuestList()));

                appDC.SubmitChanges();
            }
        }
        public static void InsertListings(List <Listings> listings)
        {
            using (var appDC = new DataClasses2DataContext())
            {
                appDC.Listings.InsertAllOnSubmit(listings.Select(e => e.ToTasteMakerListing()));

                appDC.SubmitChanges();
            }
        }
        protected void Button4_Click(object sender, EventArgs e)
        {
            DataClasses2DataContext dc = new DataClasses2DataContext();
            var query = from t1 in dc.exam_masters where t1.exam_name == Session["qname"].ToString() select t1;

            foreach (var i in query)
            {
                dc.exam_masters.DeleteOnSubmit(i);
            }
            dc.SubmitChanges();
            Response.Redirect("admin.aspx");
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            DataClasses2DataContext dc = new DataClasses2DataContext();
            var query = from t1 in dc.exam_masters where t1.exam_id == (int)Session["exam_id"] select t1.timelimit;

            foreach (var i in query)
            {
                Session["timelimit"] = i;
                //Response.Redirect("takeexam.aspx?exam_id=" + Request.QueryString["exam_id"] + "&timelimit=" +i);
                Response.Redirect("takeexam.aspx");
            }
        }
        protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataClasses2DataContext dc = new DataClasses2DataContext();
            var query = from t2 in dc.exam_masters where t2.exam_name == DropDownList2.SelectedItem.Text select t2.exam_id;

            foreach (var i in query)
            {
                Session["exam_id"] = i;
            }
            GridView1.DataBind();
            GridView2.DataBind();
        }
Esempio n. 13
0
        public void InsertUser(Login li)
        {
            DataClasses2DataContext db = new DataClasses2DataContext();
            register rs = new register();

            rs.rid          = li.rid;
            rs.rname        = li.rname;
            rs.remailid     = li.remailid;
            rs.Userpassword = li.Userpassword;
            db.registers.InsertOnSubmit(rs);
            db.SubmitChanges();
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            DataClasses2DataContext dc = new DataClasses2DataContext();
            var query = from t1 in dc.exam_masters where t1.exam_name == DropDownList2.SelectedValue select t1;

            foreach (var i in query)
            {
                Session["exam_id"] = i.exam_id;
                //Response.Redirect("startexam.aspx?exam_id=" + i.exam_id);
                Response.Redirect("startexam.aspx");
            }
        }
        protected void SqlDataSource2_Updated(object sender, SqlDataSourceStatusEventArgs e)
        {
            DataClasses2DataContext dc = new DataClasses2DataContext();
            update_exam             ue = new update_exam();

            ue.date        = System.DateTime.Now;
            ue.description = "updated";

            ue.exam_name = DropDownList2.SelectedValue;
            ue.username  = Session["username"].ToString();
            dc.update_exams.InsertOnSubmit(ue);
            dc.SubmitChanges();
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            List <String> lst = new List <string>();

            foreach (RepeaterItem item in Repeater1.Items)
            {
                int j;
                for (j = 1; j <= 4; j++)
                {
                    RadioButton rdb = (RadioButton)item.FindControl("RadioButton" + j);
                    if (rdb.Checked == true)
                    {
                        lst.Add(rdb.Text);
                        break;
                    }
                }
                if (j == 5)
                {
                    lst.Add("notselected");
                }
            }

            string[] useranswerarr = lst.ToArray();
            //GridView1.DataSource =lst;
            //GridView1.DataBind();
            DataClasses2DataContext dc = new DataClasses2DataContext();
            var query = from t1 in dc.question_masters where t1.exam_id == (int)Session["exam_id"] select t1;

            int i = 0;
            int right = 0, wrong = 0;

            foreach (var temp in query)
            {
                if (useranswerarr[i].Equals(temp.right_answer))
                {
                    right++;
                }
                else if (!useranswerarr[i].Equals("notselected"))
                {
                    wrong++;
                }
                i++;
            }
            // string exam_id =;
            Session["right"] = right;
            Session["wrong"] = wrong;

            string redirectstring = "result.aspx";

            Response.Redirect(redirectstring);
        }
Esempio n. 17
0
        public string searchk(Login li)
        {
            DataClasses2DataContext db = new DataClasses2DataContext();
            register rs      = new register();
            string   passout = "";
            // var pass = from m in db.registers where m.emailid == li.Emailid select m.userpassword;
            var pass = from m in db.registers where m.remailid == li.remailid select m.Userpassword;

            foreach (string query in pass)
            {
                passout = query;
            }
            return(passout);
        }
Esempio n. 18
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            db = new DataClasses2DataContext();
            var grade = db.TBL_GRADEs.FirstOrDefault(g => g.ST_CURRENTID.Equals(txtscid.Text) && g.SUBJECT_ID.Equals(Convert.ToInt32(txtsub.SelectedValue)) && g.GRADEPERIOD.Equals(txtgrper.Text));

            grade.GRADE = int.Parse(txtgrade.Text);
            db.SubmitChanges();
            MessageBox.Show("Successfully Update", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            StudentGrade_Load(this, null);
            btnViewStud.Enabled   = true;
            txtgrade.Text         = "";
            txtgrper.SelectedItem = null;
            txtsub.SelectedValue  = -1;
        }
Esempio n. 19
0
    protected void Submit_Click(object sender, EventArgs e)
    {
        DataClasses2DataContext db1 = new DataClasses2DataContext();

        Project newProject = new Project();


        newProject.Username    = Label1.Text;
        newProject.ProjectName = ProjName.Text;
        newProject.ProjectDesc = ProjDesc.Text;
        newProject.Status      = "created";
        db1.Projects.InsertOnSubmit(newProject);
        db1.SubmitChanges();
        Response.Redirect("Home.aspx");
    }
Esempio n. 20
0
        private void btnUpdatepass_Click(object sender, EventArgs e)
        {
            DataClasses2DataContext db = new DataClasses2DataContext();
            int count = 0;

            if (txtOldpass.Text == "" || txtNewpass.Text == "" || txtRetypepass.Text == "")
            {
                MessageBox.Show("Please input data", "Ooops !", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else
            {
                var scan = db.SP_VERIFYPASSWORD(int.Parse(txtUserID.Text), txtOldpass.Text);
                db.SubmitChanges();

                foreach (SP_VERIFYPASSWORDResult user in scan)
                {
                    count++;
                    if (txtNewpass.Text.Length >= 8)
                    {
                        if (txtNewpass.Text == txtRetypepass.Text)
                        {
                            user.USER_PASSWORD = txtNewpass.Text;
                            db.SP_CHANGEUSERPASS(lbluname.Text, user.USER_PASSWORD);
                            TBL_USER user2 = new TBL_USER();
                            MessageBox.Show("Password Successfully Changed", "Success !", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            //CLEAR TEXTBOXES
                            txtOldpass.Clear();
                            txtNewpass.Clear();
                            txtRetypepass.Clear();
                            groupChangePass.Visible = false;
                        }
                        else
                        {
                            MessageBox.Show("Password did not match", "Ooops !", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Password must be contain atleast 8 characters long ", "Ooops !", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                }
                if (count == 0)
                {
                    MessageBox.Show("Old password Incorrect", "Ooops !", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if ((Session["username"] == null) || (Session["admin"] != null && (int)Session["admin"] == 1))
     {
         ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Please login first');window.location ='login.aspx';", true);
     }
     if (!IsPostBack)
     {
         DataClasses2DataContext dc = new DataClasses2DataContext();
         var query = from t1 in dc.exam_masters group t1 by t1.exam_type into gr select gr.Key;
         DropDownList1.DataSource = query;
         DropDownList1.DataBind();
         var query1 = from t2 in dc.exam_masters where t2.exam_type == DropDownList1.SelectedValue select t2.exam_name;
         DropDownList2.DataSource = query1;
         DropDownList2.DataBind();
     }
 }
        //get cartype to send to app
        public List <string> GetCarType()
        {
            List <string> carTypeList = new List <string>();

            DataClasses2DataContext db = new DataClasses2DataContext();

            Table <Lst_LoaiXe> listLoaiXe = db.GetTable <Lst_LoaiXe>();
            var query = from cartype in listLoaiXe select cartype;

            //concate car type - number of seat
            foreach (var cartype in query)
            {
                carTypeList.Add(cartype.ten_loai_xe + " - " + cartype.so_ghe);
            }

            return(carTypeList);
        }
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            string email = "";

            try
            {
                var chars       = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
                var stringChars = new char[10];
                var random      = new Random();
                for (int i = 0; i < stringChars.Length; i++)
                {
                    stringChars[i] = chars[random.Next(chars.Length)];
                }
                var finalString            = new String(stringChars);
                DataClasses2DataContext dc = new DataClasses2DataContext();
                var qu = from t1 in dc.user_masters where t1.username == TextBox1.Text select t1;

                foreach (var i in qu)
                {
                    i.password = Crypto.Hash(finalString);
                    email      = i.email;
                    dc.SubmitChanges();
                }
                MailMessage message = new MailMessage();
                message.From = new MailAddress("*****@*****.**");
                message.To.Add(new MailAddress(email));
                message.Subject    = "New Password for your account";
                message.Body       = "Login with your new password.Username:"******" ,Password:"******"smtp.gmail.com";
                client.Port = 587;
                client.UseDefaultCredentials = true;
                client.EnableSsl             = true;
                client.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "nikhilkrishna");
                client.Send(message);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Email has been sent!Please login with new password...');window.location ='login.aspx';", true);
            }
            catch (Exception ee)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Something went wrong');window.location ='login.aspx';", true);
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            int exam_id = 0;

            try
            {
                DataClasses2DataContext dc = new DataClasses2DataContext();
                var query = from t1 in dc.exam_masters where t1.exam_name == DropDownList2.SelectedItem.Text select t1;

                foreach (var i in query)
                {
                    exam_id = i.exam_id;
                    dc.exam_masters.DeleteOnSubmit(i);
                }



                update_exam ue = new update_exam();
                ue.date        = System.DateTime.Now;
                ue.description = "deleted";

                ue.exam_name = DropDownList2.SelectedValue;
                ue.username  = Session["username"].ToString();
                dc.update_exams.InsertOnSubmit(ue);
                dc.SubmitChanges();



                dc.SubmitChanges();
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Questionpaper deleted successfully');window.location ='admin.aspx';", true);
                // var query1 = from t1 in dc.exam_masters group t1 by t1.exam_type into gr select gr.Key;
                // DropDownList1.DataSource = query1;
                // DropDownList1.DataBind();
                // var query2 = from t2 in dc.exam_masters where t2.exam_type == DropDownList1.SelectedValue select t2.exam_name;
                // DropDownList2.DataSource = query2;
                // DropDownList2.DataBind();
            }
            catch (Exception ee)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Something went wrong!try again!!');window.location ='admin.aspx';", true);
            }
        }
        //get info to send request to firebase server
        private void GetInfoFromDb(int status, int carID, int orderID)
        {
            DataClasses2DataContext db = new DataClasses2DataContext();
            //get car order from Lst_DatXe
            Table <Lst_DatXe> lst_datxe = db.GetTable <Lst_DatXe>();
            var queryOrder = from o in lst_datxe where o.id_dat_xe == orderID select o;
            var order      = queryOrder.FirstOrDefault();

            //get car information from Lst_Xe
            Table <Lst_Xe> lst_xe   = db.GetTable <Lst_Xe>();
            var            queryCar = from c in lst_xe where c.id_xe == carID select c;
            var            car      = queryCar.FirstOrDefault();

            //get driver's information from Lst_LaiXe
            Table <Lst_LaiXe> lst_laixe = db.GetTable <Lst_LaiXe>();
            var queryDriver             = from d in lst_laixe where d.id_lai_xe == car.id_lai_xe_chinh select d;
            var driver = queryDriver.FirstOrDefault();

            RequestFirebaseSendNoti(status, order, car, driver);
        }
        //handle request
        public string CarOrderRequestReceiver(Stream orderStream)
        {
            StreamReader reader          = new StreamReader(orderStream, Encoding.UTF8);
            string       carOrderRequest = reader.ReadToEnd();
            var          items           = carOrderRequest.Split(new[] { '&' }, StringSplitOptions.RemoveEmptyEntries)
                                           .Select(s => s.Split(new[] { '=' }));

            Dictionary <string, string> carOrder = new Dictionary <string, string>();

            foreach (var item in items)
            {
                carOrder.Add(item[0], item[1]);
            }

            using (DataClasses2DataContext db = new DataClasses2DataContext())
            {
                string response = saveRequestDataToDb(db, carOrder);
                return(response);
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            int flag = 0;
            DataClasses2DataContext dcd = new DataClasses2DataContext();
            var query = from t1 in dcd.user_masters where t1.username == TextBox1.Text select t1;

            if (query.Count() > 0)
            {
                flag        = 1;
                Label1.Text = "Username is already in use";
            }
            var query1 = from t1 in dcd.user_masters where t1.email == TextBox4.Text select t1;

            if (query1.Count() > 0)
            {
                flag        = 1;
                Label2.Text = "Email address is already in use";
            }

            if (flag == 0)
            {
                user_master us = new user_master();
                us.username     = TextBox1.Text;
                us.password     = Crypto.Hash(TextBox2.Text);
                us.email        = TextBox4.Text;
                us.sequrity_que = DropDownList1.SelectedItem.Text;
                us.sequrity_ans = TextBox5.Text;
                us.role_name    = "admin";
                dcd.user_masters.InsertOnSubmit(us);
                try
                {
                    dcd.SubmitChanges();
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Account created successfully!!login here');window.location ='login.aspx';", true);
                }
                catch (Exception ee)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('try again');window.location ='signupadmin.aspx';", true);
                }
            }
        }
Esempio n. 28
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            int flag = 0;
            DataClasses2DataContext dcd = new DataClasses2DataContext();
            var query = from t1 in dcd.exam_masters where t1.exam_name == TextBox2.Text select t1;

            if (query.Count() > 0)
            {
                flag        = 1;
                Label1.Text = "exam_name is already in use";
            }

            if (flag == 0)
            {
                exam_master em = new exam_master();

                em.exam_type     = TextBox1.Text;
                em.exam_name     = TextBox2.Text;
                em.exam_info     = TextBox3.Text;
                em.timelimit     = Int32.Parse(TextBox4.Text);
                em.marks_onright = Double.Parse(TextBox5.Text);
                em.marks_onwrong = Double.Parse(TextBox6.Text);
                em.total_que     = Int32.Parse(TextBox7.Text);
                dcd.exam_masters.InsertOnSubmit(em);
                try
                {
                    dcd.SubmitChanges();
                    Session["qname"] = TextBox2.Text;
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Add questions!!!!');window.location ='addquestions.aspx';", true);
                }
                catch (Exception ee)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Something went wrong!please try again!!!');window.location ='addqpaper.aspx';", true);
                }
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            DataClasses2DataContext cd = new DataClasses2DataContext();

            if (MultiView1.ActiveViewIndex == 0)
            {
                var query = from t1 in cd.user_masters
                            where t1.username == TextBox1.Text
                            select t1;
                if (query.Count() == 0)
                {
                    Label1.Text = "Enter valid username";
                }
                else
                {
                    var query1 = from t1 in cd.user_masters
                                 where t1.username == TextBox1.Text
                                 select t1;
                    foreach (var i in query1)
                    {
                        Label6.Text = i.sequrity_que;
                    }
                    MultiView1.ActiveViewIndex = 1;
                }
            }
            else if (MultiView1.ActiveViewIndex == 1)
            {
                var query1 = from t1 in cd.user_masters
                             where t1.username == TextBox1.Text
                             select t1;

                if (TextBox5.Text == null)
                {
                    Label2.Text = "enter answer";
                }
                else
                {
                    foreach (var i in query1)
                    {
                        if (TextBox5.Text == i.sequrity_ans)
                        {
                            MultiView1.ActiveViewIndex = 2;
                        }

                        if (TextBox5.Text != i.sequrity_ans && TextBox5.Text != "")
                        {
                            TextBox5.Text = "";
                            Label2.Text   = "enter right answer again";
                        }
                    }
                }
            }
            else if (MultiView1.ActiveViewIndex == 2)
            {
                user_master us = new user_master();
                if (TextBox3.Text == TextBox4.Text && TextBox3.Text != "" && TextBox4.Text != "")
                {
                    flag = 1;
                    var qu = from t1 in cd.user_masters where t1.username == TextBox1.Text select t1;

                    foreach (var i in qu)
                    {
                        i.password = Crypto.Hash(TextBox4.Text);
                        cd.SubmitChanges();
                    }
                }
                if (flag == 1)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Password chnaged successfully!please login again');window.location ='login.aspx';", true);
                }
            }
        }
        protected void Button3_Click(object sender, EventArgs e)
        {
            int flag = 0;

            for (int i = 1; i <= 6; i++)
            {
                if (((TextBox)form1.FindControl("TextBox" + (((((int)Session["totalque"]) - 1) * 6 + i)))).Text == "")
                {
                    flag = 1;
                }
            }

            if (flag == 1)
            {
                Label2.Text = "*all fileds required!!";
            }
            else
            {
                Label2.Text = "";
                //Label1.Text = (MultiView1.ActiveViewIndex + 2).ToString() + "/" + Session["totalque"];
                //MultiView1.ActiveViewIndex = MultiView1.ActiveViewIndex + 1;

                int    exam_id = 0, temp;
                String strtemp;
                DataClasses2DataContext dc = new DataClasses2DataContext();
                var query = from t1 in dc.exam_masters where t1.exam_name == Session["qname"].ToString() select t1.exam_id;
                foreach (var i in query)
                {
                    exam_id = i;
                }
                for (int i = 1; i <= (int)Session["totalque"]; i++)
                {
                    question_master qm = new question_master();
                    qm.que_id  = i;
                    qm.exam_id = exam_id;

                    temp    = (i - 1) * 6 + 1;
                    strtemp = "Textbox" + temp;
                    qm.que  = ((TextBox)form1.FindControl(strtemp)).Text;

                    temp    = (i - 1) * 6 + 2;
                    strtemp = "Textbox" + temp;
                    qm.op1  = ((TextBox)form1.FindControl(strtemp)).Text;

                    temp    = (i - 1) * 6 + 3;
                    strtemp = "Textbox" + temp;
                    qm.op2  = ((TextBox)form1.FindControl(strtemp)).Text;

                    temp    = (i - 1) * 6 + 4;
                    strtemp = "Textbox" + temp;
                    qm.op3  = ((TextBox)form1.FindControl(strtemp)).Text;

                    temp    = (i - 1) * 6 + 5;
                    strtemp = "Textbox" + temp;
                    qm.op4  = ((TextBox)form1.FindControl(strtemp)).Text;

                    temp            = (i - 1) * 6 + 6;
                    strtemp         = "Textbox" + temp;
                    qm.right_answer = ((TextBox)form1.FindControl(strtemp)).Text;
                    dc.question_masters.InsertOnSubmit(qm);
                }

                try
                {
                    dc.SubmitChanges();
                    update_exam ue = new update_exam();
                    ue.date        = System.DateTime.Now;
                    ue.description = "added";

                    ue.exam_name = Session["qname"].ToString();
                    ue.username  = Session["username"].ToString();
                    dc.update_exams.InsertOnSubmit(ue);
                    dc.SubmitChanges();
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Questionpaper with questions added Successfully!!!');window.location ='admin.aspx';", true);
                }
                catch (Exception ee)
                {
                    var query1 = from t1 in dc.exam_masters where t1.exam_name == Session["qname"].ToString() select t1;

                    foreach (var i in query1)
                    {
                        dc.exam_masters.DeleteOnSubmit(i);
                    }

                    dc.SubmitChanges();
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Something went wrong!please try again!!!');window.location ='admin.aspx';", true);
                }
            }
        }