Exemplo n.º 1
0
        private bool hasDuplicateFileName()
        {
            bool hasDuplicate = false;

            //Check for Duplicate Name for Same File type
            string id = "";

            if (!IsInsert())
            {
                id = ASSET_ATTACHMENT_ID;
            }
            string asset_id = GetSetAssetID;
            string filename = txtNameEdit.Text;

            string filetype       = hdnFileType.Value;
            string fileUploadType = Utilities.GetFileTypeFromUploadControl(FileUploadAttachment);

            if (!Utilities.isNull(fileUploadType))
            {
                filetype = fileUploadType;
            }

            //only validate if a file has been attachched
            if (!Utilities.isNull(filetype))
            {
                DataSet ds = DatabaseUtilities.DsValidateDuplicateAttachmentName(asset_id, id, filename, filetype);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    hasDuplicate            = true;
                    cvDuplicateName.IsValid = false;
                }
            }

            return(hasDuplicate);
        }
        public void LoadDDLInteractionType(string businessRuleList, bool isDisplayActiveOnly, bool isDisplayPleaseSelectOption, bool isDisplayAllOption)
        {
            DataSet ds           = DatabaseUtilities.DsGetInteractionType(isDisplayActiveOnly, businessRuleList, Constants.COLUMN_CT_INTERACTION_TYPE_Name);
            int     iRecordCount = ds.Tables[0].Rows.Count;

            if (iRecordCount > 0)
            {
                ddlInteractionType.DataSource     = ds;
                ddlInteractionType.DataTextField  = Constants.COLUMN_CT_INTERACTION_TYPE_Name;
                ddlInteractionType.DataValueField = Constants.COLUMN_CT_INTERACTION_TYPE_ID;
                ddlInteractionType.DataBind();
            }

            //Only display select option if return more than one record and isDisplayPleaseSelectOption = true
            if (iRecordCount > 1 && isDisplayAllOption)
            {
                ddlInteractionType.Items.Insert(0, new ListItem(Constants._OPTION_ALL_TEXT, Constants._OPTION_ALL_VALUE));
            }

            //Only display select option if return more than one record and isDisplayPleaseSelectOption = true
            if (iRecordCount > 1 && isDisplayPleaseSelectOption)
            {
                ddlInteractionType.Items.Insert(0, new ListItem(Constants._OPTION_PLEASE_SELECT_TEXT, Constants._OPTION_PLEASE_SELECT_VALUE));
            }
        }
        protected void ButtonLogOn_Click(object sender, EventArgs e)
        {
            string email = txtUserName.Text;
            string pwd = txtPassword.Text;

            //log("User attempted to log in with password " + pwd);

            DatabaseUtilities du = new DatabaseUtilities(Server);

            string error_message = du.CustomerTicketLogin(Response, email, pwd);

            if (error_message == null) //login successful!
            {
                string returnUrl = Request.QueryString["ReturnUrl"];
                if (returnUrl == null) 
                    returnUrl = "/WebGoatCoins/MainPage.aspx";
                Response.Redirect(returnUrl);

            }
            else
                labelMessage.Text = error_message;
            
            
            /*
            string error_message = du.CustomerLogin(uid, pwd);
            if (error_message != null)
            {
                labelMessage.Text = error_message;
            }
            else
            {
                Response.Redirect("./MainPage.aspx");
            }
            */
        }
        /// <summary>
        /// called when this instance impacts the given thing
        /// </summary>
        /// <param name="hitThing">The hit thing.</param>
        protected override void Impact(Thing hitThing)
        {
            base.Impact(hitThing);
            var pgc = Find.World.GetComponent <PawnmorphGameComp>();

            if (hitThing != null && hitThing is Pawn pawn)
            {
                Pawn hitPawn = pawn;

                if (hitPawn.def.IsValidAnimal())
                {
                    if (pgc.taggedAnimals.Contains(hitPawn.kindDef))
                    {
                        Messages.Message("{0} already in genetic database".Formatted(hitPawn.kindDef.LabelCap), MessageTypeDefOf.RejectInput);
                        return;
                    }

                    pgc.TagPawn(hitPawn.kindDef);
                    Messages.Message("{0} added to database".Formatted(hitPawn.kindDef.LabelCap), MessageTypeDefOf.TaskCompletion);
                }
                else if (DatabaseUtilities.IsChao(hitPawn.def))
                {
                    Messages.Message("{0} is too genetically corrupted to be added".Formatted(hitPawn.kindDef.LabelCap), MessageTypeDefOf.RejectInput);
                }
            }
        }
Exemplo n.º 5
0
        public void LoadddlAttachmentType(bool isDisplayActiveOnly, bool isDisplayPleaseSelectOption, bool isDisplayAllOption)
        {
            DataSet ds           = DatabaseUtilities.DsGet_CTByTableName(Constants.TBL_CT_ATTACHMENT_TYPE, isDisplayActiveOnly);
            int     iRecordCount = ds.Tables[0].Rows.Count;

            if (iRecordCount > 0)
            {
                ddlAttachmentType.DataSource     = ds;
                ddlAttachmentType.DataTextField  = Constants.COLUMN_CT_ATTACHMENT_TYPE_Name;
                ddlAttachmentType.DataValueField = Constants.COLUMN_CT_ATTACHMENT_TYPE_ID;
                ddlAttachmentType.DataBind();
            }

            //Only display select option if return more than one record and isDisplayPleaseSelectOption = true
            if (iRecordCount > 1 && isDisplayAllOption)
            {
                ddlAttachmentType.Items.Insert(0, new ListItem(Constants._OPTION_ALL_TEXT + "Attachment Types ---", Constants._OPTION_ALL_VALUE));
            }

            //Only display select option if return more than one record and isDisplayPleaseSelectOption = true
            if (iRecordCount > 1 && isDisplayPleaseSelectOption)
            {
                ddlAttachmentType.Items.Insert(0, new ListItem(Constants._OPTION_PLEASE_SELECT_TEXT + "Attachment Type ---", Constants._OPTION_PLEASE_SELECT_VALUE));
            }
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.User.IsInRole("Administrator"))
            {
                AdminOptions.Visible = true;
                currentUser          = Administrator.Get();
            }
            else
            {
                currentUser = DatabaseUtilities.GetUser(this.User.Identity.Name);
            }

            // set the default meeting date to tomorrow
            DatePicker.SelectedDate = DateTime.Today.AddDays(1);

            // populate the dropdowns with valid times
            for (int i = 8; i <= 17; i++)
            {
                StartHour.Items.Add((i < 10 ? "0" : "") + i);
                EndHour.Items.Add((i < 10 ? "0" : "") + i);
            }

            for (int i = 0; i <= 55; i += 5)
            {
                StartMinute.Items.Add((i < 10 ? "0" : "") + i);
                EndMinute.Items.Add((i < 10 ? "0" : "") + i);
            }

            // populate the group number dropdown with valid group numbers
            for (int i = 0; i <= DatabaseUtilities.GetHighestGroupNumber(); i++)
            {
                Groups_DropDown.Items.Add("" + i);
            }
        }
