Team: Add tutors in batches

Source: Internet
Author: User

For (I = 1; I <8; I ++) // We only pull 8 fileupload.
{

Fileupload Fu = (fileupload) panel1.findcontrol (string. Format ("fileupload {0}", I ));
Textbox textboxa = (textbox) panel1.findcontrol (string. Format ("textbox {0}", I ));

If (Fu. postedfile. contentlength <2048000)
{

String Path = httpcontext. Current. Request. mappath ("../picture/phone /");
// Check whether there are any pending cases
If (Fu. hasfile)
{

// If (isallowedextension (Fu) = true)
//{
Try
{
// Save the case to your specified position
Fu. saveas (path + Fu. filename );

String wpath = "picture/phone/" + Fu. filename;
Paras2 [0]. value = strpid;
Paras2 [1]. value = dropphonetype. selectedvalue;
Paras2 [2]. value = wpath;
Paras2 [3]. value = textboxa. text;
String sqlb = sql2.tostring ();
Sqlhelper. executenonquery (St, commandtype. Text, sqlb, paras2); // Add data cyclically
}

'Add mentors cyclically
For I as integer = 1 to 3
Dim stra as string = "lblnamchn" & I. tostring
Dim strb as string = "txtempno" & I. tostring
Dim textboxa as textbox = ctype (Me. findcontrol (stra), textbox)
Dim textboxb as textbox = ctype (Me. findcontrol (strb), textbox)
If textboxa. Text. Trim <> "then
Strsql = "insert into tutor (tutor_type, tutor_emp_id, tutor_name, crs_num, cls_num, crt_user, crt_datetime) values ("
Strsql & = "'" & replacestring (seltutortype. selectedvalue )&"',"
Strsql & = "'" & replacestring (textboxb. Text. Trim )&"',"
Strsql & = "'" & replacestring (textboxa. Text. Trim )&"',"
Strsql & = "'" & replacestring (lstcrsnum. selectedvalue )&"',"
Strsql & = "'" & replacestring (txtclsnum. Text. Trim )&"',"
Strsql & = "'" & SESSION ("userid ")&"',"
Strsql & = "'" & format (now (), "yyyy/mm/dd hh: mm: SS ")&"')"
Clsdbprocess. executesql (Session ("server"), Session ("Database"), strsql)
End if
Next

For I = 0 to count-1 'modify and delete cyclically
Dim Rec (I) as string
If isdbnull (Ds. Tables (0). Rows (I) (0) then
Rec (I) = ""
Else
Rec (I) = Ds. Tables (0). Rows (I) (0). tostring
End if
'Rec (I) = IIF (Ds. tables (0 ). rows (I) (0) is dbnull. value, "", DS. tables (0 ). rows (I) (0 ))
'Msgbox. Text = Rec (I) & "& request. querystring (" strclassnum ")
Dim J as integer = I + 1
Dim strx as string = "lblnamchn" & J. tostring
Dim stry as string = "txtempno" & J. tostring
Dim textboxx as textbox = ctype (Me. findcontrol (strx), textbox)
Dim textboxy as textbox = ctype (Me. findcontrol (stry), textbox)
If textboxx. Text. Trim <> "then
If rec (I) <> "then
'If rec1 has a value, modify the table
Strsql = "Update tutor set"
Strsql & = "tutor_type = '" & replacestring (seltutortype. selectedvalue )&"',"
Strsql & = "tutor_emp_id = '" & replacestring (textboxy. Text. Trim )&"',"
Strsql & = "tutor_name = '" & replacestring (textboxx. Text. Trim )&"',"
Strsql & = "crs_num = '" & replacestring (lstcrsnum. selectedvalue )&"',"
Strsql & = "chg_user = '" & SESSION ("userid ")&"',"
Strsql & = "chg_datetime = '" & format (now (), "yyyy-mm-dd hh: mm: SS ")&"'"
Strsql & = "where rec_id = '" & Rec (I )&"'"
Clsdbprocess. executesql (Session ("server"), Session ("Database"), strsql)
End if
End if
If textboxx. Text. Trim = "" then', if the class has other users, but the textbox information is empty, the number of users will be deleted.
If rec (I) <> "then
Strsql = "delete from tutor Where rec_id = '" & Rec (I )&"'"
Clsdbprocess. executesql (Session ("server"), Session ("Database"), strsql)
End if
End if
Next
'Add a mentor cyclically. 'For example, if there is a mentor and the second and third lblnamchn are not empty, add a mentor.
For K as integer = count + 1 to 3
Dim stra as string = "lblnamchn" & K. tostring
Dim strb as string = "txtempno" & K. tostring
Dim textboxa as textbox = ctype (Me. findcontrol (stra), textbox)
Dim textboxb as textbox = ctype (Me. findcontrol (strb), textbox)
If textboxa. Text. Trim <> "then
Strsql = "insert into tutor (tutor_type, tutor_emp_id, tutor_name, crs_num, cls_num, crt_user, crt_datetime) values ("
Strsql & = "'" & replacestring (seltutortype. selectedvalue )&"',"
Strsql & = "'" & replacestring (textboxb. Text. Trim )&"',"
Strsql & = "'" & replacestring (textboxa. Text. Trim )&"',"
Strsql & = "'" & replacestring (lstcrsnum. selectedvalue )&"',"
Strsql & = "'" & replacestring (txtclsnum. Text. Trim )&"',"
Strsql & = "'" & SESSION ("userid ")&"',"
Strsql & = "'" & format (now (), "yyyy/mm/dd hh: mm: SS ")&"')"
Clsdbprocess. executesql (Session ("server"), Session ("Database"), strsql)
End if
Next

Alert ("modified successfully ")

// Add a mentor cyclically
{
For (INT I = 1; I <= 3; I ++ ){
String stra = "lblnamchn" + I. tostring;
String strb = "txtempno" + I. tostring;
Textbox textboxa = (textbox) This. findcontrol (stra );
Textbox textboxb = (textbox) This. findcontrol (strb );
If (! String. isnullorempty (textboxa. Text. Trim )){
Strsql = "insert into tutor (tutor_type, tutor_emp_id, tutor_name, crs_num, cls_num, crt_user, crt_datetime) values (";
Strsql + = "'" + replacestring (seltutortype. selectedvalue) + "',";
Strsql + = "'" + replacestring (textboxb. Text. Trim) + "',";
Strsql + = "'" + replacestring (textboxa. Text. Trim) + "',";
Strsql + = "'" + replacestring (lstcrsnum. selectedvalue) + "',";
Strsql + = "'" + replacestring (txtclsnum. Text. Trim) + "',";
Strsql + = "'" + SESSION ("userid") + "',";
Strsql + = "'" + strings. Format (now (), "yyyy/mm/dd hh: mm: SS") + "')";
Clsdbprocess. executesql (Session ("server"), Session ("Database"), strsql );
}
}

For (I = 0; I <= count-1; I ++ ){
// Cyclically modify and delete
String [] rec = new string [I + 1];
If (Ds. Tables (0). Rows (I) (0) = system. dbnull. Value ){
Rec (I) = "";
}
Else {
Rec (I) = Ds. Tables (0). Rows (I) (0). tostring;
}
// Rec (I) = IIF (Ds. tables (0 ). rows (I) (0) is dbnull. value, "", DS. tables (0 ). rows (I) (0 ))
// Msgbox. Text = Rec (I) & "& request. querystring (" strclassnum ")
Int J = I + 1;
String strx = "lblnamchn" + J. tostring;
String stry = "txtempno" + J. tostring;
Textbox textboxx = (textbox) This. findcontrol (strx );
Textbox textboxy = (textbox) This. findcontrol (stry );
If (! String. isnullorempty (textboxx. Text. Trim )){
If (! String. isnullorempty (Rec (I ))){
// If rec1 has a value, modify the table
Strsql = "Update tutor set ";
Strsql + = "tutor_type = '" + replacestring (seltutortype. selectedvalue) + "',";
Strsql + = "tutor_emp_id = '" + replacestring (textboxy. Text. Trim) + "',";
Strsql + = "tutor_name = '" + replacestring (textboxx. Text. Trim) + "',";
Strsql + = "crs_num = '" + replacestring (lstcrsnum. selectedvalue) + "',";
Strsql + = "chg_user = '" + SESSION ("userid") + "',";
Strsql + = "chg_datetime = '" + strings. Format (now (), "yyyy-mm-dd hh: mm: SS") + "'";
Strsql + = "where rec_id = '" + Rec (I) + "'";
Clsdbprocess. executesql (Session ("server"), Session ("Database"), strsql );
}
}
If (string. isnullorempty (textboxx. Text. Trim )){
// If the class has a cursor, but the textbox information is empty, the cursor is deleted.
If (! String. isnullorempty (Rec (I ))){
Strsql = "delete from tutor Where rec_id = '" + Rec (I) + "'";
Clsdbprocess. executesql (Session ("server"), Session ("Database"), strsql );
}
}
}
// Add a mentor cyclically. For example, if there is a mentor and the second and third lblnamchn are not empty, add a mentor.
For (int K = count + 1; k <= 3; k ++ ){
String stra = "lblnamchn" + K. tostring;
String strb = "txtempno" + K. tostring;
Textbox textboxa = (textbox) This. findcontrol (stra );
Textbox textboxb = (textbox) This. findcontrol (strb );
If (! String. isnullorempty (textboxa. Text. Trim )){
Strsql = "insert into tutor (tutor_type, tutor_emp_id, tutor_name, crs_num, cls_num, crt_user, crt_datetime) values (";
Strsql + = "'" + replacestring (seltutortype. selectedvalue) + "',";
Strsql + = "'" + replacestring (textboxb. Text. Trim) + "',";
Strsql + = "'" + replacestring (textboxa. Text. Trim) + "',";
Strsql + = "'" + replacestring (lstcrsnum. selectedvalue) + "',";
Strsql + = "'" + replacestring (txtclsnum. Text. Trim) + "',";
Strsql + = "'" + SESSION ("userid") + "',";
Strsql + = "'" + strings. Format (now (), "yyyy/mm/dd hh: mm: SS") + "')";
Clsdbprocess. executesql (Session ("server"), Session ("Database"), strsql );
}
}

Alert ("modified successfully ");
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.