protected void btnFoodAdd_Click(object sender, EventArgs e) { string fileName = Guid.NewGuid().ToString() + ".jpg"; foodPicUpload.SaveAs(Server.MapPath("~/pics/" + fileName)); var ifb = new iFoodBoxDataContext(); var addfoods = new foods(); addfoods.foodName = tbFoodName.Text; addfoods.foodType = rdofoodType.SelectedItem.Value.ToString(); addfoods.foodCount = int.Parse(tbFoodCount.Text); addfoods.foodPicPath = fileName; addfoods.foodDate = DateTime.Parse(tbFoodDate.Text); addfoods.foodDeadline = DateTime.Parse(tbFoodDeadline.Text); addfoods.foodalarmDay = int.Parse(cboSetFoodAlert.SelectedItem.Value); addfoods.foodFreezing = int.Parse(cboFoodPosition.SelectedItem.Value); addfoods.iFoodBoxID = 1; //chi 還沒寫 ifb.foods.InsertOnSubmit(addfoods); ifb.SubmitChanges(); Response.Redirect("ManageFood.aspx"); }
protected void btnInsert_Click(object sender, EventArgs e) { if (vadPassCheck.IsValid && vadAfterFour.IsValid) { //驗證帳號(信箱)是否已存在 var ifb = new iFoodBoxDataContext(); var uAccount = ifb.userAccounts.FirstOrDefault(m => txtAccount.Text.Equals(m.userAccount.ToString())); if (uAccount != null) { lblErrorMsgEmail.Visible = true; return; } //驗證電話是否已存在 ifb = new iFoodBoxDataContext(); var uData = ifb.userData.FirstOrDefault(m => txtPhone.Text.Equals(m.userPhone.ToString())); if (uData != null) { lblErrorMsgPhone.Visible = true; return; } //將基本資料存入 uData = new userData(); uData.userName = txtName.Text; uData.userDate = DateTime.Parse(txtDate.Text); if (rBtnM.Checked)//判斷性別 uData.userSex = true; else if (rBtnF.Checked) uData.userSex = false; else uData.userSex = true; uData.userAfterFour = txtAfterFour.Text; uData.userPhone = txtPhone.Text; ifb = new iFoodBoxDataContext(); ifb.userData.InsertOnSubmit(uData); ifb.SubmitChanges(); //取出userID ifb = new iFoodBoxDataContext(); var tableUserData = from x in ifb.userData where x.userPhone == txtPhone.Text select x; var userID = 0; foreach (userData ud in tableUserData) userID = ud.userID; //將帳號資訊存入 uAccount = new userAccounts(); uAccount.userAccount = txtAccount.Text; uAccount.userPassword = txtPassword.Text; uAccount.userID = userID; ifb = new iFoodBoxDataContext(); ifb.userAccounts.InsertOnSubmit(uAccount); ifb.SubmitChanges(); Response.Write(" <script language=JavaScript> alert('資料新增完畢!'); </script> "); Response.Redirect("LoginPage.aspx"); } }
protected void btnChangePass_Click(object sender, EventArgs e) { if (davCheckPassword.IsValid) { var ifb = new iFoodBoxDataContext(); var sessionAccount = new userAccounts(); sessionAccount = Session[CDkey.session_change_password] as userAccounts; var uAccount = ifb.userAccounts.FirstOrDefault(m => sessionAccount.accountID.Equals(m.accountID.ToString())); if (uAccount == null) return; uAccount.userPassword = txtPassword.Text; ifb.SubmitChanges(); Response.Write(" <script language=JavaScript> alert('密碼修改完畢!'); </script> "); } Response.Redirect("LoginPage.aspx"); }
protected void btnChangePass_Click(object sender, EventArgs e) { if (davCheckPassword.IsValid) { var ifb = new iFoodBoxDataContext(); var sessionAccount = new userAccounts(); sessionAccount = Session[CDkey.session_change_password] as userAccounts; var uAccount = ifb.userAccounts.FirstOrDefault(m => sessionAccount.accountID.Equals(m.accountID.ToString())); if (uAccount == null) { return; } uAccount.userPassword = txtPassword.Text; ifb.SubmitChanges(); Response.Write(" <script language=JavaScript> alert('密碼修改完畢!'); </script> "); } Response.Redirect("LoginPage.aspx"); }
protected void btnFoodAdd_Click(object sender, EventArgs e) { string fileName = Guid.NewGuid().ToString() + ".jpg"; foodPicUpload.SaveAs(Server.MapPath("~/pics/" + fileName)); var ifb = new iFoodBoxDataContext(); var addfoods = new foods(); addfoods.foodName = tbFoodName.Text; addfoods.foodType = rdofoodType.SelectedItem.Value.ToString(); addfoods.foodCount = int.Parse(tbFoodCount.Text); addfoods.foodPicPath = fileName; addfoods.foodDate = DateTime.Parse(tbFoodDate.Text); addfoods.foodDeadline = DateTime.Parse(tbFoodDeadline.Text); addfoods.foodalarmDay = int.Parse(cboSetFoodAlert.SelectedItem.Value); addfoods.foodFreezing = int.Parse(cboFoodPosition.SelectedItem.Value); addfoods.iFoodBoxID = 1; //chi 還沒寫 ifb.foods.InsertOnSubmit(addfoods); ifb.SubmitChanges(); Response.Redirect("ManageFood.aspx"); }
protected void btnInsert_Click(object sender, EventArgs e) { if (vadPassCheck.IsValid && vadAfterFour.IsValid) { //驗證帳號(信箱)是否已存在 var ifb = new iFoodBoxDataContext(); var uAccount = ifb.userAccounts.FirstOrDefault(m => txtAccount.Text.Equals(m.userAccount.ToString())); if (uAccount != null) { lblErrorMsgEmail.Visible = true; return; } //驗證電話是否已存在 ifb = new iFoodBoxDataContext(); var uData = ifb.userData.FirstOrDefault(m => txtPhone.Text.Equals(m.userPhone.ToString())); if (uData != null) { lblErrorMsgPhone.Visible = true; return; } //將基本資料存入 uData = new userData(); uData.userName = txtName.Text; uData.userDate = DateTime.Parse(txtDate.Text); if (rBtnM.Checked)//判斷性別 { uData.userSex = true; } else if (rBtnF.Checked) { uData.userSex = false; } else { uData.userSex = true; } uData.userAfterFour = txtAfterFour.Text; uData.userPhone = txtPhone.Text; ifb = new iFoodBoxDataContext(); ifb.userData.InsertOnSubmit(uData); ifb.SubmitChanges(); //取出userID ifb = new iFoodBoxDataContext(); var tableUserData = from x in ifb.userData where x.userPhone == txtPhone.Text select x; var userID = 0; foreach (userData ud in tableUserData) { userID = ud.userID; } //將帳號資訊存入 uAccount = new userAccounts(); uAccount.userAccount = txtAccount.Text; uAccount.userPassword = txtPassword.Text; uAccount.userID = userID; ifb = new iFoodBoxDataContext(); ifb.userAccounts.InsertOnSubmit(uAccount); ifb.SubmitChanges(); Response.Write(" <script language=JavaScript> alert('資料新增完畢!'); </script> "); Response.Redirect("LoginPage.aspx"); } }