public ActionResult Addrq() { ValidateRequest = false; string a = Request.QueryString["a"]; if (Session["giohang"]== null) { Response.Write("Ban chua lua chon san pham !"); } else { List<Request_Stationery> ls = new List<Request_Stationery>(); foreach( GiohangModel gm in (List<GiohangModel>)Session["giohang"] ) { Request_Stationery s = new Request_Stationery(); s.ProductId = gm.Productid; s.Quantity = gm.Soluong; ls.Add(s); } string chuoi = ""; Employee el = (Employee)Session["Employee"];//form Request_StationeryModel rsm = new Request_StationeryModel(); Request r = new Request(); string[] kq = a.Split('|'); chuoi += kq[0] + kq[1] + kq[2]; r.RequestName = kq[0]; r.RequestContent = kq[1]; r.Description = kq[2]; r.DateDispatch = DateTime.Now; r.Accept = true; r.State = "1"; r.CatalogRQId = Convert.ToInt32(kq[3]); r.EmployeeNumber = el.EmployeeNumber; rsm.inserdata(r); int a1 = r.RequestId; foreach( Request_Stationery r1 in ls ) { r1.RequestId = a1; rsm.insert2(r1); } Response.Write(ls.Count); RequestModel rm = new RequestModel(); string ixep = el.RegistrationNumber; Employee xep = rsm.informationxep(ixep); DataClassesStationeryDataContext dtdc = new DataClassesStationeryDataContext(); Config c1 = dtdc.Configs.First(); if (rm.Send(el.Email, xep.Email, kq[0], kq[1], c1.Type,Convert.ToInt32(c1.Ports), c1.MailNetwork, c1.Password)) { Redirect("Default1/MyRequest10"); } } return null; }
public ActionResult update55(FormCollection form) { Config cf = dc.Configs.OrderByDescending(c => c.BuildDate).ToList().First(); RequestModel22 rq22 = new RequestModel22(); RequestModel rq = new RequestModel(); Employee e = (Employee)Session["Employee"]; Employee e1 = (Employee)Session["eplo1"];//nb req Employee e2 = dc.Employees.Where(ee => ee.EmployeeNumber == e1.RegistrationNumber).ToList().First(); ViewData["lst7"] = rq22.Listrq2().Where(r1 => (e.EmployeeNumber.Equals(r1.RNumber1) && r1.Stte1.Equals("2") && r1.Acc1 == false) || (e.EmployeeNumber.Equals(r1.RNumber1) && r1.Stte1.Equals("7") && r1.Acc1 == false)).OrderByDescending(r => r.DDispatch1).ToList(); string From = cf.MailName; string To = e1.Email; string cc = e2.Email; string type = cf.Type; int post = Convert.ToInt32(cf.Ports); string mailnetword = cf.MailNetwork; string pass = cf.Password; string Subject = "No Approved (Request Rject) " + form["rname"].ToString(); string Message = "<span><b>From:</b> " + e.FullName + "</span><br/>" + "<b>Date Dispatch:</b> " + form["dd"].ToString() + "<br/>" + "<b>Content:</b> " + form["rc"].ToString() + "<br/>" + "<b>Description:</b> " + form["dt"].ToString(); if (form["st6"].Equals("7")) { if (rq.Send1(From, To, cc, Subject, Message, type, post, mailnetword, pass)) { rq.update(Convert.ToInt32(form["requestid"]), form["rname"].ToString(), form["st"].ToString(), Convert.ToDateTime(form["dd"]), DateTime.Now, Convert.ToBoolean(form["acc"]), form["rc"].ToString(), form["en"].ToString(), form["dt"].ToString(), Convert.ToInt32(form["ctid"])); Session["email"] = 1; } else Session["email"] = 2; } else { if (rq.Send(From, To, Subject, Message, type, post, mailnetword, pass)) { rq.update(Convert.ToInt32(form["requestid"]), form["rname"].ToString(), form["st"].ToString(), Convert.ToDateTime(form["dd"]), DateTime.Now, Convert.ToBoolean(form["acc"]), form["rc"].ToString(), form["en"].ToString(), form["dt"].ToString(), Convert.ToInt32(form["ctid"])); Session["email"] = 1; } else Session["email"] = 2; } return RedirectToAction("MyRequest10"); }
public ActionResult update4(FormCollection form) { Request_StationeryModel rm1 = new Request_StationeryModel(); List<Stationery> lstr = dc.Stationeries.ToList(); Config cf = dc.Configs.OrderByDescending(c => c.BuildDate).ToList().First(); RequestModel rq = new RequestModel(); StationeryModel stmd = new StationeryModel(); Employee e = (Employee)Session["Employee"]; Employee e1 = (Employee)Session["eplo"]; Employee e2 = dc.Employees.Where(ee => ee.EmployeeNumber == e1.RegistrationNumber).ToList().First(); RequestModel22 rq22 = new RequestModel22(); // Employee e1 = dc.Employees.Where(ee => ee.EmployeeNumber == e.RegistrationNumber).ToList().First(); ViewData["lst5"] = rq22.Listrq2().Where(r1 => (e.EmployeeNumber.Equals(r1.RNumber1) && r1.Stte1.Equals("1") && r1.Acc1 == true) || (r1.Stte1.Equals("5") && r1.Acc1 == true)).OrderByDescending(r => r.DDispatch1).ToList(); // string From = cf.MailName; string To = e1.Email; string cc = e2.Email; string type = cf.Type; int post = Convert.ToInt32(cf.Ports); string mailnetword = cf.MailNetwork; string pass = cf.Password; string Subject = "Approved Request " + form["rname"].ToString(); string Message = "<span><b>From:</b> " + e.FullName + "</span><br/>" + "<b>Date Dispatch:</b> " + form["dd"].ToString() + "<br/>" + "<b>Content:</b> " + form["rc"].ToString() + "<br/>" + "<b>Description:</b> " + form["dt"].ToString(); //mail List<Request_Stationery> rqs = dc.Request_Stationeries.Where(s => s.RequestId == Convert.ToInt32(form["requestid"])).ToList(); string str = " "; Session["result"] = true; //test foreach (Stationery st in lstr) { foreach (Request_Stationery rs in rqs) { if (st.ProductId == rs.ProductId && rs.Quantity > st.Quantity) { Session["result"] = false; break; } } } // //print item if (Convert.ToBoolean(Session["result"]) == false) { foreach (Stationery st in lstr) { foreach (Request_Stationery rs in rqs) { if (st.ProductId == rs.ProductId && rs.Quantity > st.Quantity) { str = str + st.ProductName.ToString() + " _ "; } } } } else if (Convert.ToBoolean(Session["result"]) == true) { if (form["st3"].Equals("5")) { if (rq.Send1(From, To, cc, Subject, Message, type, post, mailnetword, pass)) { ////// List<Stationery> stnr = dc.Stationeries.ToList(); List<Request_Stationery> listrq = dc.Request_Stationeries.Where(l => l.RequestId == Convert.ToInt32(form["requestid"])).ToList(); // foreach (Stationery s in stnr) { foreach (Request_Stationery v in listrq) { if (s.ProductId == v.ProductId) stmd.EditST_RQ(v.ProductId, Convert.ToInt32(s.Quantity - v.Quantity)); } } // rq.update(Convert.ToInt32(form["requestid"]), form["rname"].ToString(), form["st"].ToString(), Convert.ToDateTime(form["dd"]), DateTime.Now, Convert.ToBoolean(form["acc"]), form["rc"].ToString(), form["en"].ToString(), form["dt"].ToString(), Convert.ToInt32(form["ctid"])); Session["email"] = 1; } else Session["email"] = 2; // } else { if (rq.Send(From, To, Subject, Message, type, post, mailnetword, pass)) { List<Stationery> stnr = dc.Stationeries.ToList(); List<Request_Stationery> listrq = dc.Request_Stationeries.Where(l => l.RequestId == Convert.ToInt32(form["requestid"])).ToList(); // foreach (Stationery s in stnr) { foreach (Request_Stationery v in listrq) { if(s.ProductId==v.ProductId) stmd.EditST_RQ(v.ProductId, Convert.ToInt32(s.Quantity-v.Quantity)); } } rq.update(Convert.ToInt32(form["requestid"]), form["rname"].ToString(), form["st"].ToString(), Convert.ToDateTime(form["dd"]), DateTime.Now, Convert.ToBoolean(form["acc"]), form["rc"].ToString(), form["en"].ToString(), form["dt"].ToString(), Convert.ToInt32(form["ctid"])); Session["email"] = 1; } else Session["email"] = 2; } } //mail Session["qty"] = str; // return RedirectToAction("MyRequest10"); }
public ActionResult Doipw(string id) { Config cf = dct.Configs.OrderByDescending(c => c.BuildDate).ToList().First(); Employee el = (Employee)Session["Employee"]; Employee el2 = dct.Employees.Where(e => e.EmployeeNumber == el.RegistrationNumber).First(); RequestModel rq = new RequestModel(); string From = cf.MailName; string To = el2.Email; //string cc = e2.Email; string type = cf.Type; int post = Convert.ToInt32(cf.Ports); string mailnetword = cf.MailNetwork; string pass = cf.Password; string Subject = el.FullName + "Change Password"; string Message = "<span><b>From:</b> " + el.FullName + "</span><br/>" + "<b>Date Dispatch:</b> " + DateTime.Now + "<br/>"; em.changepass(el.EmployeeNumber, mahoa_giaima.maHoa(id)); rq.Send(From, To, Subject, Message, type, post, mailnetword, pass); Response.Write("Da change Password thanh cong"); return null; }