protected void Page_Load(object sender, EventArgs e) { Id = Convert.ToInt32(Request["id"]); if (!IsPostBack) { var scriptManager = (RadScriptManager)Page.Master.FindControl("RadScriptManager1"); //scriptManager.Scripts.Add(new ScriptReference() { Path = ResolveUrl("~/assets/js/jquery.printArea.js") }); //scriptManager.RegisterPostBackControl(RadButtonFileDownload); var obj = new CVacation(); var vacationDetail = obj.Get(Id); var cUser = new CUser(); var user = cUser.Get((int)vacationDetail.CreatedId); ViewState["UserId"] = user.UserId; SetVisibleItems(false); var dt = new DataTable(); dt.Columns.Add("FullName"); dt.Columns.Add("Site"); dt.Columns.Add("SiteLocation"); var newDr = dt.NewRow(); newDr["FullName"] = cUser.GetUserName(user); var campus = (new CSiteLocation()).Get(user.SiteLocationId); newDr["SiteLocation"] = campus.Name; var site = (new CSite()).Get(campus.SiteId); newDr["Site"] = site.Name; dt.Rows.Add(newDr); RadGridInfo.DataSource = dt; } }
protected void Login_Click(object sender, EventArgs e) { if (IsValid) { var cUser = new CUser(); var user = cUser.Get(tbUsername.Text.Trim()); if (user != null) { if (CCryptography.DecryptCipherTextToPlainText(user.Password.Trim()) == tbPassword.Text.Trim()) { if (user.IsActive) { btLogin.Enabled = false; Session["UserId"] = user.UserId; Session["SiteLocationId"] = user.SiteLocationId; var siteLocation = (new CSiteLocation()).Get(user.SiteLocationId); if (siteLocation != null) { Session["SiteId"] = siteLocation.SiteId; Session["SiteName"] = new CSite().Get(siteLocation.SiteId)?.Abbreviation; Session["SiteLocationName"] = siteLocation.Name; } Session["UserName"] = cUser.GetUserName(user); Session["UserPositionId"] = user.UserPositionId; var userPosition = (new CUserPosition()).Get(user.UserPositionId); if (userPosition != null) { Session["UserGroupId"] = userPosition.UserGroupId; } var userPermissionModelList = (new CUserPermission()).GetUserPermissionModelList(user.UserId); Session["UserPermissionModelList"] = userPermissionModelList; RadAjaxPanel1.Redirect("~/Dashboard"); } else { ShowMessage("Your account is disabled<br /><br />Please contact administrator."); } // set cookie WriteCookie("IsKeepSign", RadButtonKeepSign.Checked ? "1" : "0"); if (RadButtonKeepSign.Checked) { WriteCookie("Username", tbUsername.Text.Trim()); } } else { ShowMessage("Wrong Password<br /><br />Please try again!"); } } else { ShowMessage("Invalid Login Id<br /><br />Please try again!"); } } }
public void SetData() { var cUser = new CUser(); var user = cUser.Get(CurrentUserId); var invoice = new CInvoice().Get(Convert.ToInt32(ReportParameters["InvoiceId"].Value)); if (invoice != null) { var logoPath = new CGlobal().GetLogoImagePath((int)invoice.SiteLocationId); if (logoPath != string.Empty) { companyLogoPictureBox.Value = Image.FromFile(logoPath); } } }
public RInvoice(int reportType, int currentUserId, int invoiceId) { // // Required for telerik Reporting designer support // InitializeComponent(); ReportParameters["InvoiceId"].Value = invoiceId; var cUser = new CUser(); var user = cUser.Get(currentUserId); textBoxInvoiceIssuer.Value = cUser.GetUserName(user); switch (reportType) { case (int)CConstValue.Report.InvoiceStudent: // default break; case (int)CConstValue.Report.InvoiceAgency: textBoxInvoiceTitle.Value = "Invoice (Net)"; itemDescriptionTextBoxStudentPrice.Value = "= Fields.AgencyPrice"; textBoxStudentPriceSum1.Value = "=Sum(Fields.AgencyPrice)"; textBoxStudentPriceSum2.Value = "=Sum(Fields.AgencyPrice)"; break; } var invoice = new CInvoice().Get(invoiceId); if (invoice != null) { var logoPath = new CGlobal().GetLogoImagePath((int)invoice.SiteLocationId, CConstValue.ImageType.Basic); if (logoPath != string.Empty) { companyLogoPictureBox.Value = Image.FromFile(logoPath); } } }
public RInvoiceLumpSum(int reportType, int currentUserId, string invoiceArray) { // // Required for telerik Reporting designer support // InitializeComponent(); // = Split(",", "26427, 26429") => filter // In (Parameters.InvoiceId.Value, Parameters.InvoiceId2.Value) => query sqlDataSourceInvoiceDetail.Parameters[0].Value = "In (" + invoiceArray + ")"; tableTotal.Filters[0].Value = "= Split(\",\", \"" + invoiceArray + "\")"; switch (reportType) { case (int)CConstValue.Report.InvoiceStudent: // default break; case (int)CConstValue.Report.InvoiceAgency: textBoxInvoiceTitle.Value = "Invoice Lump Sum (Net)"; textBoxStudentPriceSum1.Value = "=Sum(Fields.AgencyPrice)"; break; } var cUser = new CUser(); var user = cUser.Get(currentUserId); textBoxInvoiceIssuer.Value = cUser.GetUserName(user); var logoPath = new CGlobal().GetLogoImagePath(user.SiteLocationId, CConstValue.ImageType.Basic); if (logoPath != string.Empty) { companyLogoPictureBox.Value = Image.FromFile(logoPath); } }
protected void DataBound(GridDataItem DataItem) { // GridDataItem DataItem = e.Item as GridDataItem; // int HomestayStudentId = Convert.ToInt32(DataItem["HomestayStudentId"].Text.ToString().Trim()); //HB.UrgentRequest AS UrgentFlag, string UgentFlag = ""; switch (DataItem["UrgentFlag"].Text.Trim().ToString()) { case "0": UgentFlag = "-"; break; case "1": UgentFlag = "No"; break; case "2": UgentFlag = "Yes"; break; } DataItem["UrgentFlag"].Text = UgentFlag; //HB.ExtensionFlag, HB.MealType, string ExtensionFlag = ""; switch (DataItem["ExtensionFlag"].Text.Trim().ToString()) { case "0": ExtensionFlag = "-"; break; case "1": ExtensionFlag = "No"; break; case "2": ExtensionFlag = "Yes"; break; } DataItem["ExtensionFlag"].Text = ExtensionFlag; //HB.PickUp, string PickUp = ""; switch (DataItem["PickUp"].Text.Trim().ToString()) { case "0": PickUp = "-"; break; case "1": PickUp = "No"; break; case "2": PickUp = "Yes"; break; } DataItem["PickUp"].Text = PickUp; //HB.DropOff, string DropOff = ""; switch (DataItem["DropOff"].Text.Trim().ToString()) { case "0": DropOff = "-"; break; case "1": DropOff = "No"; break; case "2": DropOff = "Yes"; break; } DataItem["DropOff"].Text = DropOff; //HB.GuardianRequired, string GuardianRequired = ""; switch (DataItem["GuardianRequired"].Text.Trim().ToString()) { case "0": GuardianRequired = "-"; break; case "1": GuardianRequired = "No"; break; case "2": GuardianRequired = "Yes"; break; } DataItem["GuardianRequired"].Text = GuardianRequired; //HB.Internet, string Internet = ""; switch (DataItem["Internet"].Text.Trim().ToString()) { case "0": Internet = "-"; break; case "1": Internet = "No"; break; case "2": Internet = "Yes"; break; } DataItem["Internet"].Text = Internet; //HB.HomestayStudentStatus, string HomestayStudentStatus = ""; switch (DataItem["HomestayStudentStatus"].Text.Trim().ToString()) { case "0": HomestayStudentStatus = "Pending"; break; case "1": HomestayStudentStatus = "Requested"; break; case "2": HomestayStudentStatus = "Placed by School"; break; case "3": HomestayStudentStatus = "Placed by Agency"; break; case "6": HomestayStudentStatus = "Cacelled by Agency"; break; case "7": HomestayStudentStatus = "Rejected by Agency"; break; case "4": HomestayStudentStatus = "Canceled"; break; case "5": HomestayStudentStatus = "Schedule Change"; break; } DataItem["HomestayStudentStatus"].Text = HomestayStudentStatus; //HB.MealType string MealType = ""; switch (DataItem["MealType"].Text.Trim().ToString()) { case "0": MealType = "-"; break; case "1": MealType = "Half Meal"; break; case "2": MealType = "Full Meal"; break; } DataItem["MealType"].Text = MealType; //HB.PlacedUserId string PlacedByName = "-"; string userid = DataItem["PlacedUserId"].Text.Trim().ToString(); if (Convert.ToInt32(userid) > 0) { var cUser = new CUser(); User user = cUser.Get(Convert.ToInt32(userid)); PlacedByName = cUser.GetUserName(user); } DataItem["PlacedUserId"].Text = PlacedByName; }
protected void StaffButtonClicked(object sender, RadToolBarEventArgs e) { if (e.Item.Text == @"New") { ResetForm(); } else if (e.Item.Text == @"Update" && RadGridUser.SelectedValue != null) { if (IsValid) { var cUser = new CUser(); var user = cUser.Get(Convert.ToInt32(RadGridUser.SelectedValue)); if (string.IsNullOrEmpty(tbPassWord.Text) == false) { user.Password = CCryptography.EncryptPlainTextToCipherText(tbPassWord.Text.Trim()); } user.FirstName = tbFName.Text; user.MidName = tbMName.Text; user.LastName = tbLName.Text; user.DOB = tbDOB.SelectedDate; user.MaritalStatus = ddlMarital.SelectedValue; user.Gender = ddlGender.SelectedValue; user.Email = tbWEmail.Text.Trim(); user.Phone = tbWPhone.Text.Trim(); user.EContactName = tbEName.Text; user.ERelation = tbERelation.Text; user.EPhone = tbEPhone.Text; user.EAddress = tbEAddress.Text; // only HR or IT can modify those things. if (CurrentGroupId == (int)CConstValue.UserGroupForUserInformation.HR || CurrentGroupId == (int)CConstValue.UserGroupForUserInformation.IT) { user.UserPositionId = Convert.ToInt32(RadComboBoxUserPosition.SelectedValue); user.SINNo = Convert.ToInt32(tbSIN.Text); user.SiteLocationId = Convert.ToInt32(RadComboBoxSiteLocation.SelectedValue); user.EmployeeNumber = tbEmpNo.Text; user.IsActive = cbActive.Checked; int?supervisor = string.IsNullOrEmpty(RadComboBoxSuper.SelectedValue) ? (int?)null : Convert.ToInt32(RadComboBoxSuper.SelectedValue); if (user.Supervisor != supervisor) { user.Supervisor = supervisor; var cApp = new CApproval(); var appList = cApp.GetList(Convert.ToInt32(RadGridUser.SelectedValue)); foreach (var app in appList) { app.Supervisor = user.Supervisor; app.IsActive = user.IsActive; app.UpdatedId = CurrentUserId; app.UpdatedDate = DateTime.Now; cApp.Update(app); } } } user.Address1 = tbPAddess1.Text; user.Address2 = tbPAddess2.Text; user.City = tbPCity.Text; user.Province = tbPProvince.Text; user.PostalCode = tbPPostal.Text; user.HomePhone = tbPHomePhone.Text; user.CellPhone = tbPCell.Text; user.PersonalEmail = tbPEmail.Text; user.UpdatedId = CurrentUserId; user.UpdatedDate = DateTime.Now; if (AsyncUploadPicture.UploadedFiles.Count > 0) { UploadedFile file = AsyncUploadPicture.UploadedFiles[0]; byte[] fileData = new byte[file.InputStream.Length]; file.InputStream.Read(fileData, 0, (int)file.InputStream.Length); user.Picture = fileData; } if (cUser.Update(user)) { RadGridUser.Rebind(); ShowMessage("Updated Staff Info Successfully"); } else { ShowMessage("Failed To Update Staff Info"); } } } else if (e.Item.Text == @"Save") { if (IsValid) { var cUser = new CUser(); var user = new Erp2016.Lib.User(); if (CurrentSiteId != 1) { user.SiteLocationId = Convert.ToInt32(CurrentSiteLocationId); } else { user.SiteLocationId = Convert.ToInt32(RadComboBoxSiteLocation.SelectedValue); } user.LoginId = tbUserID.Text; user.Password = CCryptography.EncryptPlainTextToCipherText(tbPassWord.Text.Trim()); user.FirstName = tbFName.Text; user.MidName = tbMName.Text; user.LastName = tbLName.Text; user.SINNo = Convert.ToInt32(tbSIN.Text); user.DOB = tbDOB.SelectedDate; user.MaritalStatus = ddlMarital.SelectedValue; user.Gender = ddlGender.SelectedValue; user.Email = tbWEmail.Text.Trim(); user.Phone = tbWPhone.Text.Trim(); user.UserPositionId = Convert.ToInt32(RadComboBoxUserPosition.SelectedValue); if (!string.IsNullOrEmpty(RadComboBoxSuper.SelectedValue)) { user.Supervisor = Convert.ToInt32(RadComboBoxSuper.SelectedValue); } user.EmployeeNumber = tbEmpNo.Text; user.EContactName = tbEName.Text; user.ERelation = tbERelation.Text; user.EPhone = tbEPhone.Text; user.EAddress = tbEAddress.Text; user.Address1 = tbPAddess1.Text; user.Address2 = tbPAddess2.Text; user.City = tbPCity.Text; user.Province = tbPProvince.Text; user.PostalCode = tbPPostal.Text; user.HomePhone = tbPHomePhone.Text; user.CellPhone = tbPCell.Text; user.PersonalEmail = tbPEmail.Text; user.IsActive = true; user.CreatedId = CurrentUserId; user.CreatedDate = DateTime.Now; if (AsyncUploadPicture.UploadedFiles.Count > 0) { UploadedFile file = AsyncUploadPicture.UploadedFiles[0]; byte[] fileData = new byte[file.InputStream.Length]; file.InputStream.Read(fileData, 0, (int)file.InputStream.Length); user.Picture = fileData; } int newUserId = cUser.Add(user); if (newUserId > 0) { var tempSupervisor = user.Supervisor ?? CConstValue.UserSystemId; var cApproval = new CApproval(); var approval = cApproval.GetAppType(tempSupervisor); foreach (var a in approval) { var type = new Approval(); type.ApproveType = a.ApproveType; type.UserId = newUserId; type.Supervisor = a.UserId; type.IsActive = true; type.CreatedId = CurrentUserId; type.CreatedDate = DateTime.Now; cApproval.Add(type); } // vacation Schema var cVacationSchema = new CVacationSchema(); var isKgic = new CSite().Get(new CSiteLocation().Get(user.SiteLocationId).SiteId).Abbreviation.ToLower() == "kgic"; for (var i = 1; i <= 6; i++) { var vacationType = 0; var date = i % 2 == 0 ? DateTime.Today.AddYears(1) : DateTime.Today; switch (i) { case 1: case 2: vacationType = (int)CConstValue.VacationType.PaidVacationDay; break; case 3: case 4: vacationType = (int)CConstValue.VacationType.SickDay; break; case 5: case 6: if (isKgic == false) { continue; } vacationType = (int)CConstValue.VacationType.EntitlementDay; break; } cVacationSchema.Add(new VacationSchema { Date = date, UserId = newUserId, VacationType = vacationType, TotalDays = 0, CreatedId = CurrentUserId, CreatedDate = DateTime.Now }); } // user permission new CUserPermission().SetBasicPermission(user, CurrentUserId); RadGridUser.Rebind(); ShowMessage(new CUser().GetUserName(user) + " has been successfully created"); } else { ShowMessage("Failed To Add Staff Info"); } } } else if (e.Item.Text == "Permission") { if (RadGridUser.SelectedValue != null) { RunClientScript("ShowPermission(" + RadGridUser.SelectedValue + ");"); } } else if (e.Item.Text == "User Information") { if (RadGridUser.SelectedValue != null) { RunClientScript("ShowUserInformation(" + RadGridUser.SelectedValue + ");"); } } }
protected void GetStaffInfo() { if (RadGridUser.SelectedValue != null) { var cUser = new CUser(); var user = cUser.Get(Convert.ToInt32(RadGridUser.SelectedValue)); if (user.UserId > 0) { var cSiteLocation = new CSiteLocation(); var siteLocation = cSiteLocation.Get(user.SiteLocationId); LoadSite(siteLocation.SiteId); LoadSiteLocation(siteLocation.SiteId); LoadUserGroup(siteLocation.SiteId); LoadSupervisor(); RadComboBoxSite.SelectedValue = siteLocation.SiteId.ToString(); RadComboBoxSiteLocation.SelectedValue = user.SiteLocationId.ToString(); var cUserPosition = new CUserPosition(); var userPosition = cUserPosition.Get(user.UserPositionId); if (userPosition != null) { RadComboBoxUserGroup.SelectedValue = userPosition.UserGroupId.ToString(); LoadUserPosition(userPosition.UserGroupId); RadComboBoxUserPosition.SelectedValue = user.UserPositionId.ToString(); } RadComboBoxSuper.SelectedValue = user.Supervisor.ToString(); tbUserID.Enabled = false; tbUserID.Text = user.LoginId; //tbPassWord.Text = user.Password; tbFName.Text = user.FirstName; tbMName.Text = user.MidName; tbLName.Text = user.LastName; tbSIN.Text = Convert.ToString(user.SINNo); tbDOB.SelectedDate = user.DOB; DateTime Today = DateTime.Now; DateTime Dob = Convert.ToDateTime(user.DOB); TimeSpan ts = Today - Dob; DateTime Age = DateTime.MinValue + ts; int Years = Age.Year - 1; tbAge.Text = Years.ToString(); ddlMarital.SelectedValue = user.MaritalStatus; ddlGender.SelectedValue = user.Gender; tbWEmail.Text = user.Email; tbWPhone.Text = user.Phone; tbEmpNo.Text = user.EmployeeNumber; cbActive.Checked = user.IsActive; tbPAddess1.Text = user.Address1; tbPAddess2.Text = user.Address2; tbPCity.Text = user.City; tbPProvince.Text = user.Province; tbPPostal.Text = user.PostalCode; tbPHomePhone.Text = user.HomePhone; tbPCell.Text = user.CellPhone; tbPEmail.Text = user.PersonalEmail; tbEName.Text = user.EContactName; tbERelation.Text = user.ERelation; tbEPhone.Text = user.EPhone; tbEAddress.Text = user.EAddress; // pic if (user.Picture != null) { RadBinaryImagePicture.DataValue = user.Picture.ToArray(); RadBinaryImagePicture.Visible = true; } else { RadBinaryImagePicture.DataValue = null; RadBinaryImagePicture.Visible = false; } if (RadToolBarUser.FindItemByText("New") != null) { RadToolBarUser.FindItemByText("New").Enabled = true; } if (RadToolBarUser.FindItemByText("Save") != null) { RadToolBarUser.FindItemByText("Save").Text = @"Update"; } } } }
protected void DataBound(GridDataItem DataItem) { // GridDataItem DataItem = e.Item as GridDataItem; // int HomestayStudentId = Convert.ToInt32(DataItem["HomestayStudentId"].Text.ToString().Trim()); //HB.UrgentRequest AS UrgentFlag, string UgentFlag = ""; switch (DataItem["UrgentFlag"].Text.Trim().ToString()) { case "0": UgentFlag = "-"; break; case "1": UgentFlag = "No"; break; case "2": UgentFlag = "Yes"; break; } DataItem["UrgentFlag"].Text = UgentFlag; string ExtensionFlag = ""; switch (DataItem["ExtensionFlag"].Text.Trim().ToString()) { case "0": ExtensionFlag = "-"; break; case "1": ExtensionFlag = "No"; break; case "2": ExtensionFlag = "Yes"; break; } DataItem["ExtensionFlag"].Text = ExtensionFlag; //HB.PickUp, string PickUp = ""; switch (DataItem["PickUp"].Text.Trim().ToString()) { case "0": PickUp = "-"; break; case "1": PickUp = "No"; break; case "2": PickUp = "Yes"; break; } DataItem["PickUp"].Text = PickUp; //HB.DropOff, string DropOff = ""; switch (DataItem["DropOff"].Text.Trim().ToString()) { case "0": DropOff = "-"; break; case "1": DropOff = "No"; break; case "2": DropOff = "Yes"; break; } DataItem["DropOff"].Text = DropOff; //HB.StudentStatus, string HomestayStudentStatus = ""; switch (DataItem["DormitoryStudentStatus"].Text.Trim().ToString()) { case "0": HomestayStudentStatus = "Pending"; break; case "1": HomestayStudentStatus = "Requested"; break; case "2": HomestayStudentStatus = "Placed"; break; case "4": HomestayStudentStatus = "Canceled"; break; case "5": HomestayStudentStatus = "Schedule Change"; break; } DataItem["DormitoryStudentStatus"].Text = HomestayStudentStatus; //HB.PlacedUserId string PlacedByName = "-"; string userid = DataItem["PlacedUserId"].Text.Trim().ToString(); if (Convert.ToInt32(userid) > 0) { var cUser = new CUser(); User user = cUser.Get(Convert.ToInt32(userid)); PlacedByName = cUser.GetUserName(user); } DataItem["PlacedUserId"].Text = PlacedByName; }
public RPayment(int reportType, int currentUserId, int invoiceId, string paymentArray = null) { // // Required for telerik Reporting designer support // InitializeComponent(); ReportParameters["InvoiceId"].Value = invoiceId; var cUser = new CUser(); var user = cUser.Get(currentUserId); textBoxReceiptIssuer.Value = cUser.GetUserName(user); var sqlDataSourcePaymentHistoryParameter = sqlDataSourcePaymentHistory.Parameters[0]; var detailsTableFilter = detailsTable.Filters[0]; var tableTotalFilter = tableTotal.Filters[0]; switch (reportType) { case (int)CConstValue.Report.PaymentStudent: // default break; case (int)CConstValue.Report.PaymentAgency: // Payment textBoxInvoiceTitle.Value = "Receipt (Net)"; textBoxTotalInvoice.Value = "= Fields.AgencyPriceSum"; textBoxBalance.Value = "= Fields.AgencyPriceSum - Fields.PayAmount"; // Invoice itemDescriptionTextBoxStudentPrice.Value = "= Fields.AgencyPrice"; textBoxStudentPriceSum2.Value = "=Sum(Fields.AgencyPrice)"; break; case (int)CConstValue.Report.DetailPaymentStudent: sqlDataSourcePaymentHistoryParameter.Name = "PaymentId"; sqlDataSourcePaymentHistoryParameter.Value = "In (" + paymentArray + ")"; detailsTableFilter.Expression = "= Fields.PaymentId"; detailsTableFilter.Operator = FilterOperator.In; detailsTableFilter.Value = "= Split(\",\", \"" + paymentArray + "\")"; tableTotalFilter.Expression = "= Fields.PaymentId"; tableTotalFilter.Operator = FilterOperator.In; tableTotalFilter.Value = "= Split(\",\", \"" + paymentArray + "\")"; break; case (int)CConstValue.Report.DetailPaymentAgency: sqlDataSourcePaymentHistoryParameter.Name = "PaymentId"; sqlDataSourcePaymentHistoryParameter.Value = "In (" + paymentArray + ")"; detailsTableFilter.Expression = "= Fields.PaymentId"; detailsTableFilter.Operator = FilterOperator.In; detailsTableFilter.Value = "= Split(\",\", \"" + paymentArray + "\")"; tableTotalFilter.Expression = "= Fields.PaymentId"; tableTotalFilter.Operator = FilterOperator.In; tableTotalFilter.Value = "= Split(\",\", \"" + paymentArray + "\")"; // additional textBoxInvoiceTitle.Value = "Receipt (Net)"; textBoxTotalInvoice.Value = "= Fields.AgencyPriceSum"; textBoxBalance.Value = "= Fields.AgencyPriceSum - Fields.PayAmount"; // Invoice itemDescriptionTextBoxStudentPrice.Value = "= Fields.AgencyPrice"; textBoxStudentPriceSum2.Value = "=Sum(Fields.AgencyPrice)"; break; } var invoice = new CInvoice().Get(invoiceId); if (invoice != null) { var logoPath = new CGlobal().GetLogoImagePath((int)invoice.SiteLocationId, CConstValue.ImageType.Basic); if (logoPath != string.Empty) { companyLogoPictureBox.Value = Image.FromFile(logoPath); } } }
protected void Page_Load(object sender, EventArgs e) { Id = Convert.ToInt32(Request["id"]); if (!IsPostBack) { //var scriptManager = (RadScriptManager)Page.Master.FindControl("RadScriptManager1"); //scriptManager.RegisterPostBackControl(RadButtonFileDownload); FileDownloadList1.InitFileDownloadList((int)CConstValue.Upload.BulletinBoard); // new if (Request["createOrListType"] == "0") { var cUser = new CUser(); var user = cUser.Get(CurrentUserId); RadTextBoxUserName.Text = cUser.GetUserName(user); RadDatePickerDate.SelectedDate = DateTime.Today; } // select else { var cBulletinBoard = new CBulletinBoard(); var bulletinBoard = cBulletinBoard.Get(Id); if (bulletinBoard != null) { var cUser = new CUser(); var user = cUser.Get((int)bulletinBoard.CreatedId); RadTextBoxUserName.Text = cUser.GetUserName(user); RadDatePickerDate.SelectedDate = bulletinBoard.CreatedDate; RadTextBoxSubject.Text = bulletinBoard.Subject; RadEditorBody.Content = bulletinBoard.Body; // update views bulletinBoard.Views++; cBulletinBoard.Update(bulletinBoard); // view if (CurrentUserId != bulletinBoard.CreatedId) { RadTextBoxSubject.Enabled = false; RadEditorBody.EditModes = EditModes.Preview; FileDownloadList1.SetVisibieUploadControls(false); foreach (RadToolBarItem item in RadToolBar1.Items) { if (item.Text == "Save") { item.Visible = false; break; } } } } // UP LOAD FileDownloadList1.GetFileDownload(Convert.ToInt32(Id)); } } }
protected void Page_Load(object sender, EventArgs e) { Id = Convert.ToInt32(Request["id"]); if (!IsPostBack) { foreach (GridColumn v in RadGridPurchaseOrderDetail.Columns) { if (v.GetType() == typeof(GridTemplateColumn)) { var column = (GridTemplateColumn)v; switch (column.UniqueName) { case "Quantity": column.DefaultInsertValue = "1"; break; } } } var scriptManager = (RadScriptManager)Page.Master.FindControl("RadScriptManager1"); //scriptManager.Scripts.Add(new ScriptReference() { Path = ResolveUrl("~/assets/js/jquery.printArea.js") }); //scriptManager.RegisterPostBackControl(RadButtonFileDownload); FileDownloadList1.InitFileDownloadList((int)CConstValue.Upload.PurchaseOrder); var global = new CGlobal(); RadComboBoxType.DataSource = global.GetDictionary(1466); RadComboBoxType.DataTextField = "Name"; RadComboBoxType.DataValueField = "Value"; RadComboBoxType.DataBind(); RadComboBoxPriority.DataSource = global.GetDictionary(1470); RadComboBoxPriority.DataTextField = "Name"; RadComboBoxPriority.DataValueField = "Value"; RadComboBoxPriority.DataBind(); RadComboBoxShippingMethod.DataSource = global.GetDictionary(1471); RadComboBoxShippingMethod.DataTextField = "Name"; RadComboBoxShippingMethod.DataValueField = "Value"; RadComboBoxShippingMethod.DataBind(); RadComboBoxReviewType.DataSource = global.GetDictionary(1489); RadComboBoxReviewType.DataTextField = "Name"; RadComboBoxReviewType.DataValueField = "Value"; RadComboBoxReviewType.DataBind(); RadComboBoxReviewType.Items.Add(new RadComboBoxItem("N/A", null)); RadComboBoxReviewType.SelectedIndex = RadComboBoxReviewType.Items.Count - 1; var obj = new CPurchaseOrder(); var requestOrApprovalType = Request["requestOrApprovalType"]; var approvalType = Request["approvalType"]; var buttonList = new List <string>(); // new if (Request["createOrListType"] == "0") { obj = obj.GetNewDocument(CurrentUserId); buttonList.Add("TempSave"); buttonList.Add("Request"); buttonList.Add("Close"); SetVisibleItems(true); } // select else { FileDownloadList1.GetFileDownload(Convert.ToInt32(Id)); // date obj = new CPurchaseOrder(Id); // request list if (requestOrApprovalType == "0") { // Revise if (approvalType == ((int)CConstValue.ApprovalStatus.Revise).ToString()) { buttonList.Add("Request"); buttonList.Add("Cancel"); buttonList.Add("Close"); SetVisibleItems(true); } // TempSave else if (approvalType == string.Empty) { buttonList.Add("TempSave"); buttonList.Add("Request"); buttonList.Add("Cancel"); buttonList.Add("Close"); SetVisibleItems(true); } // Request else if (approvalType == "1") { buttonList.Add("Cancel"); buttonList.Add("Close"); SetVisibleItems(false); } else { buttonList.Add("Close"); SetVisibleItems(false); } } // approval else if (requestOrApprovalType == "1") { // approved or rejected if (approvalType == ((int)CConstValue.ApprovalStatus.Approved).ToString() || approvalType == ((int)CConstValue.ApprovalStatus.Rejected).ToString() || approvalType == ((int)CConstValue.ApprovalStatus.Canceled).ToString()) { buttonList.Add("Close"); } else { var refundApproveInfo = new CGlobal(); var supervisor = refundApproveInfo.CheckApprovalEnable((int)CConstValue.Approval.PurchaseOrder, Convert.ToInt32(Id)); if (CurrentUserId == supervisor) { buttonList.Add("Approve"); buttonList.Add("Reject"); buttonList.Add("Revise"); buttonList.Add("Close"); } else { buttonList.Add("Close"); } } SetVisibleItems(false); } // Purchase Order from HQ else if (requestOrApprovalType == "2") { // Wating for review from HQ if (approvalType == ((int)CConstValue.ApprovalStatus.WaitingForPreviewFromHq).ToString()) { buttonList.Add("Accept"); buttonList.Add("Reject"); buttonList.Add("Close"); } // Approved else if (approvalType == ((int)CConstValue.ApprovalStatus.Approved).ToString()) { buttonList.Add("Print"); buttonList.Add("Accept"); buttonList.Add("Close"); } else { buttonList.Add("Close"); } SetVisibleItems(false); } } foreach (RadToolBarItem item in RadToolBar1.Items) { if (buttonList.Contains(item.Text)) { item.Visible = true; } else { item.Visible = false; } } // new or temp if (approvalType == "0" || approvalType == string.Empty) { FileDownloadList1.SetVisibieUploadControls(true); } else { FileDownloadList1.SetVisibieUploadControls(false); } if (approvalType != ((int)CConstValue.ApprovalStatus.WaitingForPreviewFromHq).ToString() && approvalType != ((int)CConstValue.ApprovalStatus.Approved).ToString()) { RunClientScript("HideReview();"); } var dt = new DataTable(); dt.Columns.Add("DocNo"); dt.Columns.Add("Site"); dt.Columns.Add("Location"); dt.Columns.Add("Name"); dt.Columns.Add("Date"); var newDr = dt.NewRow(); newDr["DocNo"] = obj.DocNo; newDr["Site"] = obj.Site; newDr["Location"] = obj.Location; newDr["Name"] = obj.Name; newDr["Date"] = obj.Date; dt.Rows.Add(newDr); RadGridInfo.DataSource = dt; // New if (Request["createOrListType"] == "0") { var cUser = new CUser(); var user = cUser.Get(CurrentUserId); if (user != null) { RadTextBoxShipToName.Text = cUser.GetUserName(user); RadTextBoxShipToAddress.Text = user.Address1 + " " + user.Address2; RadTextBoxShipToCity.Text = user.City; RadTextBoxShipToProvince.Text = user.Province; RadTextBoxShipToPostalCode.Text = user.PostalCode; RadTextBoxShipToPhone.Text = user.CellPhone; RadTextBoxShipToEmail.Text = user.Email; } // Init RadNumericTextBoxShippingTerms.Value = 1; RadDatePickerDeliveryDate.SelectedDate = DateTime.Now; } else { var result = obj.Get(Id); if (result != null) { RadComboBoxType.SelectedIndex = result.PurchaseOrderType; RadComboBoxPriority.SelectedIndex = (int)result.PriorityType; RadComboBoxShippingMethod.SelectedIndex = (int)result.ShippingMethodType; RadNumericTextBoxShippingTerms.Value = result.ShippingTerms; RadDatePickerDeliveryDate.SelectedDate = result.ShippingDeliveryDate; RadTextBoxDescription.Text = result.Description; RadTextBoxVendorName.Text = result.VendorName; RadTextBoxVendorAddress.Text = result.VendorAddress; RadTextBoxVendorCity.Text = result.VendorCity; RadTextBoxVendorProvince.Text = result.VendorProvince; RadTextBoxVendorPostalCode.Text = result.VendorPostalCode; RadTextBoxVendorPhone.Text = result.VendorPhone; RadTextBoxVendorEmail.Text = result.VendorEmail; RadTextBoxShipToName.Text = result.ShipToName; RadTextBoxShipToAddress.Text = result.ShipToAddress; RadTextBoxShipToCity.Text = result.ShipToCity; RadTextBoxShipToProvince.Text = result.ShipToProvince; RadTextBoxShipToPostalCode.Text = result.ShipToPostalCode; RadTextBoxShipToPhone.Text = result.ShipToPhone; RadTextBoxShipToEmail.Text = result.ShipToEmail; if (result.ReviewType != null) { RadComboBoxReviewType.SelectedIndex = (int)result.ReviewType; } if (result.ReviewDate != null) { RadDatePickerReviewDate.SelectedDate = result.ReviewDate; } if (result.ReviewUserId != null) { var cUser = new CUser(); var user = cUser.Get((int)result.ReviewUserId); RadTextBoxReviewUser.Text = cUser.GetUserName(user); } RadDatePickerReviewDate.SelectedDate = result.ReviewDate; RadTextBoxReviewMemo.Text = result.ReviewMemo; RadNumericTextBoxTax.Value = (double)result.Tax; } } } }