コード例 #1
0
        protected void Btn_Submit_Click(object sender, EventArgs e)
        {
            getcon();
            if (Txt_Mobile.Text == "")
            {
                Txt_Mobile.Text = "0";
            }
            if (RBL_Gender.SelectedItem.Text == "Male" && RBL_Marital.SelectedItem.Text == "Married")
            {
                string       password;
                password_gen pg = new password_gen();
                password = pg.CreateRandomPassword(6);
                string     str = "insert into tbl_registration values('" + Convert.ToInt32(DropDown_Group.SelectedItem.Value) + "','" + Convert.ToInt32(DropDown_Family_Head.SelectedItem.Value) + "','" + Convert.ToInt32(DropDown_Relationship.SelectedItem.Value) + "','" + Txt_Fname.Text.Trim() + "','" + Txt_Lname.Text.Trim() + "','" + Txt_Nick.Text.Trim() + "','" + RBL_Gender.SelectedItem.Text + "','" + RBL_Marital.SelectedItem.Text + "','" + Txt_DOB.Text.Trim() + "','" + Txt_Profession.Text.Trim() + "','" + Convert.ToInt32(DropDown_BldGrp.SelectedItem.Value) + "','" + Txt_Address.Text.Trim() + "','" + Convert.ToInt32(DropDown_District.SelectedItem.Value) + "','" + Convert.ToInt32(Txt_Pin.Text.Trim()) + "','" + Txt_Home.Text.Trim() + "','" + Txt_Mobile.Text.Trim() + "','" + Txt_Email.Text.Trim() + "','" + Txt_WriteUp.Text.Trim() + "','Approved');select @@identity";
                SqlCommand cmd = new SqlCommand(str, con);
                object     obj = new object();
                obj = cmd.ExecuteScalar();
                string     str1 = "insert into tbl_login values('" + Txt_Email.Text.Trim() + "','" + password + "','2','" + Convert.ToInt32(obj) + "')";
                SqlCommand cmd1 = new SqlCommand(str1, con);
                cmd1.ExecuteNonQuery();
            }
            else
            {
                string     str = "insert into tbl_registration values('" + Convert.ToInt32(DropDown_Group.SelectedItem.Value) + "','" + Convert.ToInt32(DropDown_Family_Head.SelectedItem.Value) + "','" + Convert.ToInt32(DropDown_Relationship.SelectedItem.Value) + "','" + Txt_Fname.Text.Trim() + "','" + Txt_Lname.Text.Trim() + "','" + Txt_Nick.Text.Trim() + "','" + RBL_Gender.SelectedItem.Text + "','" + RBL_Marital.SelectedItem.Text + "','" + Txt_DOB.Text.Trim() + "','" + Txt_Profession.Text.Trim() + "','" + Convert.ToInt32(DropDown_BldGrp.SelectedItem.Value) + "','" + Txt_Address.Text.Trim() + "','" + Convert.ToInt32(DropDown_District.SelectedItem.Value) + "','" + Convert.ToInt32(Txt_Pin.Text.Trim()) + "','" + Txt_Home.Text.Trim() + "','" + Txt_Mobile.Text.Trim() + "','" + Txt_Email.Text.Trim() + "','" + Txt_WriteUp.Text.Trim() + "','OnRequest')";
                SqlCommand cmd = new SqlCommand(str, con);
                cmd.ExecuteNonQuery();
            }

            con.Close();
        }
コード例 #2
0
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            getcon();
            string         email, password;
            LinkButton     lb   = (LinkButton)sender;
            GridViewRow    gr   = lb.NamingContainer as GridViewRow;
            int            dk   = (Convert.ToInt32(GridView1.DataKeys[gr.RowIndex].Values[0].ToString()));
            string         strr = "select tbl_registration.registration_email from tbl_registration where registration_id='" + dk + "'";
            SqlCommand     cmd  = new SqlCommand(strr, con);
            SqlDataAdapter ad   = new SqlDataAdapter(cmd);
            DataTable      dt   = new DataTable();

            ad.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                email = dt.Rows[0][0].ToString();
                password_gen pg = new password_gen();
                password = pg.CreateRandomPassword(6);
                string     str  = "insert into tbl_login values('" + email + "','" + password + "','3','" + dk + "')";
                SqlCommand cmd1 = new SqlCommand(str, con);
                cmd1.ExecuteNonQuery();
            }
            string     str3 = "update tbl_registration set registration_status='Approved' where registration_id='" + dk + "'";
            SqlCommand cmdd = new SqlCommand(str3, con);

            cmdd.ExecuteNonQuery();
            string         str1  = "select tbl_registration.registration_id,tbl_registration.registration_fname,tbl_registration.registration_lname,tbl_group.group_name,tbl_relationship.relationship_type from tbl_registration inner join tbl_group on tbl_group.group_id = tbl_registration.group_id inner join tbl_relationship on tbl_relationship.relationship_id = tbl_registration.relationship_id where tbl_registration.registration_status='onRequest'and tbl_group.group_id='" + DropDown_Group.SelectedItem.Value + "'";
            SqlCommand     cmdd1 = new SqlCommand(str1, con);
            SqlDataAdapter ad1   = new SqlDataAdapter(cmdd1);
            DataTable      dtt   = new DataTable();

            ad1.Fill(dtt);
            if (dtt.Rows.Count > 0)
            {
                GridView1.DataSource = dtt;
                GridView1.DataBind();
            }

            con.Close();
        }