public ActionResult Create(JenisBank mdat) { // Is Exists var check = entities.JenisBanks.FirstOrDefault(x => x.Nama == mdat.Nama); // Check Validation Form if (ModelState.IsValid) { if (check != null) { ViewBag.Validasi = "Bank telah terdaftar."; return(View(mdat)); } // Set Attributes mdat.CreatedTime = DateTime.Now; mdat.RowStatus = 0; mdat.CreatedBy = this.Session["NamaUser"].ToString(); entities.JenisBanks.Add(mdat); entities.SaveChanges(); // Session Username & Role ViewBag.NamaUser = this.Session["NamaUser"]; ViewBag.Role = this.Session["Role"]; return(RedirectToAction("Index")); } else { // Session Username & Role ViewBag.NamaUser = this.Session["NamaUser"]; ViewBag.Role = this.Session["Role"]; return(View(mdat)); } }
public ActionResult Create(BarangVendor mdat) { if (ModelState.IsValid) { // Set Data mdat.CreatedTime = DateTime.Now; mdat.RowStatus = 0; mdat.CreatedBy = this.Session["NamaUser"].ToString(); entities.BarangVendors.Add(mdat); entities.SaveChanges(); // Session Username & Role ViewBag.NamaUser = this.Session["NamaUser"]; ViewBag.Role = this.Session["Role"]; return(RedirectToAction("Index")); } else { ViewBag.ID_JenisBarang = new SelectList(entities.JenisBarangs.Where(x => x.RowStatus == 0), "ID", "Nama", mdat.ID_JenisBarang); ViewBag.ID_Vendor = new SelectList(entities.Vendors.Where(x => x.RowStatus == 0), "ID", "NamaVendor", mdat.ID_Vendor); // Session Username & Role ViewBag.NamaUser = this.Session["NamaUser"]; ViewBag.Role = this.Session["Role"]; return(View(mdat)); } }
public ActionResult Add(int ID) { string npk = this.Session["NPK"].ToString(); var data = entities.BarangPerusahaans.Where(x => x.ID == ID).First(); var check = entities.Keranjangs.Where(x => x.ID_Barang == data.ID && x.ID_Karyawan == npk).FirstOrDefault(); if (check == null) { Keranjang cart = new Keranjang(); cart.ID_Barang = data.ID; cart.ID_Karyawan = npk; cart.Qyt = 1; entities.Keranjangs.Add(cart); entities.SaveChanges(); } else { } var item = entities.BarangPerusahaans.Where(x => x.RowStatus == 0); ViewBag.Cart = entities.Keranjangs.Where(x => x.ID_Karyawan == npk); // Session Username & Role ViewBag.NamaUser = this.Session["NamaUser"]; ViewBag.Role = this.Session["Role"]; return(View("Form", item)); }
public ActionResult Create(JenisBarang mdat) { if (ModelState.IsValid) { // Change Attributes mdat.CreatedTime = DateTime.Now; mdat.RowStatus = 0; mdat.CreatedBy = this.Session["NamaUser"].ToString(); entities.JenisBarangs.Add(mdat); entities.SaveChanges(); // Session Username & Role ViewBag.NamaUser = this.Session["NamaUser"]; ViewBag.Role = this.Session["Role"]; return(RedirectToAction("Index")); } else { // Session Username & Role ViewBag.NamaUser = this.Session["NamaUser"]; ViewBag.Role = this.Session["Role"]; return(View("Create")); } }
public ActionResult Submit(int?id) { string npk = this.Session["NPK"].ToString(); Pengajuan mdat = new Pengajuan(); mdat.ID_Pengajuan = DateTime.Now.ToString("yyyyMMddHHmmss") + RandomString(3); mdat.ID_GA = npk; mdat.Tgl_Pengajuan = DateTime.Now; mdat.TotalHarga = 0; mdat.StatusPengajuan = 0; mdat.SudahDibayar = 0; mdat.StatusFinal = "-"; entities.Pengajuans.Add(mdat); var detail = entities.KeranjangPengajuans.Where(x => x.ID_Karyawan == npk); foreach (var item in detail) { DetailPengajuan dat = new DetailPengajuan(); dat.ID_Pengajuan = mdat.ID_Pengajuan; dat.ID_Barang = item.ID_Barang; dat.Kuantitas = item.Qyt; dat.HargaBarang = item.BarangVendor.Harga; dat.StatusBarang = "-"; dat.ID_Vendor = (int)item.BarangVendor.ID_Vendor; var temp = entities.BarangPerusahaans.Where(x => x.ID == item.ID_Barang).First(); dat.HargaBarang = temp.Harga; entities.DetailPengajuans.Add(dat); } entities.KeranjangPengajuans.RemoveRange(entities.KeranjangPengajuans.Where(x => x.ID_Karyawan == npk)); entities.SaveChanges(); // Session Username & Role ViewBag.NamaUser = this.Session["NamaUser"]; ViewBag.Role = this.Session["Role"]; return(RedirectToAction("Form")); }
public ActionResult Create(HttpPostedFileBase File, Karyawan mdat) { // Check Validation Form if (ModelState.IsValid && File != null) { ViewBag.PesanValidasi = ""; mdat.NPK = GenerateNPK(mdat.ID_Seksi); var ext = Path.GetExtension(File.FileName); var inputFileName = DateTime.Now.ToString("yyyyMMddHHmmss") + mdat.NPK + ext; var serverPath = Path.Combine(Server.MapPath("~/assets/img/upload/") + inputFileName); // Save File to Server Folder File.SaveAs(serverPath); // Set Attributes mdat.Foto = inputFileName; mdat.CreatedTime = DateTime.Now; mdat.RowStatus = 0; mdat.CreatedBy = this.Session["NamaUser"].ToString(); mdat.Password = RandomString(10); entities.Karyawans.Add(mdat); entities.SaveChanges(); using (MailMessage mail = new MailMessage()) { mail.From = new MailAddress("*****@*****.**"); mail.To.Add(mdat.Email); mail.Subject = "Akun Perusahaan"; mail.Body = "<h2>Hello, " + mdat.NamaKaryawan + "</h2>Berkaitan dengan website Sistem Informasi General Affair, Berikut Terlampir detail informasi akun anda<br>" + "Username : <b>" + mdat.NPK + "</b><br>Password : <b>" + mdat.Password + "</b><br>Sekian info yang dapat kami sampaikan atas perhatiannya kami ucapkan terimakasih." + "<br>Sekretaris"; mail.IsBodyHtml = true; using (SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587)) { smtp.Credentials = new NetworkCredential("*****@*****.**", "Testing1322"); smtp.EnableSsl = true; smtp.Send(mail); } } // Session Username & Role ViewBag.NamaUser = this.Session["NamaUser"]; ViewBag.Role = this.Session["Role"]; return(RedirectToAction("Index")); } else { ViewBag.PesanValidasi = "Foto profil belum dipilih"; ViewBag.ID_Role = new SelectList(entities.Roles.Where(x => x.RowStatus == 0), "ID", "NamaRole", mdat.ID_Role); ViewBag.ID_Seksi = new SelectList(entities.Sections.Where(x => x.RowStatus == 0), "ID", "NamaSection", mdat.ID_Seksi); ViewBag.JenisKelamin = new SelectList(entities.References.Where(x => x.UsedFor == "Gender"), "Value", "Deskripsi", mdat.JenisKelamin); // Session Username & Role ViewBag.NamaUser = this.Session["NamaUser"]; ViewBag.Role = this.Session["Role"]; return(View(mdat)); } }