public ActionResult Modify(string oldPassword, string newPassword, string confirmPassword) { UserInfo user = Commom.ReadUserInfo(); string strError = string.Empty; user.PassWord = Common.Basic_Func.JiaMi(oldPassword); User_Func func = new User_Func(); if (!func.UserLogin(ref user, ref strError)) { ViewData["errorMsg"] = "原始密码不正确!"; return(View("ModifyPassword")); } user.IsChangePwd = true; user.PassWord = Common.Basic_Func.JiaMi(newPassword); user.RePassword = Common.Basic_Func.JiaMi(confirmPassword); if (!func.ChangeUserPassword(user, ref strError)) { // 数据有误 ViewData["errorMsg"] = "修改密码失败:" + strError; return(View("ModifyPassword")); } else { // 数据有误 ViewData["errorMsg"] = "修改成功退出重新登陆!"; return(View("ModifyPassword")); } }
protected void Buy_Click(object sender, EventArgs e) { SqlConnection Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OnlineCourseConnectionString"].ConnectionString); try { string sql = "select UserName,Cash from Users where UserName='******'"; Conn.Open(); SqlDataAdapter da = new SqlDataAdapter(sql, Conn); DataSet ds = new DataSet(); da.Fill(ds, "用户表"); DataRowView drv = ds.Tables["用户表"].DefaultView[0]; string Price = Convert.ToString(drv.Row["Cash"]); if (Convert.ToDouble(Price) < Convert.ToDouble(Sum.Text.Trim())) { Response.Write("<script>alert('您的余额不足,请重新充值后再购买!');</script>"); } else { string sql1 = "update Users set Cash='" + (Convert.ToDouble(Price) - Convert.ToDouble(Sum.Text)) + "'where UserName='******'"; SqlCommand Comm = new SqlCommand(sql1, Conn); Comm.ExecuteNonQuery(); string sql3 = "UPDATE Orders SET IsPaid=1, OrderTime=Getdate() WHERE UserID={0} AND IsPaid=0"; sql3 = string.Format(sql3, Session["UserID"]); SqlCommand com = new SqlCommand(sql3, Conn); com.ExecuteNonQuery(); for (int i = 0; i < GridView1.Rows.Count; i++) { sql = "UPDATE Classes SET Num = Num + 1 WHERE ClassID={0}"; sql = string.Format(sql, ((HiddenField)GridView1.Rows[i].FindControl("ClassID")).Value); com = new SqlCommand(sql, Conn); com.ExecuteNonQuery(); sql = "INSERT INTO MyClasses (ClassID, UserID) VALUES ({0}, {1})"; sql = string.Format(sql, ((HiddenField)GridView1.Rows[i].FindControl("ClassID")).Value, Session["UserID"]); com = new SqlCommand(sql, Conn); com.ExecuteNonQuery(); } sql = "INSERT INTO Orders(UserID) VALUES('{0}')"; sql = string.Format(sql, Session["UserID"]); com = new SqlCommand(sql, Conn); com.ExecuteNonQuery(); sql = "SELECT OrderID FROM Orders WHERE IsPaid=0 AND UserID='" + Session["UserID"] + "'"; com = new SqlCommand(sql, Conn); Session["ShoppingID"] = com.ExecuteScalar().ToString(); GetShopping(); Response.Write("<script>alert('支付成功!');</script>"); } } catch (Exception ex) { Commom commom = new Commom(); commom.ShowErrorPage(Response, Server.UrlEncode(ex.Message), Server.UrlEncode(ex.StackTrace), false); } finally { Conn.Close(); } }
protected void GetShopping() { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OnlineCourseConnectionString"].ConnectionString); try { conn.Open(); string selectSql = "SELECT * FROM ShoppingView WHERE UserID={0}"; selectSql = string.Format(selectSql, Session["UserID"].ToString()); SqlDataAdapter da = new SqlDataAdapter(selectSql, conn); DataSet ds = new DataSet(); da.Fill(ds, "Shopping"); GridView1.DataSource = ds; GridView1.DataBind(); } catch (Exception ex) { Commom commom = new Commom(); commom.ShowErrorPage(Response, Server.UrlEncode(ex.Message), Server.UrlEncode(ex.StackTrace), false); } finally { conn.Close(); } }
protected void Search_Click(object sender, EventArgs e) { if (SearchBook.Text != "") { SqlConnection con = new SqlConnection("Server=localhost;Initial Catalog=OnlineCourse;Integrated Security=True;"); try { con.Open(); string sql = "select Classes.ClassID as ClassID,ClassName,ClassImg,Price,Classes.TypeID,TypeName,Num " + "from Classes,ClassType where ClassName like '%{0}%' and Classes.TypeID=ClassType.TypeID"; sql = string.Format(sql, SearchBook.Text); SqlCommand com = new SqlCommand(sql, con); SqlDataReader res = com.ExecuteReader(); SearchList.DataSource = res; SearchList.DataBind(); } catch (Exception ex) { Commom commom = new Commom(); commom.ShowErrorPage(Response, Server.UrlEncode(ex.Message), Server.UrlEncode(ex.StackTrace), false); } finally { con.Close(); } } }
/* Lấy dữ liệu từ DB đổ lên List */ void getData() { listWallets = new List <CSoNo>(); float sum_cho_vay = 0, sum_di_vay = 0; string query = @"SELECT NguoiQuen.ten_nguoi_quen, LoaiGiaoDich.ten_loai_gd , SUM(GiaoDichTaiChinh.so_tien) , COUNT(*) FROM GiaoDichTaiChinh, TaiKhoan, VI, NguoiQuen, LoaiGiaoDich WHERE TaiKhoan.taikhoan = VI.taikhoan AND TaiKhoan.taikhoan = NguoiQuen.taikhoan AND GiaoDichTaiChinh.ma_vi = VI.ma_vi AND GiaoDichTaiChinh.ma_nguoi_quen = NguoiQuen.ma_nguoi_quen AND GiaoDichTaiChinh.ma_loai_gd = LoaiGiaoDich.ma_loai_gd AND TaiKhoan.taikhoan = '" + IdUser + "'" + "AND(LoaiGiaoDich.ten_loai_gd = N'Đi vay' OR LoaiGiaoDich.ten_loai_gd = N'Cho vay')" + "AND NguoiQuen.ma_nguoi_quen != " + Commom.clone_nguoi_quen + ""; if (timeEnd == string.Empty && timeStart != string.Empty) { query += " AND GiaoDichTaiChinh.thoi_gian = '" + timeStart + "'"; } else if (timeEnd != string.Empty && timeStart != string.Empty) { query += " AND GiaoDichTaiChinh.thoi_gian >= '" + timeStart + "' AND GiaoDichTaiChinh.thoi_gian <= '" + timeEnd + "'"; } if (IDWallets != string.Empty) { query += " AND VI.ma_vi = " + IDWallets + ""; } query += " GROUP BY NguoiQuen.ten_nguoi_quen, LoaiGiaoDich.ten_loai_gd"; DB.conn.Open(); SqlCommand cmd = new SqlCommand(query, DB.conn); SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { CSoNo owe = new CSoNo(rd[0].ToString(), rd[1].ToString(), rd[2].ToString(), rd[3].ToString()); listWallets.Add(owe); if (owe.LoaiNhanTra == "Đi vay") { sum_di_vay += float.Parse(owe.SoTien); } else if (owe.LoaiNhanTra == "Cho vay") { sum_cho_vay += float.Parse(owe.SoTien); } } DB.conn.Close(); lbChoVay.Text = Commom.getMoneyStr(sum_cho_vay.ToString()); lbNo.Text = Commom.getMoneyStr(sum_di_vay.ToString()); }
/// <summary> /// 新增 /// </summary> /// <returns></returns> public ActionResult Submit(T_Setting setting) { string userNo = Commom.ReadUserInfo().UserNo; var successResult = new SettingService().Submit(userNo, setting); return(Json(successResult, JsonRequestBehavior.AllowGet)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OnlineCourseConnectionString"].ConnectionString); try { conn.Open(); string selectSql = "SELECT * FROM ClassType WHERE TypeID={0}"; selectSql = string.Format(selectSql, Request["TypeID"].ToString()); SqlDataAdapter da = new SqlDataAdapter(selectSql, conn); DataSet ds = new DataSet(); da.Fill(ds, "ClassType"); DataRowView dr = ds.Tables["ClassType"].DefaultView[0]; TypeName.InnerText = dr["TypeName"].ToString(); } catch (Exception ex) { Commom commom = new Commom(); commom.ShowErrorPage(Response, Server.UrlEncode(ex.Message), Server.UrlEncode(ex.StackTrace), false); } finally { conn.Close(); } } }
public void getVi(string ma) { string name = "", img = "", donvi = ""; string query = @"SELECT ten_vi, img, don_vi FROM VI WHERE ma_vi = '" + ma + "'"; DB.conn.Open(); SqlCommand cmd = new SqlCommand(query, DB.conn); SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { name = rd[0].ToString(); img = rd[1].ToString(); donvi = rd[2].ToString(); } DB.conn.Close(); llbVi.Text = name; pbImgVi.Image = Commom.getImage(img); if (donvi == "VND") { pbSoTien.Image = Commom.getImage("vnd.PNG"); } else { pbSoTien.Image = Commom.getImage("usd.PNG"); } }
/* Add các ví lên flowLayoutPanel */ void addItem() { flowLayoutPanelNganSach.Controls.Clear(); listItem = new UserControlNganSach[listNganSachs.Count]; for (int i = 0; i < listItem.Length; i++) { DateTime DateTime = DateTime.Now; DateTime DateTimeKetThuc = DateTime.Parse(Commom.getDate(listNganSachs[i].NgayKetThuc)); TimeSpan interval = DateTimeKetThuc.Subtract(DateTime); if (interval.Days >= 0) { listItem[i] = new UserControlNganSach(this); listItem[i].ID = listNganSachs[i].MaLoaiGD; listItem[i].Vi = listNganSachs[i].MaVi; listItem[i].NgayBatDau = Commom.getDate(listNganSachs[i].NgayBatDau); listItem[i].NgayKetThuc = Commom.getDate(listNganSachs[i].NgayKetThuc); listItem[i].SoTien = listNganSachs[i].SoTien; listItem[i].SoTienConLai = getSoTienConLai(listNganSachs[i].MaVi, listNganSachs[i].MaLoaiGD, listNganSachs[i].SoTien).ToString(); listItem[i].NgayConLai = "Còn lại: " + interval.Days.ToString() + " ngày"; listItem[i].Img = listNganSachs[i].getImage(); } if (flowLayoutPanelNganSach.Controls.Count < 0) { flowLayoutPanelNganSach.Controls.Clear(); } else { flowLayoutPanelNganSach.Controls.Add(listItem[i]); } } }
protected void Login(object sender, EventArgs e) { SqlDataReader UserInfo; int res; string Pwd; SqlConnection con = new SqlConnection("Server=localhost;Initial Catalog=OnlineCourse;Integrated Security=True;"); try { con.Open(); string sql = "select ManagerID from Managers " + "where ManagerName='{0}'"; sql = string.Format(sql, UserName.Text); SqlCommand com = new SqlCommand(sql, con); object r = com.ExecuteScalar(); if (r != null) { res = (int)r; sql = "select Pwd,Tel from Managers " + "where ManagerID='{0}'"; sql = string.Format(sql, res); com = new SqlCommand(sql, con); UserInfo = com.ExecuteReader(); UserInfo.Read(); Pwd = UserInfo["Pwd"].ToString(); if (Pwd == PassWord.Text) { Session["ManagerName"] = UserName.Text; Session["ManagerID"] = res; Session["Pwd"] = UserInfo["Pwd"]; Session["Tel"] = UserInfo["Tel"]; UserInfo.Close(); Response.Redirect("ManagerTools.aspx", false); } else { errMsg.Style["display"] = "inline-block"; info.Text = "密码错误,请重新输入!"; } } else { errMsg.Style["display"] = "inline-block"; info.Text = "该用户不存在!"; } } catch (Exception ex) { Commom commom = new Commom(); commom.ShowErrorPage(Response, Server.UrlEncode(ex.Message), Server.UrlEncode(ex.StackTrace), true); } finally { con.Close(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { preview.ImageUrl = "~/icons/AddImg.jpg"; SqlConnection con = new SqlConnection("Server=localhost;Initial Catalog=OnlineCourse;Integrated Security=True;"); try { con.Open(); string sql = "select * from ClassType"; SqlCommand com = new SqlCommand(sql, con); SqlDataReader reader = com.ExecuteReader(); Type.DataSource = reader; Type.DataTextField = "TypeName"; Type.DataValueField = "TypeID"; Type.DataBind(); reader.Close(); if (Request["ClassID"] != null) { Title = title.InnerText = "修改书籍信息"; sql = "SELECT * FROM Classes WHERE ClassID={0}"; sql = string.Format(sql, Request["ClassID"]); SqlDataAdapter da = new SqlDataAdapter(sql, con); DataSet ds = new DataSet(); da.Fill(ds, "Classes"); DataRowView row = ds.Tables["Classes"].DefaultView[0]; ClassID.Value = row["ClassID"].ToString(); ClassName.Text = row["ClassName"].ToString(); Type.SelectedValue = row["TypeID"].ToString(); ClassImg.Value = preview.ImageUrl = row["ClassImg"].ToString(); VideoAddress.Value = row["VideoAddress"].ToString(); Price.Text = row["Price"].ToString(); Author.Text = row["Teacher"].ToString(); Introduction.Text = Server.HtmlDecode(row["Introduction"].ToString()); } else { preview.ImageUrl = "~/icons/AddImg.jpg"; Title = title.InnerText = "添加书籍"; } } catch (Exception ex) { Commom commom = new Commom(); commom.ShowErrorPage(Response, Server.UrlEncode(ex.Message), Server.UrlEncode(ex.StackTrace), false); } finally { con.Close(); } } }
void getDataChartChi() { double sum = 0; string query = @"SELECT SUM(GiaoDichTaiChinh.so_tien) AS 'so_tien', LoaiGiaoDich.ten_loai_gd FROM GiaoDichTaiChinh, LoaiGiaoDich,NhomGiaoDich,VI WHERE GiaoDichTaiChinh.ma_loai_gd = LoaiGiaoDich.ma_loai_gd AND LoaiGiaoDich.ma_nhom_gd = NhomGiaoDich.ma_nhom_gd AND GiaoDichTaiChinh.ma_vi = VI.ma_vi AND VI.taikhoan = '" + IdUser + "' AND NhomGiaoDich.ten_nhom_gd = N'Khoản chi'"; if (timeEnd == string.Empty && timeStart != string.Empty) { query += " AND GiaoDichTaiChinh.thoi_gian = '" + timeStart + "'"; } else if (timeEnd != string.Empty && timeStart != string.Empty) { query += " AND GiaoDichTaiChinh.thoi_gian >= '" + timeStart + "' AND GiaoDichTaiChinh.thoi_gian <= '" + timeEnd + "'"; } if (IDWallets != string.Empty) { query += " AND VI.ma_vi = '" + IDWallets + "'"; } query += " GROUP BY LoaiGiaoDich.ten_loai_gd"; DB.conn.Open(); SqlCommand cmd = new SqlCommand(query, DB.conn); SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { chartChi.Series["Chi"].Points.AddXY(rd[1].ToString(), double.Parse(rd[0].ToString())); sum += double.Parse(rd[0].ToString()); } DB.conn.Close(); if (sum == 0) { chartChi.Series["Chi"].Points.AddXY("Chưa có giao dịch", 100); } lbKhoanChi.Text = "Khoản chi: " + Commom.getMoneyStr(sum.ToString()); }
/// <summary> /// 拆分打印 /// </summary> /// <returns></returns> public ActionResult SplitStamp(string serialno, decimal qty) { SuccessResult successResult = new SuccessResult(); successResult.Success = false; string strErrMsg = ""; DateTime time = DateTime.Now; if (!queryDB.Chai(serialno, qty, Commom.ReadUserInfo(), ref strErrMsg, ref time)) { successResult.Msg = strErrMsg; return(Json(successResult, JsonRequestBehavior.AllowGet)); } successResult.Data = time.ToString(); successResult.Success = true; return(Json(successResult, JsonRequestBehavior.AllowGet)); }
public ActionResult ForwardEmail(UpdateFile form) { bool status = new RequestDao().User_Edit(form.Id, form.name); if (!status) { return(Json(status, JsonRequestBehavior.AllowGet)); } string template = System.IO.File.ReadAllText(HttpContext.Server.MapPath("~/Files/Templates/Approval.html")); var tbl = new Commom().respone(form.Id); tbl.Date_Autho = DateTime.Now.ToString("dd/MM/yyyy"); tbl.FullName = new UserDao().load().Where(m => m.UserName.Equals(HttpContext.User.Identity.Name.ToString())).FirstOrDefault().FullName; tbl.Url = Request.Url.GetLeftPart(UriPartial.Authority) + "/Approvals/Detail?ma=" + tbl.Id; tbl.UrlFile = Request.Url.GetLeftPart(UriPartial.Authority) + "/Files/" + form.Id + ".pdf"; string body = Engine.Razor.RunCompile(template, "checkkey", null, tbl); status = new Commom().SendEmail(form.email, "Mail Thông Báo Kiểm Tra - " + tbl.Hang_Muc, body); return(Json(new { status = status }, JsonRequestBehavior.AllowGet)); }
private void checkColor(string strMoney) { double dMoney = double.Parse(strMoney); if (dMoney > 0) // còn định mức { lbSoTienConLai.Text = "Còn lại: " + Commom.getMoneyStr(strMoney); lbSoTienConLai.ForeColor = Color.ForestGreen; } else if (dMoney == 0) // bằng định mức { lbSoTienConLai.Text = "Hết định mức: " + Commom.getMoneyStr(strMoney); lbSoTienConLai.ForeColor = Color.ForestGreen; } else // vượt { lbSoTienConLai.Text = "Vượt định mức: " + Commom.getMoneyStr(strMoney); lbSoTienConLai.ForeColor = Color.Red; } }
public void GetData() { string query = @"SELECT so_tien, ngay_bat_dau, ngay_ket_thuc FROM NganSach WHERE ma_vi = " + iD_Vi + " AND ma_loai_gd = " + iD_Loai_Gd + ""; DB.conn.Open(); SqlCommand cmd = new SqlCommand(query, DB.conn); SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { llbSoTien.Text = Commom.getMoneyStr(rd[0].ToString()); llbNgayBD.Text = Commom.getDate(rd[1].ToString()); llbNgayKT.Text = Commom.getDate(rd[2].ToString()); } DB.conn.Close(); getLoaiGD(iD_Loai_Gd); getVi(iD_Vi); lbSoTienDaChi.Text = so_tien_da_chi; }
public ActionResult SendEmail() { int ma = int.Parse(Request.Form["ma"]); string code = Request.Form["code"]; HttpPostedFileBase file = null; if (Request.Files.Count > 0) { file = Request.Files[0]; string extension = Path.GetExtension(file.FileName); string filename = ma.ToString() + extension; if (System.IO.File.Exists(Server.MapPath("/Files/FilesReponse/" + filename))) { System.IO.File.Delete(Server.MapPath("/Files/FilesReponse/" + filename)); } file.SaveAs(Server.MapPath("/Files/FilesReponse/" + filename)); } var check = new CheckDao().load(ma); if (!check.Any(m => m.Result == null)) { new CheckDao().SaveAutho(ma, code); bool result = false; //lấy thông tin email string template = System.IO.File.ReadAllText(HttpContext.Server.MapPath("~/Files/Templates/Reponse.html")); var tbl = new Commom().respone(ma); tbl.Date_Autho = DateTime.Now.ToString("dd/MM/yyyy"); tbl.Url = Request.Url.GetLeftPart(UriPartial.Authority) + "/Requests/CheckList?ma=" + tbl.Id; tbl.UrlFile = Request.Url.GetLeftPart(UriPartial.Authority) + "/Files/FilesReponse/" + ma.ToString() + ".pdf"; var email = new UserDao().load().Where(m => m.UserName.Equals(tbl.User_Nhap)).FirstOrDefault(); string body = Engine.Razor.RunCompile(template, "templatekey", null, tbl); // gửi email result = new Commom().SendEmail(email.Email, "Mail Phản Hồi Thông Báo Kiểm Tra - " + tbl.Hang_Muc, body); return(Json(new { status = result }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { status = "Error" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult ChangePassword(ChangePasswordModel model) { if (ModelState.IsValid) { model.NewPassWord = new Commom().MD5Hash(model.NewPassWord); model.OldPassword = new Commom().MD5Hash(model.OldPassword); int result = new Commom().ChangePassword(model.OldPassword, model.NewPassWord); if (result == 0) { ViewBag.Notify = "Mật khẩu không đúng"; ViewBag.Type = "alert alert-danger"; } else { ViewBag.Notify = "Thay đổi mật khẩu thành công"; ViewBag.Type = "alert alert-success"; } return(View()); } return(View(model)); }
public void getLoaiGD(string ma) { string name = "", img = ""; string query = @"SELECT ten_loai_gd, img FROM LoaiGiaoDich WHERE ma_loai_gd = '" + ma + "'"; DB.conn.Open(); SqlCommand cmd = new SqlCommand(query, DB.conn); SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { name = rd[0].ToString(); img = rd[1].ToString(); } DB.conn.Close(); llbLoaiGiaoDich.Text = name; pbLoaiGiaoDich.Image = Commom.getImage(img); }
/// <summary> /// 编辑医院信息数据 /// </summary> /// <param name="type"></param> /// <param name="hospitalDict"></param> /// <returns></returns> public int EditWeChatHospital(int type, MED_WECHAT_HOSPITALS hospitalDict) { hospitalDict.PASSWORD = Commom.Base64Encode(hospitalDict.PASSWORD); int result = 0; try { if (type == 0) { hospitalDict.HOSPITAL_ID = Guid.NewGuid().ToString(); //根据医院判断是否存在 if (dapper.Set <MED_WECHAT_HOSPITALS>().Single(d => d.HOSPITAL_NAME == hospitalDict.HOSPITAL_NAME) != null) { result = 2; } //根据医院 登录名是否存在 else if (dapper.Set <MED_WECHAT_HOSPITALS>().Single(d => d.LOGIN_NAME == hospitalDict.LOGIN_NAME) != null) { result = 3; } else { result = dapper.Set <MED_WECHAT_HOSPITALS>().Insert(hospitalDict) ? 1 : 0; } } else { hospitalDict.ModelStatus = ModelStatus.Modeified; result = dapper.Set <MED_WECHAT_HOSPITALS>().Update(hospitalDict) > 0 ? 1 : 0; } dapper.SaveChanges(); } catch (Exception ex) { Logger.Error("编辑医院信息数据EditWeChatHospital:", ex); } return(result); }
protected void submit_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Server=localhost;Initial Catalog=OnlineCourse;Integrated Security=True;"); try { con.Open(); string path = Server.MapPath("~/UserImg"); string fileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString(); if (FileUpload.HasFile) { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string[] temp = FileUpload.FileName.Split('.'); fileName = fileName + "." + temp[temp.Length - 1]; path += "/" + fileName; FileUpload.SaveAs(path); } string sql = "Insert Into Users(UserName,Pwd,Tel,UserImg)" + "values('{0}',{1},'{2}','{3}')"; sql = string.Format(sql, UserName.Text, PassWord.Text, Tel.Text, "~/UserImg/" + fileName); SqlCommand com = new SqlCommand(sql, con); com.ExecuteNonQuery(); Response.Redirect("RegSuccessful.aspx", false); } catch (Exception ex) { Commom commom = new Commom(); commom.ShowErrorPage(Response, Server.UrlEncode(ex.Message), Server.UrlEncode(ex.StackTrace), true); } finally { con.Close(); } }
public ActionResult SendEmail(UpdateFile form) { if (new Commom().CheckPermission(form.Id)) { return(Json("Error", JsonRequestBehavior.AllowGet)); } if (form.file != null) { string filename = form.Id.ToString(); string extension = Path.GetExtension(form.file.FileName); filename = filename + extension; if (System.IO.File.Exists(Server.MapPath("/Files/" + filename))) { System.IO.File.Delete(Server.MapPath("/Files/" + filename)); } form.file.SaveAs(Server.MapPath("/Files/" + filename)); } bool status = new RequestDao().User_Autho(form.Id, form.name); if (!status) { return(Json(status, JsonRequestBehavior.AllowGet)); } var template = System.IO.File.ReadAllText(HttpContext.Server.MapPath("~/Files/Templates/Approval.html")); var tbl = new Commom().respone(form.Id); tbl.Date_Autho = DateTime.Now.ToString("dd/MM/yyyy"); tbl.FullName = new UserDao().load().Where(m => m.UserName.Equals(HttpContext.User.Identity.Name.ToString())).FirstOrDefault().FullName; tbl.Url = Request.Url.GetLeftPart(UriPartial.Authority) + "/Approvals/Detail?ma=" + tbl.Id; tbl.UrlFile = Request.Url.GetLeftPart(UriPartial.Authority) + "/Files/" + form.Id + ".pdf"; var body = Engine.Razor.RunCompile(template, "key", null, tbl); status = new Commom().SendEmail(form.email, "Mail Thông Báo Kiểm Tra - " + tbl.Hang_Muc, body); return(Json(new { status = status }, JsonRequestBehavior.AllowGet)); }
protected void Clear_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OnlineCourseConnectionString"].ConnectionString); try { conn.Open(); string sql = "DELETE FROM OrderDetails WHERE OrderID={0}"; sql = string.Format(sql, Session["ShoppingID"].ToString()); SqlCommand com = new SqlCommand(sql, conn); com.ExecuteNonQuery(); GetShopping(); } catch (Exception ex) { Commom commom = new Commom(); commom.ShowErrorPage(Response, Server.UrlEncode(ex.Message), Server.UrlEncode(ex.StackTrace), false); } finally { conn.Close(); } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OnlineCourseConnectionString"].ConnectionString); try { conn.Open(); string sql = "DELETE FROM OrderDetails WHERE ClassID={0}"; sql = string.Format(sql, GridView1.DataKeys[e.RowIndex].Value.ToString()); SqlCommand com = new SqlCommand(sql, conn); com.ExecuteNonQuery(); GetShopping(); } catch (Exception ex) { Commom commom = new Commom(); commom.ShowErrorPage(Response, Server.UrlEncode(ex.Message), Server.UrlEncode(ex.StackTrace), false); } finally { conn.Close(); } }
protected void Submit_Click(object sender, EventArgs e) { if (Session["UserID"] == null) { Response.Write("<script>alert('您还没有登录或登录信息失效,请登陆后再购买!');" + "top.location.href='login.aspx';</script>"); } else { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OnlineCourseConnectionString"].ConnectionString); try { conn.Open(); if (IsShopping.Value.Equals("0")) { string sql = "INSERT INTO OrderDetails(OrderID,ClassID) VALUES({0},{1})"; sql = string.Format(sql, Session["ShoppingID"], Request["ClassID"]); SqlCommand com = new SqlCommand(sql, conn); com.ExecuteNonQuery(); Response.Write("<script>alert('添加购物车成功!');</script>"); } else { Response.Write("<script>alert('该课程已添加到购物车中!');</script>"); } } catch (Exception ex) { Commom commom = new Commom(); commom.ShowErrorPage(Response, Server.UrlEncode(ex.Message), Server.UrlEncode(ex.StackTrace), false); } finally { conn.Close(); } } }
/// <summary> /// 修改密码 /// </summary> /// <param name="user"></param> /// <returns></returns> public int ChangePwd(MED_USERS user) { string tempOldPwd = Commom.Base64Encode(user.OLD_LOGIN_PWD); MED_WECHAT_HOSPITALS midUser = dapper.Set <MED_WECHAT_HOSPITALS>().Single(x => x.LOGIN_NAME == user.LOGIN_NAME && x.PASSWORD == tempOldPwd); if (midUser == null) { return(2); //原始密码输入错误 } else { midUser.PASSWORD = Commom.Base64Encode(user.LOGIN_PWD); int updateCount = dapper.Set <MED_WECHAT_HOSPITALS>().Update(midUser, p => new { p.PASSWORD }); dapper.SaveChanges(); if (updateCount > 0) { return(1); //修改密码成功 } else { return(0); } } }
private static void SetCache() { Commom.SetSizeByLengthProperties("ConsoleTestApplication", "ConsoleTestApplication"); Commom.SaveOnCacheIfNonExists <FakeObject>(); Commom.SaveOnCacheIfNonExists <FilterFakeObject>(); }
/// <summary> /// 提交 /// </summary> /// <returns></returns> public ActionResult Submit(string formJson, string orderId, string remark) { var successResult = checkRecordService.Submit(formJson, orderId, remark, Commom.ReadUserInfo().UserNo); return(Json(successResult, JsonRequestBehavior.AllowGet)); }
public void TestDivide() { var common = new Commom(); Assert.Equal(3, common.Divide(1, 2)); }
public void TestDivide0() { var common = new Commom(); Assert.Throws <Exception>(() => { common.Divide(1, 0); }); }