public ActionResult SeachRequestDevices(FormCollection colection, RequestDevice RequestDevice) { ViewData["User"] = Ql.Users.ToList(); ViewData["RequestDevices"] = Ql.RequestDevices.ToList(); int?Status = colection["Status"].Equals("") ? (int?)null : Convert.ToInt32(colection["Status"]); var lstRequestDevices = Ql.SearchRequestDeviceNew(Status, false).ToList(); var ViewRequestDevices = lstRequestDevices; ViewBag.Status = Status; return(View("RequestDevice", ViewRequestDevices)); }
public ActionResult AddRequestDevice(FormCollection colection, RequestDevice RequestDevice) { int? UserRequest = colection["UserRequest"].Equals("") ? (int?)null : Convert.ToInt32(colection["UserRequest"]); DateTime?DateOfRequest = colection["DateOfRequest"].Equals("") ? (DateTime?)null : Convert.ToDateTime(colection["DateOfRequest"]); DateTime?DateOfUse = colection["DateOfUse"].Equals("") ? (DateTime?)null : Convert.ToDateTime(colection["DateOfUse"]); String DeviceName = colection["DeviceName"]; int? TypeOfDevice = colection["TypeOfDevice"].Equals("") ? (int?)null : Convert.ToInt32(colection["TypeOfDevice"]); String Configuration = colection["Configuration"]; String Notes = colection["Notes"]; int? Status = colection["Status"].Equals("-1") ? (int?)null : Convert.ToInt32(colection["Status"]); int? NumDevice = colection["NumDevice"].Equals("") ? (int?)null : Convert.ToInt32(colection["NumDevice"]); //int? UserApproved = colection["UserApproved"].Equals("") ? (int?)null : Convert.ToInt32(colection["UserApproved"]); Ql.AddRequestDevice(UserRequest, DateOfRequest, DateOfUse, DeviceName, TypeOfDevice, Configuration, Notes, Status, NumDevice, null); //String Name = Ql.Users.Where(x => x.Id == UserRequest).First().FullName; //String MailFrom = Ql.Users.Where(x => x.Id == UserRequest).First().Email.Trim(); //String MailTo = Ql.Users.Where(x => x.Id == null).First().Email.Trim(); //String TypeDevice = Ql.DeviceTypes.Where(x => x.Id == TypeOfDevice).First().TypeName.Trim(); //if (MailFrom != "" & MailTo != "") //{ // StringBuilder Body = new StringBuilder(); // Body.Append("<table>"); // Body.Append("<tr><td colspan='2'><h4>Thông Tin Yêu Cầu</h4></td></tr>"); // Body.Append("<tr><td>Người Yêu Cầu:</td><td>" + Name + "</td></tr>"); // Body.Append("<tr><td>Tên Thiết Bị:</td><td>" + DeviceName + "</td></tr>"); // Body.Append("<tr><td>Ngày Sử Dụng:</td><td>" + DateOfUse + "</td></tr>"); // Body.Append("<tr><td>Số Lượng Thiết Bị:</td><td>" + NumDevice + "</td></tr>"); // Body.Append("<tr><td>Loại Thiết Bị:</td><td>" + TypeDevice + "</td></tr>"); // Body.Append("<tr><td>Cấu Hình:</td><td>" + Configuration + "</td></tr>"); // Body.Append("<tr><td>Chú Thích:</td><td>" + Notes + "</td></tr>"); // Body.Append("</table>"); // MailMessage mail = new MailMessage(); // mail.To.Add(MailTo); // mail.From = new MailAddress(MailFrom); // mail.Subject = "Yêu Cầu Sử Dụng Thiết Bị"; // mail.Body = Body.ToString();// phần thân của mail ở trên // mail.IsBodyHtml = true; // SmtpClient smtp = new SmtpClient(); // smtp.Host = "smtp.gmail.com"; // smtp.Port = 587; // smtp.UseDefaultCredentials = true; // smtp.Credentials = new System.Net.NetworkCredential(MailFrom, "11111111");// tài khoản Gmail của bạn // smtp.EnableSsl = true; // try // { // smtp.Send(mail); // } // catch (Exception) // { // } //} return(RedirectToAction("RequestDevice", "RequestDevice")); }
public ActionResult EditRequestDevice(FormCollection colection, RequestDevice RequestDevice) { int? IdRequest = colection["IdRequest"].Equals("-1") ? (int?)null : Convert.ToInt32(colection["IdRequest"]); int? UserRequest = colection["UserRequest"].Equals("0") ? (int?)null : Convert.ToInt32(colection["UserRequest"]); DateTime?DateOfRequest = colection["DateOfRequest"].Equals("") ? (DateTime?)null : Convert.ToDateTime(colection["DateOfRequest"]); DateTime?DateOfUse = colection["DateOfUse"].Equals("") ? (DateTime?)null : Convert.ToDateTime(colection["DateOfUse"]); String DeviceName = colection["DeviceName"]; int? TypeOfDevice = colection["TypeOfDevice"].Equals("0") ? (int?)null : Convert.ToInt32(colection["TypeOfDevice"]); String Configuration = colection["Configuration"]; String Notes = colection["Notes"]; int? Status = colection["Status"].Equals("") ? (int?)null : Convert.ToInt32(colection["Status"]); bool? Approved = Convert.ToBoolean(colection["Approved"]); int? NumDevice = colection["NumDevice"].Equals("") ? (int?)null : Convert.ToInt32(colection["NumDevice"]); String NoteProcess = colection["NoteProcess"]; String NoteReasonRefuse = colection["NoteReasonRefuse"]; String NameUserApproved = colection["NameUserApproved"]; Ql.UpdateRequestDevice(IdRequest, UserRequest, DateOfRequest, DateOfUse, DeviceName, TypeOfDevice, Configuration, Notes, Approved, null, Status, NumDevice, NoteProcess, NoteReasonRefuse, NameUserApproved); ViewData["DeviceTypes"] = Ql.DeviceTypes.ToList(); ViewData["User"] = Ql.Users.Where(x => x.Status != 1 && x.IsDeleted != true).ToList(); return(View(Ql.RequestDevices.Find(IdRequest))); }
private void UpdateRendering(List <RequestPlaceholder> requestPlaceholders, XmlDocument xmlLayoutDoc, Database db, RequestDevice device) { foreach (var requestPlaceholder in requestPlaceholders) { foreach (var requestRendering in requestPlaceholder.Renderings) { var renderingElement = xmlLayoutDoc.SelectSingleNode("//r[@uid='{" + requestRendering.UniqueId.ToUpper() + "}']") as XmlElement; if (renderingElement == null) // this is new! { var deviceElement = xmlLayoutDoc.SelectSingleNode("//d[@id='{" + device.Id.ToUpper() + "}']") as XmlElement; renderingElement = xmlLayoutDoc.CreateElement("r"); renderingElement.SetAttribute("uid", "{" + requestRendering.UniqueId.ToUpper() + "}"); renderingElement.SetAttribute("id", "{" + requestRendering.ItemId.ToUpper() + "}"); deviceElement.AppendChild(renderingElement); } // TODO: rebuild this path... from parents renderingElement.SetAttribute("ph", requestRendering.PlaceholderPath); // TODO: should I use requestPlaceholder and not assume the child has been updated? (it's a lot to keep synced) string ds = ""; if (!string.IsNullOrWhiteSpace(requestRendering.DataSourcePath)) { var item = db.GetItem(requestRendering.DataSourcePath); // language not important, only life important? if (item != null) { ds = item.ID.ToString(); } } renderingElement.SetAttribute("ds", ds); UpdateRendering(requestRendering.Placeholders, xmlLayoutDoc, db, device); } } }