本文整理汇总了C#中Student.UpdateToDB方法的典型用法代码示例。如果您正苦于以下问题:C# Student.UpdateToDB方法的具体用法?C# Student.UpdateToDB怎么用?C# Student.UpdateToDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Student
的用法示例。
在下文中一共展示了Student.UpdateToDB方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoEditSubmitStudent
protected void DoEditSubmitStudent(string studentID)
{
Student t = new Student();
// validate data
t._studentID = Int32.Parse(studentID);
t._firstname = Request["firstname"];
t._surname = Request["surname"];
t._nickname = Request["nickname"];
t._citizenID = Request["citizen_id"];
t._sex = Request["sex"];
t._tel = Request["tel1"] + Request["tel2"] + Request["tel3"];
t._tel2 = Request["tel21"] + Request["tel22"] + Request["tel23"];
t._email = Request["email"];
t._addr = Request["addr"];
t._school = Request["school"];
t._level = Int32.Parse(Request["level"]);
t._quiz = Student.EncodeQuizText(Page.Request);
if (Request["birthday"] != null)
{
string[] s = Request["birthday"].Split('/');
t._birthday = new DateTime(Int32.Parse(s[2]) - 543, Int32.Parse(s[1]), Int32.Parse(s[0]));
}
else
{
t._birthday = new DateTime();
}
// default to old value
t._img = Request["img_old"];
if (portrait.PostedFile.FileName != "")
{
try
{
string serverFileExt = Path.GetExtension(portrait.PostedFile.FileName);
Random rand = new Random((int)DateTime.Now.Ticks);
string fullpath = "";
string imgname = "";
do
{
string randomFName = rand.Next(Int32.MaxValue).ToString();
imgname = randomFName + serverFileExt;
fullpath = Config.PATH_APP_ROOT + "\\" + Config.URL_PIC_STUDENT + "\\" + imgname;
} while (File.Exists(fullpath));
portrait.PostedFile.SaveAs(fullpath);
t._img = imgname;
}
catch (Exception err)
{
errorText = err.Message + err.StackTrace;
}
}
// Save to DB
DBManager db = new MySQLDBManager(Config.DB_SERVER, Config.DB_NAME, Config.DB_USER, Config.DB_PASSWORD, Config.DB_CHAR_ENC);
db.Connect();
t.UpdateToDB(db);
db.Close();
}