Exemplo n.º 7
0
        private void LoadTamperInfo()
        {
            DataSet ds = dsGetAssetInfo();

            if (!IsInsert())
            {
                ds = DatabaseUtilities.DsGetTabByView(Constants.DB_VIEW_ASSET_TAB_TAMPER, "", GetSetTamperID, "");
            }

            if (ds.Tables[0].Rows.Count > 0)
            {
                string sStudentID = ds.Tables[0].Rows[0]["Student_ID"].ToString().Trim();

                if (Utilities.isNull(sStudentID))
                {
                    trPreviousStudentAssigned.Visible = false;
                    //txtStudentLookup.Visible = true;
                    lblTamperedStudent.Visible = false;
                }
            }

            Utilities.DataBindForm(divTamperInfo, ds);

            uc_TamperAttachment.GetSetAssetID       = QS_ASSET_ID;
            uc_TamperAttachment.GetSetAssetTamperID = GetSetTamperID;

            ShowHideEditControl();
        }
        protected void lnkExportToExcel_Click(object sender, EventArgs e)
        {
            string  file_name = "Asset_Search_Results";
            DataSet ds        = DatabaseUtilities.DsGetAssetMasterList(BuildWhereClauseForSearch(), QS_ASSET_SEARCH_ID, columnsToExport());

            Utilities.ExportDataSetToExcel(ds, Response, file_name);
        }
        private bool ValidateSubmitTransfer()
        {
            bool    IsAllAssetValidToTransfer = true;
            string  transfer_site_id          = ddlSiteTransferAsset.SelectedValue;
            DataSet ds = DatabaseUtilities.DsGetCheckItemFromAssetSearch(ASSET_SEARCH_ID, transfer_site_id, "");

            //Validate to see if there are any error message from the grid
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                string sErrorMsg = row["Message_Error"].ToString();
                if (!isNull(sErrorMsg))
                {
                    IsAllAssetValidToTransfer = false;
                }
            }

            if (!IsAllAssetValidToTransfer)
            {
                LoadTransferAsset(); //Reload grid in case any of the asset has been updated.
            }

            cvInvalidAssetToTransfer.IsValid = IsAllAssetValidToTransfer;

            return(IsAllAssetValidToTransfer);
        }
Exemplo n.º 10
0
        public string[] GetEmployeeName(string prefixText, int count, string contextKey)
        {
            DataSet ds = DatabaseUtilities.DsGetEmployeeInfoForLookup(prefixText, contextKey, "");

            var list = new System.Collections.Generic.Dictionary <string, string>(count);

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                string sIsTerm              = dr["Is_Term"].ToString();
                string sEmployeeID          = dr["EmpDistID"].ToString();
                string sEmployeeDisplayName = dr["EmployeeDisplayName"].ToString();

                bool IsTerm = bool.Parse(sIsTerm);

                if (IsTerm)
                {
                    sEmployeeDisplayName = "<span class='invalid'>" + sEmployeeDisplayName + "</span>";
                }

                list.Add(sEmployeeID, sEmployeeDisplayName);
            }

            return(list
                   .Select(p => AjaxControlToolkit.AutoCompleteExtender
                           .CreateAutoCompleteItem(p.Value, p.Key.ToString()))
                   .ToArray <string>());
        }
Exemplo n.º 11
0
        /// <summary>
        /// Save Temp Header Info
        /// </summary>
        /// <param name="site">Site Parameter</param>
        /// <param name="description">Description Param</param>
        /// <returns>ID for the record that has been inserted or updated</returns>
        private string SaveTempHeaderTbl(string site, string description)
        {
            string p_ID = "-1";

            if (!isNull(qsHeaderID))
            {
                p_ID = qsHeaderID;
            }
            string p_Asset_Site_ID       = site;
            string p_Name                = ""; //Not saving name for now
            string p_Description         = description;
            string p_Added_By_Emp_ID     = Utilities.GetEmployeeIdByLoggedOn(LoggedOnUser);
            string p_Date_Added          = DateTime.Now.ToString();
            string p_Modified_By_Emp_ID  = Utilities.GetEmployeeIdByLoggedOn(LoggedOnUser);
            string p_Date_Modified       = DateTime.Now.ToString();;
            string p_Has_Submit          = "0";
            string p_Date_Submit         = Constants.MCSDBNULL;
            string p_Submitted_By_Emp_ID = Constants.MCSDBNULL;

            return(DatabaseUtilities.Upsert_Asset_Temp_Header(
                       p_ID,
                       p_Asset_Site_ID,
                       p_Name,
                       p_Description,
                       p_Added_By_Emp_ID,
                       p_Date_Added,
                       p_Modified_By_Emp_ID,
                       p_Date_Modified,
                       p_Has_Submit,
                       p_Date_Submit,
                       p_Submitted_By_Emp_ID
                       ));
        }
