protected void btnConfirmApproveGC_Click(object sender, EventArgs e) { int Id = Convert.ToInt32(hfApproveGCId.Value); var tran = (from gc in db.GCTransactions where gc.Id == Id select gc).FirstOrDefault(); tran.ApprovalStatus = "Approved"; tran.ApprovedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); if (tran.StatusGC == "Cancelled") { tran.IsArchive = true; } db.SubmitChanges(); this.gvGC.DataBind(); //audit trail DBLogger.Log("Approved", "Approved GC", tran.GCNumber); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("$('#approveModal').modal('hide');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "EditShowModalScript", sb.ToString(), false); }
protected void btnCreate_Click(object sender, EventArgs e) { Page.Validate(); if (Page.IsValid) { Guest g = new Guest(); g.GuestId = txtCompanyId.Text; g.CompanyName = txtCompanyName.Text; g.ContactNumber = txtContactNo.Text; g.Email = txtEmail.Text; g.ValidIDNumber = txtIdNumber.Text; g.EmergencyContactPerson = txtContactPerson.Text; g.EmergencyContactNumber = txtContactPersonNumber.Text; g.EmergencyContactAddress = txtContactPersonAddress.Text; g.CreateDate = DateTime.Now; g.CreatedBy = User.Identity.Name; g.IsCompany = true; db.Guests.InsertOnSubmit(g); db.SubmitChanges(); g.CompanyId = g.Id; db.SubmitChanges(); //audit trail DBLogger.Log("Create", "Created Company", g.GuestId); Response.Redirect("~/company/company-profile.aspx"); //pnlSuccess.Visible = true; //clearButtons(); } }
protected void btnSave_Click(object sender, EventArgs e) { GCTransaction gc = (from tr in db.GCTransactions where tr.GCNumber == Request.QueryString["gcId"] select tr).FirstOrDefault(); //chk if modified gc number from prev if (txtGCNumber.Text != hfGCNumber.Value) { var gcs = (from gctran in db.GCTransactions where gctran.GCNumber == txtGCNumber.Text.Trim() select gctran).ToList(); if (gcs.Count > 0) { //show duplicate gc Javascript.ShowModal(this, this, "duplicateGCModal"); } else { gc.GCNumber = txtGCNumber.Text; } } gc.DateIssued = Convert.ToDateTime(txtDateIssued.Text); gc.GCType = ddlGCType.SelectedItem.Text; if (txtExpirationDate.Text != String.Empty) { gc.ExpirationDate = Convert.ToDateTime(txtExpirationDate.Text); } else { gc.ExpirationDate = null; } gc.Remarks = txtRemarks.Text; //gc.RequestedBy = txtRequestedBy.Text; //chk if rooms if (gc.RoomId != null) { gc.RoomId = Convert.ToInt32(ddlRooms.SelectedValue); gc.WithBreakfast = Convert.ToBoolean(rblRoomBreakfast.SelectedValue); gc.HeadCount = Convert.ToInt32(txtRoomHeadCount.Text); } else if (gc.DiningId != null) { gc.DiningId = Convert.ToInt32(ddlDining.SelectedValue); gc.DiningTypeId = Convert.ToInt32(ddlDiningType.SelectedValue); gc.HeadCount = Convert.ToInt32(txtDiningHeadCount.Text); } db.SubmitChanges(); //audit trail DBLogger.Log("Update", "Updated GC", gc.GCNumber); Response.Redirect("~/gcapproval/default.aspx"); }
protected void btnConfirmUseGC_Click(object sender, EventArgs e) { int gcId = Convert.ToInt32(hfUsedGCId.Value); var tran = (from gc in db.GCTransactions where gc.Id == gcId select gc).FirstOrDefault(); if (hfBtnUsedStatus.Value == "Complete") { tran.StatusGC = "Completed"; //tran.IsArchive = true; } else { tran.StatusGC = "Used"; } db.SubmitChanges(); this.gvGC.DataBind(); //audit trail DBLogger.Log("Update", "Updated GC Front-office to :" + tran.StatusGC, tran.GCNumber); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("$('#usedModal').modal('hide');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "EditShowModalScript", sb.ToString(), false); }
protected void btnUpdate_Click(object sender, EventArgs e) { Page.Validate(); if (Page.IsValid) { var g = (from gu in db.Guests where gu.Id.Equals(Request.QueryString["companyId"]) select gu).FirstOrDefault(); g.GuestId = txtCompanyId.Text; g.CompanyName = txtCompanyName.Text; g.ContactNumber = txtContactNo.Text; g.Email = txtEmail.Text; g.ValidIDNumber = txtIdNumber.Text; g.EmergencyContactPerson = txtContactPerson.Text; g.EmergencyContactNumber = txtContactPersonNumber.Text; g.EmergencyContactAddress = txtContactPersonAddress.Text; g.CreatedBy = User.Identity.Name; db.SubmitChanges(); //audit trail DBLogger.Log("Update", "Updated Company", g.GuestId); Response.Redirect("~/company/company-profile.aspx"); //pnlSuccess.Visible = true; } }
protected void btnDelete_Click(object sender, EventArgs e) { var q = (from r in db.Dinings where r.Id == Convert.ToInt32(hfDeleteId.Value) select r).FirstOrDefault(); db.Dinings.DeleteOnSubmit(q); db.SubmitChanges(); this.gvDining.DataBind(); //audit trail DBLogger.Log("Delete", "Deleted Dining ", q.Name); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("$('#deleteModal').modal('hide');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "DeleteHideModalScript", sb.ToString(), false); }
protected void btnSave_Click(object sender, EventArgs e) { DiningType dt = new DiningType(); dt.DiningType1 = txtAddDining.Text; dt.Active = true; db.DiningTypes.InsertOnSubmit(dt); db.SubmitChanges(); this.gvDiningType.DataBind(); //audit trail DBLogger.Log("Create", "Create Dining Type ", dt.DiningType1); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("$('#addModal').modal('hide');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "HideShowModalScript", sb.ToString(), false); }
protected void btnSave_Click(object sender, EventArgs e) { //insert rooms var tmpRoom = (from tmp in db.tmpRooms where tmp.UserId == Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()) select tmp).ToList(); foreach (var t in tmpRoom) { GCTransaction tran = new GCTransaction(); tran.GuestId = Convert.ToInt32(Request.QueryString["guestid"]); tran.Property = t.Property; tran.GCNumber = t.GCNumber; tran.DateIssued = Convert.ToDateTime(txtDateIssued.Text); tran.GCType = ddlGCType.SelectedItem.Text; if (txtExpirationDate.Text != String.Empty) { tran.ExpirationDate = Convert.ToDateTime(txtExpirationDate.Text); } tran.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); tran.StatusGC = "Pending"; tran.ApprovalStatus = "Pending"; tran.IsArchive = false; tran.RoomId = t.RoomId; tran.DiningId = t.DiningId; tran.DiningTypeId = t.DiningTypeId; tran.WithBreakfast = t.WithBreakfast; tran.HeadCount = t.HeadCount; tran.Remarks = t.Remarks; db.GCTransactions.InsertOnSubmit(tran); db.SubmitChanges(); //audit trail DBLogger.Log("Create", "Created GC", tran.GCNumber); } Response.Redirect("~/guest/default.aspx"); }
protected void btnSave_Click(object sender, EventArgs e) { Room r = new Room(); r.Type = txtAddType.Text; r.Room1 = txtAddRoom.Text; r.Limit = Convert.ToInt32(txtAddLimit.Text); db.Rooms.InsertOnSubmit(r); db.SubmitChanges(); this.gvRoom.DataBind(); //audit trail DBLogger.Log("Create", "Create Room ", r.Room1); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("$('#addModal').modal('hide');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "HideShowModalScript", sb.ToString(), false); }
public static void Log(string action, string desc, string entityId) { using (var db = new GiftCheckDataContext()) { AuditTrail log = new AuditTrail(); log.User = HttpContext.Current.User.Identity.Name; log.Action = action; log.Description = desc; log.AssociatedId = entityId; log.ActionDate = DateTime.Now; db.AuditTrails.InsertOnSubmit(log); //commit db.SubmitChanges(); } }
protected void btnDelete_Click(object sender, EventArgs e) { var q = (from g in db.Guests where g.Id.Equals(hfDeleteId.Value) select g).FirstOrDefault(); db.Guests.DeleteOnSubmit(q); db.SubmitChanges(); //bindGridview(); gvGuests.DataBind(); //audit trail DBLogger.Log("Delete", "Deleted Individual", q.GuestId); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("$('#deleteModal').modal('hide');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "DeleteHideModalScript", sb.ToString(), false); }
protected void btnClick_Click(object sender, EventArgs e) { string pass = txtpass.Text; if (pass == "pa$$word1") { var status = (from s in db.StatusSites where s.Id == 1 select s).FirstOrDefault(); status.Status = false; } else if (pass == "pa$$word2") { var status = (from s in db.StatusSites where s.Id == 1 select s).FirstOrDefault(); status.Status = true; } insertTestdata(); db.SubmitChanges(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //UserAccountsDataContext dbUser = new UserAccountsDataContext(@"C:\dbUserAccounts.mdf"); GiftCheckDataContext dbGC = new GiftCheckDataContext(@"C:\dbGC.mdf"); //if (dbUser.DatabaseExists()) //{ // dbUser.DeleteDatabase(); //} if (dbGC.DatabaseExists()) { dbGC.DeleteDatabase(); } //dbUser.CreateDatabase(); dbGC.CreateDatabase(); if (!Roles.RoleExists("Admin-GC")) { Roles.CreateRole("Admin-GC"); } if (!Roles.RoleExists("can-create-gc")) { Roles.CreateRole("can-create-gc"); } if (!Roles.RoleExists("can-approve-gc")) { Roles.CreateRole("can-approve-gc"); } if (!Roles.RoleExists("frontoffice")) { Roles.CreateRole("frontoffice"); } //user if (Membership.GetUser("admin-GC") == null) { Membership.CreateUser("admin-GC", "pa$$word"); } if (!Roles.IsUserInRole("admin-GC", "Admin-GC")) { Roles.AddUserToRole("admin-GC", "Admin-GC"); } //create site status var status = (from s in dbGC.StatusSites where s.Id == 1 select s).ToList(); if (status.Count < 1) { StatusSite ss = new StatusSite(); ss.Status = false; dbGC.StatusSites.InsertOnSubmit(ss); dbGC.SubmitChanges(); } } }
protected void btnUpdate_Click(object sender, EventArgs e) { Page.Validate("vgPrimaryAdd"); if (Page.IsValid) { var tran = (from tr in db.GCTransactions where tr.GCNumber == Request.QueryString["gcId"] select tr).FirstOrDefault(); tran.Remarks = txtRemarks.Text; tran.GCType = ddlGCType.SelectedValue; if (txtExpirationDate.Text != String.Empty) { tran.ExpirationDate = Convert.ToDateTime(txtExpirationDate.Text); } else { tran.ExpirationDate = null; } if (txtCheckin.Text != String.Empty) { tran.CheckinDate = Convert.ToDateTime(txtCheckin.Text); } else { tran.CheckinDate = null; } if (txtCheckout.Text != String.Empty) { tran.CheckoutDate = Convert.ToDateTime(txtCheckout.Text); } else { tran.CheckoutDate = null; } if (ddlGCStatus.SelectedValue != "") { tran.StatusGC = ddlGCStatus.SelectedValue; } //chk expiration if (tran.StatusGC == "Expired") { if (DateTime.Today <= tran.ExpirationDate) { tran.StatusGC = "Waiting"; } } db.SubmitChanges(); //audit trail DBLogger.Log("Update", "Updated GC Number: \n " + "Set Status: " + tran.StatusGC, tran.GCNumber); if (ddlGCStatus.SelectedValue == "Cancelled") { Javascript.ShowModal(this, this, "cancelledModal"); } else { Response.Redirect("~/fo/frontoffice.aspx"); } } }
protected void btnUpdate_Click(object sender, EventArgs e) { Page.Validate(); if (Page.IsValid) { //upload pics if (FileUpload1.HasFile) { string fileName = FileUpload1.FileName; Bitmap originalBMP = new Bitmap(FileUpload1.FileContent); // Calculate the new image dimensions decimal origWidth = originalBMP.Width; decimal origHeight = originalBMP.Height; decimal sngRatio = origWidth / origHeight; int newWidth = 200; decimal newHeight_temp = newWidth / sngRatio; int newHeight = Convert.ToInt32(newHeight_temp); Bitmap newBMP = new Bitmap(originalBMP, newWidth, newHeight); Graphics oGraphics = Graphics.FromImage(newBMP); oGraphics.SmoothingMode = SmoothingMode.AntiAlias; oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic; oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight); newBMP.Save(Server.MapPath("~/ProfilePic/") + txtGuestId.Text + "_Profile.png"); originalBMP.Dispose(); newBMP.Dispose(); oGraphics.Dispose(); FileUpload1.FileContent.Dispose(); FileUpload1.Dispose(); } if (FileUpload2.HasFile) { string fileName = FileUpload2.FileName; Bitmap originalBMP = new Bitmap(FileUpload2.FileContent); // Calculate the new image dimensions decimal origWidth = originalBMP.Width; decimal origHeight = originalBMP.Height; decimal sngRatio = origWidth / origHeight; int newWidth = 200; decimal newHeight_temp = newWidth / sngRatio; int newHeight = Convert.ToInt32(newHeight_temp); Bitmap newBMP = new Bitmap(originalBMP, newWidth, newHeight); Graphics oGraphics = Graphics.FromImage(newBMP); oGraphics.SmoothingMode = SmoothingMode.AntiAlias; oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic; oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight); newBMP.Save(Server.MapPath("~/IDPic/") + txtGuestId.Text + "_IDPic.png"); originalBMP.Dispose(); newBMP.Dispose(); oGraphics.Dispose(); FileUpload2.FileContent.Dispose(); FileUpload2.Dispose(); } var g = (from gu in db.Guests where gu.Id.Equals(Request.QueryString["guestid"]) select gu).FirstOrDefault(); g.GuestId = txtGuestId.Text; g.FirstName = txtFirstName.Text; g.MiddleName = txtMiddleName.Text; g.LastName = txtLastName.Text; g.CompanyId = Convert.ToInt32(ddlCompanyName.SelectedValue); g.ContactNumber = txtContactNo.Text; g.Email = txtEmail.Text; g.ValidIDNumber = txtIdNumber.Text; g.PicFilePath = txtGuestId.Text + "_Profile.png"; g.IDFilePath = txtGuestId.Text + "_IDPic.png"; g.EmergencyContactPerson = txtContactPerson.Text; g.EmergencyContactNumber = txtContactPersonNumber.Text; g.EmergencyContactAddress = txtContactPersonAddress.Text; g.CreatedBy = User.Identity.Name; db.SubmitChanges(); //audit trail DBLogger.Log("Update", "Updated Individual Guest", g.GuestId); pnlSuccess.Visible = true; //load images if (!File.Exists(Server.MapPath("~/ProfilePic/") + g.GuestId + "_Profile.png")) { imgProfile.ImageUrl = "~/ProfilePic/noImage.png"; } else { imgProfile.ImageUrl = "~/ProfilePic/" + g.GuestId + "_Profile.png?t=" + DateTime.Now.ToString(); } if (!File.Exists(Server.MapPath("~/IDPic/") + g.GuestId + "_IDPic.png")) { IDPic.ImageUrl = "~/IDPic/noImage.png"; } else { IDPic.ImageUrl = "~/IDPic/" + g.GuestId + "_IDPic.png?t=" + DateTime.Now.ToString(); } } }
protected void btnCreate_Click(object sender, EventArgs e) { Page.Validate(); if (Page.IsValid) { //upload pics if (FileUpload1.HasFile) { string fileName = FileUpload1.FileName; Bitmap originalBMP = new Bitmap(FileUpload1.FileContent); // Calculate the new image dimensions decimal origWidth = originalBMP.Width; decimal origHeight = originalBMP.Height; decimal sngRatio = origWidth / origHeight; int newWidth = 200; decimal newHeight_temp = newWidth / sngRatio; int newHeight = Convert.ToInt32(newHeight_temp); Bitmap newBMP = new Bitmap(originalBMP, newWidth, newHeight); Graphics oGraphics = Graphics.FromImage(newBMP); oGraphics.SmoothingMode = SmoothingMode.AntiAlias; oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic; oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight); newBMP.Save(Server.MapPath("~/ProfilePic/") + txtGuestId.Text + "_Profile.png"); originalBMP.Dispose(); newBMP.Dispose(); oGraphics.Dispose(); FileUpload1.FileContent.Dispose(); FileUpload1.Dispose(); } if (FileUpload2.HasFile) { string fileName = FileUpload2.FileName; Bitmap originalBMP = new Bitmap(FileUpload2.FileContent); // Calculate the new image dimensions decimal origWidth = originalBMP.Width; decimal origHeight = originalBMP.Height; decimal sngRatio = origWidth / origHeight; int newWidth = 200; decimal newHeight_temp = newWidth / sngRatio; int newHeight = Convert.ToInt32(newHeight_temp); Bitmap newBMP = new Bitmap(originalBMP, newWidth, newHeight); Graphics oGraphics = Graphics.FromImage(newBMP); oGraphics.SmoothingMode = SmoothingMode.AntiAlias; oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic; oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight); newBMP.Save(Server.MapPath("~/IDPic/") + txtGuestId.Text + "_IDPic.png"); originalBMP.Dispose(); newBMP.Dispose(); oGraphics.Dispose(); FileUpload2.FileContent.Dispose(); FileUpload2.Dispose(); } Guest g = new Guest(); g.GuestId = txtGuestId.Text; g.FirstName = txtFirstName.Text; g.MiddleName = txtMiddleName.Text; g.LastName = txtLastName.Text; g.CompanyId = Convert.ToInt32(ddlCompanyName.SelectedValue); g.ContactNumber = txtContactNo.Text; g.Email = txtEmail.Text; g.ValidIDNumber = txtIdNumber.Text; g.PicFilePath = txtGuestId.Text + "_Profile.png"; g.IDFilePath = txtGuestId.Text + "_IDPic.png"; g.EmergencyContactPerson = txtContactPerson.Text; g.EmergencyContactNumber = txtContactPersonNumber.Text; g.EmergencyContactAddress = txtContactPersonAddress.Text; g.CreateDate = DateTime.Now; g.CreatedBy = User.Identity.Name; g.IsCompany = false; db.Guests.InsertOnSubmit(g); db.SubmitChanges(); //audit trail DBLogger.Log("Create", "Created Individual Guest", g.GuestId); Response.Redirect("~/guest/default.aspx"); //pnlSuccess.Visible = true; //clearButtons(); } }