public ActionResult DeleteContract(Contract cont) { try { var itm = db.item_Contract.Where(a => a.Cont_No == cont.Cont_No).ToList(); if (itm != null) { foreach (var item in itm) { db.item_Contract.Remove(item); db.SaveChanges(); } } Contract DelCon = db.Contracts.FirstOrDefault(a => a.Cont_No == cont.Cont_No); db.Contracts.Remove(DelCon); db.SaveChanges(); return(RedirectToAction("viewContracts", "Customers", new { Cust_Id = cont.Cust_Id })); } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); return(RedirectToAction("ErrorPage", "Home")); } }
public ActionResult Edit(Customer newCust) { try { if (ModelState.IsValid) { Customer OldCust = db.Customers.FirstOrDefault(a => a.Id == newCust.Id); OldCust.Name = newCust.Name; OldCust.Address = newCust.Address; OldCust.Email = newCust.Email; db.SaveChanges(); return(RedirectToAction("Index", "Customers")); //return View("Index"); //return Json(new { success = true, message = "Customer data Updated Successfuly" }, JsonRequestBehavior.AllowGet); } Customer cust = db.Customers.FirstOrDefault(a => a.Id == newCust.Id); if (cust == null) { return(HttpNotFound("Customer Doesn't Exist")); } return(View("Index")); } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); return(RedirectToAction("ErrorPage", "Home")); } }
/// <summary> /// Intizializes the <see cref="ILogProvider"/>. /// </summary> /// <param name="logHandler">The <see cref="ILogHandler"/> that may handle incomming <see cref="LogMessage"/>s.</param> public override void Initialize(ILogHandler logHandler) { base.Initialize(logHandler); try { mSocket = new Socket( AddressFamily.InterNetwork , SocketType.Stream , ProtocolType.Tcp); mSocket.ExclusiveAddressUse = true; mSocket.ReceiveBufferSize = RECEIVE_BUFFER_SIZE; mSocket.Bind(new IPEndPoint( IPAddress.Any , mPort)); mSocket.Listen(100); SocketAsyncEventArgs socketEvent = new SocketAsyncEventArgs(); socketEvent.Completed += SocketEventCompleted; mSocket.AcceptAsync(socketEvent); } catch (Exception ex) { mLogHandler.HandleError(LogError.Error(ex.Message)); } }
protected void btn_submit_Click(object sender, EventArgs e) { try { if (Page.IsValid) { MailMessage mailMessage = new MailMessage(); mailMessage.From = new MailAddress("*****@*****.**"); mailMessage.To.Add(txt_email.Text); mailMessage.Subject = txt_subject.Text; mailMessage.Body = "<b>Sender Name:</b>" + txt_name.Text + "<br/>" + "<b> Sender Email:</b>" + txt_email.Text + "<br/>" + "<b>Message :</b>" + txt_message.Text; mailMessage.IsBodyHtml = true; SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587); smtpClient.EnableSsl = true; smtpClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", ""); smtpClient.Send(mailMessage); lbl_contact.Text = "Your message is delivered ,Thank you for contacting us"; txt_email.Enabled = false; txt_message.Enabled = false; txt_name.Enabled = false; txt_subject.Enabled = false; btn_submit.Enabled = false; } } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { if (Session["isadmin"] != null) { if (Session["isadmin"].ToString() != "1") { Response.Redirect("~/Annonymous/Home.aspx"); } } if (Session["id"] == null) { Response.Redirect("~/Annonymous/Home.aspx"); } lv_data.DataSource = products.getAll2(); lv_data.DataBind(); }catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } } }
protected void btn_addprod_Click(object sender, EventArgs e) { try { if (IsValid) { string path = "~/prodimg/" + ddl_category.SelectedItem.Text + "/" + fu_prodimag.FileName; if (fu_prodimag.HasFile) { string ext = Path.GetExtension(fu_prodimag.FileName); if (ext == ".jpg" || ext == ".png" || ext == ".PNG" || ext == ".JPG") { fu_prodimag.SaveAs(Server.MapPath(path)); products.Add(txt_prodName.Text, txt_prodDesc.Text, int.Parse(txt_prodPrice.Text), int.Parse(txt_prodQuantity.Text), path, int.Parse(ddl_category.SelectedValue)); Page.ClientScript.RegisterStartupScript(this.GetType(), "show", " showDialog();", true); } else { lbl_doneOrError.Text = "Wrong image path"; lbl_doneOrError.Style.Add("color", "red"); } } } } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } }
//search users public async Task <ActionResult> searchAsync(string name) { try { if (Session["Member"] != null) { TempData["search"] = name; TempData.Keep(); List <ApplicationUser> users = null; HttpResponseMessage response = globalVariables.webApiClient.GetAsync("ApplicationUsers/?name=" + TempData["search"]).Result; if (response.IsSuccessStatusCode) { users = await response.Content.ReadAsAsync <List <ApplicationUser> >(); } return(View(users)); } else { return(RedirectToAction("Login", "Account")); } } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); return(View("ErrorPage")); } }
public ActionResult Delete() { try { var id = int.Parse(TempData["ItemId"].ToString()); var itm = db.item_Contract.Where(a => a.Code == id).ToList(); if (itm != null) { db.Items.FirstOrDefault(a => a.Code == id).quantity = 0; db.SaveChanges(); } else { Item Delitm = db.Items.FirstOrDefault(a => a.Code == id); db.Items.Remove(Delitm); db.SaveChanges(); } return(RedirectToAction("index")); } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); return(RedirectToAction("ErrorPage", "Home")); } }
//accept request public ActionResult Accept(string submit) { try { if (Session["Member"] != null) { string reciever = TempData["userId"].ToString(); TempData.Keep(); Friend friend = new Friend() { SenderId = submit, ReceiverId = reciever, state = "Accepted" }; HttpResponseMessage response = globalVariables.webApiClient.PutAsJsonAsync("/api/Friend", friend).Result; if (response.IsSuccessStatusCode) { return(RedirectToAction("FriendsAsync", "Member")); } } else { return(RedirectToAction("Login", "Account")); } return(View()); } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); return(View("ErrorPage")); } }
public async Task <ActionResult> Dashboard() { try { if (Session["Member"] != null) { //ApplicationUser loginUser = null; moodChart mood = null; HttpResponseMessage response = globalVariables.webApiClient.GetAsync("ApplicationUsers?userId=" + Session["Member"].ToString()).Result; if (response.IsSuccessStatusCode) { mood = await response.Content.ReadAsAsync <moodChart>(); } TempData.Keep(); return(View(mood)); } else { return(RedirectToAction("Login", "Account")); } //return View(); } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); return(View("ErrorPage")); } }
//cancel request public ActionResult CancelRequest(string submit) { try { if (Session["Member"] != null) { TempData["search"] = submit; string sender = TempData["userId"].ToString(); TempData.Keep(); HttpResponseMessage response = globalVariables.webApiClient.DeleteAsync("/api/Friend?senderID=" + sender + "&recieverId=" + TempData["search"]).Result; if (response.IsSuccessStatusCode) { return(RedirectToAction("userProfile", "Member", new { id = submit })); } } else { return(RedirectToAction("Login", "Account")); } return(View()); } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); return(View("ErrorPage")); } }
protected void Page_Load(object sender, EventArgs e) { UnobtrusiveValidationMode = UnobtrusiveValidationMode.None; if (!IsPostBack) { try { if (Session["isadmin"] != null) { if (Session["isadmin"].ToString() != "1") { Response.Redirect("~/Annonymous/Home.aspx"); } } if (Session["id"] == null) { Response.Redirect("~/Annonymous/Home.aspx"); } ddl_product.DataSource = products.getAll(); ddl_product.DataTextField = "prod_name"; ddl_product.DataValueField = "prod_id"; ddl_product.DataBind(); if (Session["prodid"] != null) { ddl_product.SelectedValue = Session["prodid"].ToString(); } } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } } }
public ActionResult Edit(Item newItm) { try { if (ModelState.IsValid) { Item OldItm = db.Items.FirstOrDefault(a => a.Code == newItm.Code); OldItm.name = newItm.name; OldItm.quantity = newItm.quantity; OldItm.Price = newItm.Price; db.SaveChanges(); return(RedirectToAction("Index", "Items")); } Item Itm = db.Items.FirstOrDefault(a => a.Code == newItm.Code); if (Itm == null) { return(HttpNotFound("Item Doesn't Exist")); } return(View("Index")); } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); return(RedirectToAction("ErrorPage", "Home")); } }
protected void Page_Load(object sender, EventArgs e) { UnobtrusiveValidationMode = UnobtrusiveValidationMode.None; try { if (!IsPostBack) { if (Session["isadmin"] != null) { if (Session["isadmin"].ToString() != "1") { Response.Redirect("~/Annonymous/Home.aspx"); } } if (Session["id"] == null) { Response.Redirect("~/Annonymous/Home.aspx"); } //to fill ddl_category with categories name ddl_category.DataSource = Category.getAll(); ddl_category.DataTextField = "Category_Name"; ddl_category.DataValueField = "Category_id"; ddl_category.DataBind(); if (Session["category"] != null) { ddl_category.SelectedItem.Text = Session["category"].ToString(); } } } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } }
protected void Page_Load(object sender, EventArgs e) { UnobtrusiveValidationMode = UnobtrusiveValidationMode.None; try { if (Session["isadmin"] != null) { if (Session["isadmin"].ToString() != "1") { Response.Redirect("~/Annonymous/Home.aspx"); } } if (Session["id"] == null) { Response.Redirect("~/Annonymous/Home.aspx"); } //fill gv with all category gv_category.DataSource = Category.getAll(); gv_category.DataBind(); } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { if (Session["isadmin"] != null) { if (Session["isadmin"].ToString() != "1") { Response.Redirect("~/Annonymous/Home.aspx"); } } if (Session["id"] == null) { Response.Redirect("~/Annonymous/Home.aspx"); } gv_pendingorder.DataSource = Order.Pending(); gv_pendingorder.DataBind(); gv_approvedorder.DataSource = Order.Approved(); gv_approvedorder.DataBind(); gv_blocked.DataSource = Order.Blocked(); gv_blocked.DataBind(); } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } } }
public async Task <ActionResult> edit() { try { if (Session["Member"] != null) { //string st = TempData["userId"].ToString(); ApplicationUser loginUser = null; HttpResponseMessage response = globalVariables.webApiClient.GetAsync("ApplicationUsers/" + Session["Member"].ToString()).Result; if (response.IsSuccessStatusCode) { loginUser = await response.Content.ReadAsAsync <ApplicationUser>(); } return(View(loginUser)); } else { return(RedirectToAction("Login", "Account")); } } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); return(View("ErrorPage")); } }
//friends public async Task <ActionResult> FriendsAsync() { try { if (Session["Member"] != null) { List <Friend> users = null; string currentUser = TempData["userId"].ToString(); TempData.Keep(); HttpResponseMessage response = globalVariables.webApiClient.GetAsync("/api/Friend/" + currentUser + "?State=Accepted").Result; if (response.IsSuccessStatusCode) { users = await response.Content.ReadAsAsync <List <Friend> >(); } return(View(users)); } else { return(RedirectToAction("Login", "Account")); } } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); return(View("ErrorPage")); } }
protected void Lbtn_Edit_Click(object sender, EventArgs e) { try { LinkButton lbtn = sender as LinkButton; int prod_id = int.Parse(lbtn.CommandArgument.ToString()); Session.Add("prodid", prod_id); Response.Redirect("~/Admin/EditProduct.aspx"); }catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } }
protected void lbtn_update_Click(object sender, EventArgs e) { try { int prodid = int.Parse(ddl_product.SelectedValue); products.editprom(txt_prom.Text, prodid); MultiView1.ActiveViewIndex = 0; lbl_promotion.Text = products.prom(prodid).Rows[0][0].ToString(); }catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } }
protected void btn_add_Click(object sender, EventArgs e) { if (IsValid) { try { products.editprom(txt_promotion.Text, int.Parse(ddl_product.SelectedValue)); }catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } } }
protected void lbtn_Delete_Click(object sender, EventArgs e) { try { int prodid = int.Parse(ddl_product.SelectedValue); products.editprom("NULL", prodid); MultiView1.ActiveViewIndex = -1; } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } }
protected void Page_Load(object sender, EventArgs e) { try { // GitHub Test 000 SqlCommand cmd = new SqlCommand("SELECT top(1) p1.* FROM Product p1 LEFT JOIN Product p2 ON (p1.Category_id = p2.Category_id AND p1.Prod_id < p2.Prod_id) WHERE p2.Prod_id IS NULL order by p1.Category_id desc"); dlst_latest.DataSource = DBlayer.Sel(cmd); dlst_latest.DataBind(); }catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } }
//Get All Suppliers public ActionResult GetAllSupplierDetails() { try { SupplierRepository SubRepo = new SupplierRepository(); ModelState.Clear(); return(View(SubRepo.GetAllSuppliers())); } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); return(RedirectToAction("ErrorPage", "Home")); } }
protected void btn_block_Click(object sender, EventArgs e) { try { Button btn = (Button)(sender); int id = int.Parse(btn.CommandArgument.ToString()); string NewStatus = "blocked"; Customer.editstatus(id, NewStatus); Response.Redirect("~/Admin/pendingUsers.aspx"); }catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } }
/// <summary> /// 记录错误日志 /// </summary> /// <param name="info">日志内容</param> /// <param name="se">异常</param> public static void WriteLog(string info, Exception se) { if (LogError.IsErrorEnabled) { try { LogError.Error(info, se); Console.WriteLine(info); } catch { } } }
public static void WriteLog(string info, Exception se) { if (LogError.IsErrorEnabled) { try { LogError.Error(info, se); System.Diagnostics.Debug.WriteLine(info); } catch { } } }
public ActionResult proWithMinOrder() { try { ProductsRepository ProRepo = new ProductsRepository(); ModelState.Clear(); return(View(ProRepo.proWithMinOrder())); } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); return(RedirectToAction("ErrorPage", "Home")); } }
protected void Lbtn_Delete_Click(object sender, EventArgs e) { try { LinkButton lbtn = sender as LinkButton; int prod_id = int.Parse(lbtn.CommandArgument.ToString()); products.remove(prod_id); lv_data.DataSource = products.getAll(); lv_data.DataBind(); }catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); } }
public async Task <ActionResult> edit(ApplicationUser newUser, HttpPostedFileBase img) { try { if (Session["Member"] != null) { ApplicationUser loginUser = null; ApplicationUser u = new ApplicationUser() { Id = newUser.Id, Fname = newUser.Fname, Lname = newUser.Lname, Email = newUser.Email, UserName = newUser.UserName, Image = newUser.Image, BirthDate = newUser.BirthDate, PhoneNumber = newUser.PhoneNumber, }; if (img != null && img.ContentLength > 0) { using (var binaryReader = new BinaryReader(img.InputStream)) u.Image = binaryReader.ReadBytes(img.ContentLength); } HttpResponseMessage response = await globalVariables.webApiClient.PutAsJsonAsync("ApplicationUsers/" + Session["Member"].ToString(), u); if (response.IsSuccessStatusCode) { loginUser = await response.Content.ReadAsAsync <ApplicationUser>(); } else if (response.StatusCode == System.Net.HttpStatusCode.BadRequest) { var data = await response.Content.ReadAsStringAsync(); Error error = JsonConvert.DeserializeObject <Error>(data); ViewBag.error = error.Message; return(View(u)); } return(RedirectToAction("viewprofile")); } else { return(View("Login", "Account")); } } catch (Exception ex) { LogError.Error(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); return(View("ErrorPage")); } }