Exemplo n.º 12
0
        private void SaveComments()
        {
            string datetimenow = DateTime.Now.ToString();
            string empid       = Utilities.GetEmployeeIdByLoggedOn(Utilities.GetLoggedOnUser());

            string p_ID                 = ASSET_COMMENT_ID;
            string p_Asset_ID           = QS_ASSET_ID;
            string p_Comment            = txtComment.Text;
            string p_Added_By_Emp_ID    = Constants.MCSDBNOPARAM;
            string p_Date_Added         = Constants.MCSDBNOPARAM;
            string p_Modified_By_Emp_ID = Constants.MCSDBNOPARAM;
            string p_Date_Modified      = Constants.MCSDBNOPARAM;

            if (IsInsert())
            {
                p_Added_By_Emp_ID = empid;
                p_Date_Added      = datetimenow;
            }
            else
            {
                p_Modified_By_Emp_ID = empid;
                p_Date_Modified      = datetimenow;
            }

            DatabaseUtilities.Upsert_Asset_Comment(
                p_ID,
                p_Asset_ID,
                p_Comment,
                p_Added_By_Emp_ID,
                p_Date_Added,
                p_Modified_By_Emp_ID,
                p_Date_Modified
                );
        }
Exemplo n.º 13
0
        //___________________________Deletes item(User or test) at the accepted key from the relevant table in db_________________________________________
        public bool DeleteSelectedItem(int key, bool delUser)
        {
            bool deleteSuccess = false;

            //__________________Deletes a User if delUser bool is true_________________________________
            if (delUser)
            {
                if (MessageBox.Show("This will permenantly delete User: "******" " + UserObjDictionary[key].Surname + ", as well as all Tests the user has created and all marks associated to the tests.", "Are you sure?", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
                {
                    UserObjDictionary.Remove(key);
                    DatabaseUtilities.DeleteFromDB("Users", "userID", key);
                    deleteSuccess = true;
                }
            }
            //__________________Deletes a Test if delUser bool is false_________________________________
            else
            {
                if (MessageBox.Show("This will permenantly delete " + TestObjDictionary[key].TestName + ", as well as all Questions and Marks associated with the test.", "Are you sure?", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
                {
                    TestObjDictionary.Remove(key);
                    DatabaseUtilities.DeleteFromDB("Tests", "testID", key);
                    deleteSuccess = true;
                }
            }
            return(deleteSuccess);
        }
Exemplo n.º 14
0
        //Removes the related question from the current feedback form
        protected void DeleteButton_Click(object sender, EventArgs e)
        {
            LinkButton delButton = sender as LinkButton;
            string     dID       = delButton.ID;
            string     qID       = "Q" + dID.Substring(1, dID.Length - 1);
            string     rID       = "R" + dID.Substring(1, dID.Length - 1);
            TableRow   qRow      = QuestionTable.FindControl(rID) as TableRow;
            Label      qLabel    = qRow.FindControl(qID) as Label;
            string     question  = qLabel.Text.Substring(22, qLabel.Text.Length - 27);

            title = Title_Textbox.Text;

            qRow.Visible = false;
            using (var _db = new MPAS.Models.ApplicationDbContext())
            {
                _db.Database.ExecuteSqlCommand("DELETE FROM Feedback WHERE Question = @p0 AND Role = @p1 AND Title = @p2", question, role, title);
            }

            //Enables the Question textbox and Add button if the maximum amount of questions had been reached before the deletion
            if (DatabaseUtilities.CountFeedback(role, title) == 9)
            {
                Question_Textbox.Enabled = true;
                Add_Button.Enabled       = true;
                Question_Textbox.Text    = "";
            }
        }
Exemplo n.º 15
0
        //Saves the feedback from the user in the Feedback table
        protected void SubmitButton_Click(Object source, EventArgs args)
        {
            int counter = 1;

            foreach (FeedbackItem a in DatabaseUtilities.GetFeedback(role, title))
            {
                string          qID      = "Q" + (counter).ToString();
                string          rID      = "R" + (counter).ToString();
                string          rbrID    = "RBR" + (counter).ToString();
                string          rbID     = "RB" + (counter).ToString();
                TableRow        qRow     = FeedbackTable.FindControl(rID) as TableRow;
                Label           qLabel   = qRow.FindControl(qID) as Label;
                TableRow        rbrRow   = FeedbackTable.FindControl(rbrID) as TableRow;
                RadioButtonList rbList   = rbrRow.FindControl(rbID) as RadioButtonList;
                string          question = qLabel.Text.Substring(22, qLabel.Text.Length - 27);

                int feedbackCount = DatabaseUtilities.GetFeedbackCount(role, title, question);
                int feedbackTotal = DatabaseUtilities.GetFeedbackTotal(role, title, question);

                feedbackCount = feedbackCount + 1;
                feedbackTotal = feedbackTotal + Convert.ToInt32(rbList.SelectedValue);

                using (var _db = new MPAS.Models.ApplicationDbContext())
                {
                    _db.Database.ExecuteSqlCommand("UPDATE Feedback SET Count = @p0, Total = @p1 WHERE Role = @p2 AND Title = @p3 AND Question = @p4", feedbackCount, feedbackTotal, role, title, question);
                }
                counter++;
            }

            //Saves the mentor's additional comments in the database
            if (currentUser is Mentor && Comment_Textbox.Text != "")
            {
                SqlConnection conn            = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
                SqlCommand    newFeedbackComm = new SqlCommand("INSERT INTO FeedbackComments (Comment, SNum, Title) " +
                                                               "VALUES(@comment, @snum, @title)");

                //parameterization
                newFeedbackComm.Parameters.Add("@comment", SqlDbType.VarChar);
                newFeedbackComm.Parameters.Add("@snum", SqlDbType.VarChar);
                newFeedbackComm.Parameters.Add("@title", SqlDbType.VarChar);

                //set parameter values
                newFeedbackComm.Parameters["@comment"].Value = Comment_Textbox.Text;
                newFeedbackComm.Parameters["@snum"].Value    = this.User.Identity.Name;
                newFeedbackComm.Parameters["@title"].Value   = title;

                newFeedbackComm.Connection = conn;
                conn.Open();
                using (conn)
                {
                    newFeedbackComm.ExecuteNonQuery();
                }
                conn.Close();
            }
            using (var _db = new MPAS.Models.ApplicationDbContext())
            {
                _db.Database.ExecuteSqlCommand("UPDATE ProfileDetails SET Feedback = 1 WHERE StudentNumber = @p0", this.User.Identity.Name);
            }
            Response.Redirect("~/Default");
        }
        protected void btnSaveMarkReceivedModal_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string Asset_Repair_ID = hdnAssetRepairID.Value;
                string disposition     = ddlDisposition_MarkReceived.SelectedValue;
                string condition       = Constants.MCSDBNOPARAM;

                //only save condition if available option is selected
                if (disposition.Equals(Constants.DISP_AVAILABLE))
                {
                    condition = ddlCondition_MarkReceived.SelectedValue;
                }

                //Update Received info from asset repair
                DatabaseUtilities.UpdateAssetRepairReceived(Asset_Repair_ID, disposition, GetLoggOnEmployeeID());

                //Update disposition on asset
                DatabaseUtilities.SaveAssetDispositionAndCondition(QS_ASSET_ID, disposition, condition, Utilities.GetLoggedOnUser());

                RefreshForm();

                CloseMarkReceivedModal();

                if (btnSaveMarkReceived_Click != null)
                {
                    btnSaveMarkReceived_Click(sender, EventArgs.Empty);
                }
            }
        }
Exemplo n.º 17
0
        private void LoadStudentAssetDetails(string asset_student_transaction_id)
        {
            DataSet ds = DatabaseUtilities.DsGetByTableColumnValue(Constants.DB_VIEW_STUDENT_ASSET_SEARCH, "Asset_Student_Transaction_ID", asset_student_transaction_id, "");

            Utilities.DataBindForm(divStudentTransactionDetails, ds);

            string found_date = "";

            //load Student Info Control
            if (ds.Tables[0].Rows.Count > 0)
            {
                string studentid = ds.Tables[0].Rows[0]["Student_ID"].ToString();
                found_date = ds.Tables[0].Rows[0]["Date_Found_Formatted"].ToString();

                if (!isNull(studentid))
                {
                    Student_Info.LoadStudentInfo(studentid);
                }
            }

            bool isDisplayFoundInfo = !isNull(found_date);

            trFoundDisposition.Visible = isDisplayFoundInfo;
            trFoundCondition.Visible   = isDisplayFoundInfo;
            trFoundDate.Visible        = isDisplayFoundInfo;
        }
Exemplo n.º 18
0
        //Method to get all Customers

        public ReturnMessage <List <Customers_VM> > GetCustomers()
        {
            var GetCustomerResult = new ReturnMessage <List <Customers_VM> >();

            var dbConnection = DatabaseUtilities.GetSQLConnection(GetConfig.ConnectionString);

            var CustomerResult = Repo <Customers> .GetListNoParam(dbConnection, "proc_tblCustomers_GetAllCustomers");

            logger.Information($"Response from DB  to get all  Customers => {JsonConvert.SerializeObject(CustomerResult)}");

            if (CustomerResult != null && CustomerResult.Count > 0)
            {
                List <Customers_VM> CustomerResult_VM = mapper.Map <List <Customers>, List <Customers_VM> >(CustomerResult);
                CustomerResult_VM.Where(g => g.UserType.ToString() != null).Select(g => g.UserType = (User_Type)(int)System.Enum.Parse(typeof(User_Type), g.UserType.ToString()));
                GetCustomerResult.Body                = CustomerResult_VM;
                GetCustomerResult.ResponseCode        = "00";
                GetCustomerResult.ResponseDescription = "Success";
            }

            else
            {
                GetCustomerResult.ResponseCode        = "25";
                GetCustomerResult.ResponseDescription = "No result found";
            }
            return(GetCustomerResult);
        }
Exemplo n.º 19
0
        //Method to get Customers with Customer Username

        public ReturnMessage <Customers_VM> GetCustomerByUsername(string Username)
        {
            var GetCustomerResult = new ReturnMessage <Customers_VM>();

            var dbConnection = DatabaseUtilities.GetSQLConnection(GetConfig.ConnectionString);
            var paras        = new Dictionary <string, string>
            {
                { "@User_Name", Username }
            };
            var CustomerResult = Repo <Models.Customers> .GetObjectNoParam(dbConnection, paras, "proc_tblCustomers_GetCustomerByUserName");

            logger.Information($"Response from DB  to get  Customer By username => {JsonConvert.SerializeObject(CustomerResult)}");

            if (CustomerResult != null)
            {
                var CustomerResult_VM = mapper.Map <Customers, Customers_VM>(CustomerResult);
                CustomerResult_VM.UserType = (Enum.User_Type)(int) CustomerResult.User_Type;

                GetCustomerResult.Body = CustomerResult_VM;

                GetCustomerResult.ResponseCode        = "00";
                GetCustomerResult.ResponseDescription = "Success";
            }

            else
            {
                GetCustomerResult.ResponseCode        = "25";
                GetCustomerResult.ResponseDescription = "No result found";
            }
            return(GetCustomerResult);
        }
Exemplo n.º 20
0
        private void DDLLoadEnteredByEmployee()
        {
            string site_id = ddlSitePreviousBatch.SelectedValue;

            if (site_id.Contains("-"))
            {
                site_id = Utilities.buildListInDropDownList(ddlSitePreviousBatch.ddlSite, true, ",");
            }

            string batch_status = ddlBatchStatus.SelectedValue;

            DataSet ds = DatabaseUtilities.DsGetEnteredByEmpForAddAsset(site_id, batch_status);

            ddlEnteredByEmployee.Visible = false;

            int iTotalRowCount = ds.Tables[0].Rows.Count;

            if (iTotalRowCount > 0)
            {
                ddlEnteredByEmployee.Visible = true;

                ddlEnteredByEmployee.DataSource     = ds;
                ddlEnteredByEmployee.DataTextField  = "Added_By_Emp_Name";
                ddlEnteredByEmployee.DataValueField = "Added_By_Emp_ID";
                ddlEnteredByEmployee.DataBind();

                if (iTotalRowCount > 1)
                {
                    ddlEnteredByEmployee.Items.Insert(0, new ListItem(Constants._OPTION_ALL_TEXT + "Employees ---", Constants._OPTION_ALL_VALUE));
                }
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Load the Previous Load DDL
        /// </summary>
        private void LoadPreviousDG()
        {
            lblResults.Text = "No Results Found";
            string sSiteList = ddlSitePreviousBatch.SelectedValue;

            if (sSiteList.Equals(Constants._OPTION_ALL_VALUE))
            {
                sSiteList = Utilities.buildListInDropDownList(ddlSitePreviousBatch.ddlSite, true, ",");
            }
            string sBatchStatus  = ddlBatchStatus.SelectedValue;
            string sEnteredByEmp = ddlEnteredByEmployee.SelectedValue;
            string sOrderBy      = SortCriteria + " " + SortDir;

            DataSet ds        = DatabaseUtilities.DsGetPreviousAssetTempLoad(sSiteList, sBatchStatus, sEnteredByEmp, sOrderBy);
            int     iRowCount = ds.Tables[0].Rows.Count;


            if (iRowCount > 0)
            {
                lblResults.Text = "Total Batches: " + iRowCount.ToString();
                dgPreviousLoad.CurrentPageIndex = int.Parse(PageIndex);
                dgPreviousLoad.DataSource       = ds;
                dgPreviousLoad.DataBind();

                dgPreviousLoad.Focus();
            }
        }
Exemplo n.º 22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.User == null || this.User.Identity.IsAuthenticated == false)
            {
                Response.Redirect("~/Account/Login.aspx");
            }
            else if (this.User.IsInRole("Administrator"))
            {
                currentUser = Administrator.Get();
            }
            else
            {
                currentUser = DatabaseUtilities.GetUser(this.User.Identity.Name);
            }

            string otherStudentNumber = Request.QueryString["s"];

            if (otherStudentNumber != null)
            {
                otherUser = DatabaseUtilities.GetUser(otherStudentNumber);
                //messages = DatabaseUtilities.GetMessagesBetweenUsers(currentUser.StudentNumber, otherUser.StudentNumber);
                chat = PrivateChatManager.GetChat(currentUser.StudentNumber, otherUser.StudentNumber);
                // tell the chat that we want to receive its messages
                chat.RegisterReceiver(this);
                PopulatePage();
            }
            else
            {
                // no other user was supplied so return them to the inbox page
                Response.Redirect("~/Inbox.aspx");
            }
        }
        private bool IsAllCheckedDgAssetSearch()
        {
            DataSet ds = DatabaseUtilities.DsGetByTableColumnValue(Constants.TBL_ASSET_SEARCH_DETAIL, Constants.COLUMN_ASSET_SEARCH_DETAIL_Asset_Search_ID, ASSET_SEARCH_ID, "");

            if (ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow r in ds.Tables[0].Rows)
                {
                    string sIsCheck = r[Constants.COLUMN_ASSET_SEARCH_DETAIL_Is_Checked].ToString();
                    if (isNull(sIsCheck))
                    {
                        return(false);
                    }
                    else
                    {
                        bool isChecked = bool.Parse(sIsCheck);
                        if (!isChecked)
                        {
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
        private void LoadResearchAsset(string asset_id)
        {
            DataSet ds = DatabaseUtilities.DsGetByTableColumnValue(Constants.DB_VIEW_ASSET_INFO_CHECKIN, "Asset_ID", asset_id, "");

            Utilities.DataBindForm(divAssetStoredSite, ds);

            //initialize control
            divAssetStoredSite.Visible = false;
            lblAsset_Stored_Site.Text  = "";
            lblAsset_Stored_Site.Attributes["Asset_Stored_Site_ID"] = "";

            //need to load the stored site location. It may be different than the asset site location
            if (ds.Tables[0].Rows.Count > 0)
            {
                //Site match
                string asset_site      = ds.Tables[0].Rows[0]["Asset_Site_ID"].ToString();
                string asset_site_desc = ds.Tables[0].Rows[0]["Asset_Site_Desc"].ToString();
                bool   IsSiteMatch     = asset_site.Equals(ddlSite.SelectedValue);
                if (!IsSiteMatch)
                {
                    string note = "<br/><span class='text-warning'>Note: the site asset (" + asset_site_desc + ") does not match the check-in site. A storage location will be created for this asset at </span>";
                    divAssetStoredSite.Visible = true;
                    lblAsset_Stored_Site.Text  = note + ddlSite.SelectedText;
                    lblAsset_Stored_Site.Attributes["Asset_Stored_Site_ID"] = ddlSite.SelectedValue;
                }
            }
        }
Exemplo n.º 25
0
        //___________________Adds a user from input from user, tests user ID and passes userObj to InsertToDb method_________
        private void addUserButt_Click(object sender, EventArgs e)
        {
            if (Housekeeping.CheckAllFields(this))
            {
                if (int.TryParse(userIDTxt.Text, out int ret))                          //only accept int type for user ID
                {
                    if (!test.UserObjDictionary.ContainsKey(int.Parse(userIDTxt.Text))) //Check user ID doesnt already exist
                    {
                        switch (accessGrpCbox.SelectedIndex)
                        {
                        case 0:
                        {
                            user = new AdminObj();
                            break;
                        }

                        case 1:
                        {
                            user = new LecturerObj();
                            break;
                        }

                        case 2:
                        {
                            user = new StudentObj();
                            break;
                        }

                        default:
                        {
                            break;
                        }
                        }

                        user.UserID   = int.Parse(userIDTxt.Text);
                        user.Name     = nameTxt.Text;
                        user.Surname  = surnameTxt.Text;
                        user.Password = passwordTxt.Text;

                        DatabaseUtilities.InsertToDB("Users", user);
                        Housekeeping.ResetForm(this);

                        //invoke delegate
                        OnUserAdded(this, null);
                    }
                    else
                    {
                        MessageBox.Show("User ID already exists!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    MessageBox.Show("User ID can only contain numbers!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("ALL FIELDS ARE REQUIRED!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 26
0
        protected void SubmitButton_Click(Object source, EventArgs args)
        {
            DateTime selectedDay = DatePicker.SelectedDate;
            DateTime startTime   = new DateTime(selectedDay.Year, selectedDay.Month, selectedDay.Day,
                                                Int32.Parse(StartHour.Items[StartHour.SelectedIndex].Text),
                                                Int32.Parse(StartMinute.Items[StartMinute.SelectedIndex].Text), 0);
            DateTime endTime = new DateTime(selectedDay.Year, selectedDay.Month, selectedDay.Day,
                                            Int32.Parse(EndHour.Items[EndHour.SelectedIndex].Text),
                                            Int32.Parse(EndMinute.Items[EndMinute.SelectedIndex].Text), 0);

            if (endTime <= startTime)
            {
                Status_Label.Visible   = true;
                Status_Label.Text      = "Please select an end time later than the chosen start time";
                Status_Label.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                Status_Label.Visible = false;
                // if the user is not an admin, take their group number,
                // else get the group selected by the admin
                int selectedGroup = currentUser.GroupNumber;
                if (currentUser is Administrator)
                {
                    selectedGroup = Int32.Parse(Groups_DropDown.Items[Groups_DropDown.SelectedIndex].Text);
                }
                DatabaseUtilities.AddMeeting(Title_Textbox.Text, Location_Textbox.Text, Agenda_Textbox.Text,
                                             startTime, endTime, selectedGroup, currentUser.StudentNumber);
                Response.Redirect("MeetingList.aspx");
            }
        }
Exemplo n.º 27
0
 //___________Saves all items in the Memo to a database including Student Answers, Recomended to run on seperate thread_____________
 public void saveAnswers()
 {
     foreach (Memorandum memo in Memo)
     {
         DatabaseUtilities.InsertToDB("StudentAnswers", memo);
     }
 }
Exemplo n.º 28
0
        public override void Receive(Message msg)
        {
            PrivateMessage pMsg = (PrivateMessage)msg;

            base.Receive(pMsg);
            DatabaseUtilities.SendPrivateMessage(pMsg.Source.StudentNumber, pMsg.Destination.StudentNumber, pMsg.MessageContent, pMsg.SendTime);
        }
Exemplo n.º 29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.User == null || !this.User.Identity.IsAuthenticated)
            {
                Response.Redirect("/Account/Login.aspx");
            }
            else
            {
                currentUser = DatabaseUtilities.GetUser(this.User.Identity.Name);
            }

            if (Request.QueryString["meetingID"] == null || !Int32.TryParse(Request.QueryString["meetingID"], out meetingID))
            {
                Response.Redirect("/MeetingList.aspx");
            }

            currentMeeting = DatabaseUtilities.GetMeetingbyId(meetingID);
            if (currentUser is Mentor && currentUser.GroupNumber == currentMeeting.Group.Id || currentUser is Administrator)
            {
                dynamicallyAdded = new Dictionary <string, CheckBox>();
                PageSetup();
            }
            else
            {
                Response.Redirect("/Error/AuthError.aspx?source=MeetingFeedback.aspx");
            }
        }
Exemplo n.º 30
0
 protected void Page_Load(object sender, EventArgs e)
 {
     currentUser = null;
     if (HttpContext.Current.User.IsInRole("Administrator"))
     {
         adminLink.Visible = true;
     }
     if (HttpContext.Current.User != null && HttpContext.Current.User.Identity.IsAuthenticated)
     {
         announcementTab.Visible = true;
         if (HttpContext.Current.User.IsInRole("Administrator"))
         {
             meetingReportTab.Visible = true;
         }
         else
         {
             meetingTab.Visible = true;
         }
         groupChatTab.Visible = true;
         currentUser          = DatabaseUtilities.GetUser(HttpContext.Current.User.Identity.Name);
         mentorGroup.Visible  = true;
         inboxTab.Visible     = true;
         if (HttpContext.Current.User.IsInRole("Administrator") || currentUser.Feedback == 0)
         {
             feedbackTab.Visible = true;
         }
     }
 }
        private string TransferModalErrorMessage()
        {
            string  sErrorMsg = "";
            DataSet ds        = DatabaseUtilities.DsGetCheckItemCountFromAssetSearch(ASSET_SEARCH_ID);

            string sTotal_Checked = ds.Tables[0].Rows[0]["Total_Checked"].ToString();

            int iMaxCount = Utilities.MaxAllowAssetTransfer();
            int iRowCountOfSelectedItem = 0;

            if (Utilities.IsNumeric(sTotal_Checked))
            {
                iRowCountOfSelectedItem = int.Parse(sTotal_Checked);
            }

            if (iRowCountOfSelectedItem.Equals(0))
            {
                sErrorMsg += "<li>Please select at least one item from the grid to peform an action</li>";
            }

            if (iRowCountOfSelectedItem > iMaxCount)
            {
                sErrorMsg += "<li>You are only allow to transfer a maxumimum of " + iMaxCount.ToString() + " assets. You selected " + iRowCountOfSelectedItem.ToString() + ".</li>";
            }

            if (sErrorMsg.Length > 0)
            {
                sErrorMsg = "<ul>" + sErrorMsg + "</ul>";
            }

            return(sErrorMsg);
        }
Exemplo n.º 32
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         DatabaseUtilities du = new DatabaseUtilities(Server);
         string error_message = du.AddComment(hiddenFieldProductID.Value, txtEmail.Text, txtComment.Text);
         txtComment.Text = string.Empty;
         lblMessage.Visible = true;
         LoadComments();
     }
     catch(Exception ex)
     {
         lblMessage.Text = ex.Message;
         lblMessage.Visible = true;
     }
 }
Exemplo n.º 33
0
 protected void ButtonCheckEmail_Click(object sender, EventArgs e)
 {
     DatabaseUtilities du = new DatabaseUtilities(Server);
     string result = du.GetSecurityQuestion(Response, txtEmail.Text);
     if (result == null)
     {
         labelQuestion.Text = "That email address was not found in our database!";
         PanelForgotPasswordStep2.Visible = false;
         PanelForgotPasswordStep3.Visible = false;
     }
     else
     {
         labelQuestion.Text = "Here is the question we have on file for you: <strong>" + result + "</strong>";
         PanelForgotPasswordStep2.Visible = true;
         PanelForgotPasswordStep3.Visible = false;
     }
 }
Exemplo n.º 34
0
        void LoadComments()
        {
            DatabaseUtilities du = new DatabaseUtilities(Server);
            string id = Request["productNumber"];
            if (id == null) id = "S18_2795"; //this month's special    
            DataSet ds = du.GetProductDetails(id);
            string output = string.Empty;
            string comments = string.Empty;
            foreach (DataRow prodRow in ds.Tables["products"].Rows)
            {
                output += "<div class='product2' align='center'>";
                output += "<img src='./images/products/" + prodRow["productImage"] + "'/><br/>";
                output += "<strong>" + prodRow["productName"].ToString() + "</strong><br/>";
                output += "<hr/>" + prodRow["productDescription"].ToString() + "<br/>";
                output += "</div>";

                hiddenFieldProductID.Value = prodRow["productCode"].ToString();

                DataRow[] childrows = prodRow.GetChildRows("prod_comments");
                if (childrows.Length > 0)
                    comments += "<h2 class='title-regular-2'>Comments:</h2>";

                foreach (DataRow commentRow in childrows)
                {
                    comments += "<strong>Email:</strong>" + commentRow["email"] + "<span style='font-size: x-small;color: #E47911;'> (Email Address Verified!) </span><br/>";
                    comments += "<strong>Comment:</strong><br/>" + commentRow["comment"] + "<br/><hr/>";
                }

            }

            lblOutput.Text = output;
            lblComments.Text = comments;


            //Fill in the email address of authenticated users
            if (Request.Cookies["customerNumber"] != null)
            {
                string customerNumber = Request.Cookies["customerNumber"].Value;

                string email = du.GetCustomerEmail(customerNumber);
                txtEmail.Text = email;
                txtEmail.ReadOnly = true;
            }
        }
Exemplo n.º 35
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lblMessage.Visible = false;
            txtEmail.Enabled = true;
            if (!Page.IsPostBack)
                LoadComments();

            //TODO: broken 
            if (!Page.IsPostBack) 
            {
                
                DatabaseUtilities du = new DatabaseUtilities(Server);
                DataSet ds = du.GetCatalogData();
                ddlItems.DataSource = ds.Tables[0];
                ddlItems.DataTextField = "productName";
                ddlItems.DataValueField = "productCode";
                ddlItems.DataBind();
            }
        }
Exemplo n.º 36
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DatabaseUtilities du = new DatabaseUtilities(Server);
            //DataSet ds = du.GetCatalogData();
            DataSet ds = du.GetProductsAndCategories();

            foreach (DataRow catRow in ds.Tables["categories"].Rows)
            {
                lblOutput.Text += "<p/><h2 class='title-regular-2 clearfix'>Category: " + catRow["catName"].ToString() + "</h2><hr/><p/>\n";
                foreach (DataRow prodRow in catRow.GetChildRows("cat_prods"))
                {
                    lblOutput.Text += "<div class='product' align='center'>\n";
                    lblOutput.Text += "<img src='./images/products/" + prodRow[3] + "'/><br/>\n";
                    lblOutput.Text += "" + prodRow[1] + "<br/>\n";
                    lblOutput.Text += "<a href=\"ProductDetails.aspx?productNumber=" + prodRow[0].ToString() + "\"><br/>\n";
                    lblOutput.Text += "<img src=\"../resources/images/moreinfo1.png\" onmouseover=\"this.src='../resources/images/moreinfo2.png';\" onmouseout=\"this.src='../resources/images/moreinfo1.png';\" />\n";
                    lblOutput.Text += "</a>\n";
                    lblOutput.Text += "</div>\n";
                }
            }
            

            /*
            foreach(DataRow row in ds.Tables["products"].Rows)
            {
                lblOutput.Text += row[1] + "<br/>";
                lblOutput.Text += "<img src='./images/products/" + row[3] + "'/><br/>";

            }
            */
            /*
                foreach (DataRow custRow in customerOrders.Tables["Customers"].Rows)
                {
                    Console.WriteLine(custRow["CustomerID"].ToString());
                    foreach (DataRow orderRow in custRow.GetChildRows(customerOrdersRelation))
                    {
                        Console.WriteLine(orderRow["OrderID"].ToString());
                    }
                }
            */
        }
Exemplo n.º 37
0
        protected void ButtonChangePassword_Click(object sender, EventArgs e)
        {
            if(txtPassword1.Text != null && txtPassword2.Text != null && txtPassword1.Text == txtPassword2.Text)
            {
                //get customer ID
                string customerNumber = "";
                if (Request.Cookies["customerNumber"] != null)
                {
                    customerNumber = Request.Cookies["customerNumber"].Value;
                }

                DatabaseUtilities du = new DatabaseUtilities(Server);
                string output = du.UpdateCustomerPassword(int.Parse(customerNumber), txtPassword1.Text);
                labelMessage.Text = output;
            }
            else
            {
                labelMessage.Text = "Passwords do not match!  Please try again!";
            }

        }
Exemplo n.º 38
0
        public void ProcessRequest(HttpContext context)
        {
            //context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");

            string query = context.Request["query"];
            DatabaseUtilities du = new DatabaseUtilities(context);
            DataSet ds = du.GetCustomerEmails(query);
            string json = UtilitiesHelper.ToJSONSAutocompleteString(query, ds.Tables[0]);

            if (json != null && json.Length > 0)
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write(json);
            }
            else
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write("");
            
            }
        }
Exemplo n.º 39
0
    public void SendPod(DatabaseUtilities.Table tab, string name)
    {
        Debug.Log("STARTING TEST...");

        Database test = new Database();
        test.SetName(name);
        test.tables = new List<DatabaseUtilities.Table>();
        test.AddTable(tab);

        BuildPod(test);

        /*DatabaseUtilities.Table t = new DatabaseUtilities.Table();
        t.SetName("Dean");
        t.SetId("T34");
        t.columns = new List<DatabaseUtilities.Column>();

        DatabaseUtilities.Column c = new DatabaseUtilities.Column();
        c.SetName("Sam");
        c.SetId("12");
        c.SetColor(DatabaseBuilder.GetRandomColor());
        c.fields = new List<string>();
        c.AddField("Dogs");

        DatabaseUtilities.Column c2 = new DatabaseUtilities.Column();
        c2.SetName("Sammy");
        c2.SetId("1234");
        c2.SetColor(DatabaseBuilder.GetRandomColor());
        c2.fields = new List<string>();
        c2.AddField("Cats");

        t.AddColumn(c);
        t.AddColumn(c2);

        test.AddTable(t);

    */
    }
Exemplo n.º 40
0
    private static GameObject GenerateDiskObj(DatabaseUtilities.Column cylinderInfo, Transform harness)
    {
        //Generate Disk object from factory.
        GameObject disk = Generate((int)View_Type.Disk);

        float scaleSize = float.Parse(cylinderInfo.fields[0]);
        string dataTypeName = cylinderInfo.GetName();
        string hexColor = cylinderInfo.GetColor();

        //Initialize the disk object...
        disk.GetComponent<Disk>().Initialize(harness, dataTypeName, hexColor, scaleSize);

        return disk;

    }
Exemplo n.º 41
0
    private static GameObject GenerateColumnObj(DatabaseUtilities.Column col, Transform parent, int key)
    {
        GameObject curCol =  Generate((int)View_Type.Column);
        curCol.GetComponent<Column>().Initialize(key, parent, col.GetName(), col.GetId(), col.GetColor());

        return curCol;
    }
Exemplo n.º 42
0
    private static GameObject GenerateTableObj(DatabaseUtilities.Table table, Transform harness, bool aType)
    {
        GameObject currentTable = Generate((int)View_Type.Table);
        Transform tableTransform = currentTable.transform;

        List<DatabaseUtilities.Column> columnInfo = table.columns;
        int columnCount = columnInfo.Count;

        GameObject[] cols = new GameObject[columnCount];

        for(int i = 0; i < columnCount; i++)
        {
            cols[i] = GenerateColumnObj(columnInfo[i], tableTransform, i);
        }

        currentTable.GetComponent<Table>().initialization(table.GetName(), table.GetId(), cols, harness, aType);
        return currentTable;
    }
Exemplo n.º 43
0
 public ActionResult Tell(OWASP.WebGoat.NET.Models.Diary diary)
 {
     DatabaseUtilities du = new DatabaseUtilities();
     du.AddNewPosting("Secret Entry", "Anonymous", diary.Text);
     return Redirect("~/Default.aspx");
 }
Exemplo n.º 44
0
 string getPassword(string email)
 {
     DatabaseUtilities du = new DatabaseUtilities(Server);
     string password = du.GetPasswordByEmail(email);
     return password;
 }
Exemplo n.º 45
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int id;
            DataSet ds;
            if (Request.Cookies["customerNumber"] == null || !int.TryParse(Request.Cookies["customerNumber"].Value.ToString(), out id))
                lblOutput.Text = "Sorry, an unspecified problem regarding your Customer ID has occurred.  Are your cookies enabled?";
            else
            {
                DatabaseUtilities du = new DatabaseUtilities(Server);
                ds = du.GetOrders(id);

                if (!Page.IsPostBack) //generate the data grid
                {
                    GridView1.DataSource = ds.Tables[0];

                    GridView1.AutoGenerateColumns = false;

                    BoundField BoundFieldOrderNumber = new BoundField();
                    BoundField BoundFieldStatus = new BoundField();
                    BoundField BoundFieldRequiredDate = new BoundField();
                    BoundField BoundFieldShippedDate = new BoundField();

                    BoundFieldOrderNumber.DataField = "orderNumber";
                    BoundFieldStatus.DataField = "status";
                    BoundFieldRequiredDate.DataField = "requiredDate";
                    BoundFieldShippedDate.DataField = "shippedDate";

                    BoundFieldOrderNumber.HeaderText = "Order Number";
                    BoundFieldStatus.HeaderText = "Status";
                    BoundFieldRequiredDate.HeaderText = "Required Date";
                    BoundFieldShippedDate.HeaderText = "Shipped Date";

                    BoundFieldRequiredDate.DataFormatString = "{0:MM/dd/yyyy}";
                    BoundFieldShippedDate.DataFormatString = "{0:MM/dd/yyyy}";

                    GridView1.Columns.Add(BoundFieldOrderNumber);
                    GridView1.Columns.Add(BoundFieldStatus);
                    GridView1.Columns.Add(BoundFieldRequiredDate);
                    GridView1.Columns.Add(BoundFieldShippedDate);

                    GridView1.DataBind();
                }
                //check if orderNumber exists
                string orderNumber = Request["orderNumber"];
                if (orderNumber != null)
                {
                    try
                    {
                        //lblOutput.Text = orderNumber;
                        DataSet dsOrderDetails = du.GetOrderDetails(int.Parse(orderNumber));
                        DetailsView1.DataSource = dsOrderDetails.Tables[0];
                        DetailsView1.DataBind();
                        //litOrderDetails.Visible = true;
                        PanelShowDetailSuccess.Visible = true;

                        //allow customer to download image of their product
                        string image = dsOrderDetails.Tables[0].Rows[0]["productImage"].ToString();
                        HyperLink1.Text = "Download Product Image";
                        HyperLink1.NavigateUrl = Request.RawUrl + "&image=images/products/" + image;
                    }
                    catch (Exception ex)
                    {
                        //litOrderDetails.Text = "Error finding order number " + orderNumber + ". Details: " + ex.Message;
                        PanelShowDetailFailure.Visible = true;
                        litErrorDetailMessage.Text = "Error finding order number " + orderNumber + ". Details: " + ex.Message;
                    }
                }

                //check if they are trying to download the image
                string target_image = Request["image"];
                if (target_image != null)
                {
                    FileInfo fi = new FileInfo(Server.MapPath(target_image));
                    lblOutput.Text = fi.FullName;

                    NameValueCollection imageExtensions = new NameValueCollection();
                    imageExtensions.Add(".jpg", "image/jpeg");
                    imageExtensions.Add(".gif", "image/gif");
                    imageExtensions.Add(".png", "image/png");

                    Response.ContentType = imageExtensions.Get(fi.Extension);
                    Response.AppendHeader("Content-Disposition", "attachment; filename=" + fi.Name);
                    Response.TransmitFile(fi.FullName);
                    Response.End();
                }

            }
        }