void pGrid_ItemCommand(object sender, GridCommandEventArgs e)
        {
            Int64 Key = 0;

            // Get the ID for the row to select or delete
            if (e.CommandName.ToUpper() == "SELECT" || e.CommandName.ToUpper() == "DELETE")
            {
                //Key = Methods.Convert_Int64(this.UserGrid.pGrid.MasterTableView.Items[e.Item.ItemIndex].GetDataKeyValue("RecruitmentTestUserID").ToString());
                Key = this.UserGrid.GetKey(e.Item.ItemIndex);
            }

            switch (e.CommandName)
            {
                case "Select":
                    this.Response.Redirect(@"~/Page/User_Details.aspx?ID=" + Key);
                    break;

                case "Delete":
                    ClsKeys ClsKey = new ClsKeys();
                    ClsKey.Add("RecruitmentTestUserID", Convert.ToInt64(Key));

                    this.ClsUser.Load(ClsKey);
                    this.ClsUser.Delete();
                    this.UserGrid.RebindGrid();

                    break;
            }
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            Int64 Key = Convert.ToInt64(Request.QueryString["ID"].ToString());
            ClsKeys ClsKey = new ClsKeys();
            ClsKey.Add("RecruitmentTestQuestionsID", Key);

            ClsQuestion objQuestion = new ClsQuestion(this.Master.pCurrentUser);
            objQuestion.Load(ClsKey);
            objQuestion.Delete();

            Response.Redirect("Question.aspx");
        }
        /// <summary>
        /// (Overrided) Loads the List with the supplied Key
        /// </summary>
        /// <param name="Keys">
        /// Key object to use
        /// </param>
        public override void Load(ClsKeys Keys = null)
        {
            if (Keys == null)
            { this.New(); }
            else
            {
                ClsQueryCondition Qc = this.mDa.CreateQueryCondition();
                foreach (string KeyName in Keys.pName)
                { Qc.Add(KeyName, Keys[KeyName].ToString(), typeof(Int64).ToString(), "0"); }

                if (this.mQc_LoadCondition != null)
                {
                    foreach (Layer01_Common.Objects.ClsQueryCondition.Str_QueryCondition Str_Qc in this.mQc_LoadCondition.pList)
                    { Qc.pList.Add(Str_Qc); }
                }

                this.Load(Qc);
            }
        }
        public override void Load(ClsKeys Keys = null)
        {
            base.Load(Keys);

            Int64 ID = 0;
            if (Keys != null)
            {
                try { ID = Keys["RecruitmentTestUserID"]; }
                catch { }
            }

            List<Layer01_Constants.Str_Parameters> List_Sp = new List<Layer01_Constants.Str_Parameters>();
            List_Sp.Add(new Layer01_Constants.Str_Parameters("@ID", ID));
            DataTable Dt;
            Dt = (this.mDa.Connection as ClsConnection_SqlServer).ExecuteQuery("usp_RecruitmentTestUser_Rights_Load", List_Sp).Tables[0];

            this.AddRequired(Dt);
            this.pTableDetail_Set("RecruitmentTestUser_Rights", Dt);
        }
        void pGrid_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            Int64 Key = 0;

            // Get the ID for the row to select or delete
            if (e.CommandName.ToUpper() == "SELECT" || e.CommandName.ToUpper() == "DELETE")
            {
                Key = this.QuestionGrid.GetKey(e.Item.ItemIndex);
            }

            switch (e.CommandName)
            {
                case "Select":
                    this.Response.Redirect(@"~/Page/Question_Details.aspx?ID=" + Key);
                    break;

                case "Delete":
                    ClsKeys ClsKey = new ClsKeys();
                    ClsKey.Add("RecruitmentTestQuestionsID", Convert.ToInt64(Key));

                    ClsQuestion Obj_Question = new ClsQuestion(this.Master.pCurrentUser);
                    Obj_Question.Load(ClsKey);

                    if (this.Master.pCurrentUser.pUserType != Layer02_Constants.eLookupUserType.Administrator)
                    {
                        Int64 CurrentUserID = Methods.Convert_Int64(this.Master.pCurrentUser.pDrUser["RecruitmentTestUserID"], 0);
                        Int64 OwnerUserID = Methods.Convert_Int64(Obj_Question.pDr["RecruitmentTestUserID_CreatedBy"], 0);

                        if (CurrentUserID != OwnerUserID)
                        {
                            this.Show_EventMsg("You can't delete this question.", ClsBaseMain_Master.eStatus.Event_Error);
                            this.QuestionGrid.RebindGrid();
                            return;
                        }
                    }

                    Obj_Question.Delete();
                    this.QuestionGrid.RebindGrid();
                    break;
            }
        }
Beispiel #6
0
        public static bool CheckSeriesDuplicate(
            string TableName
            , string SeriesField
            , ClsKeys Keys
            , string SeriesNo)
        {
            bool      Rv = false;
            DataTable Dt;

            System.Text.StringBuilder Sb_Query_Key = new StringBuilder();
            string Query_Key = "";
            string Query_And = "";

            foreach (string Inner_Key in Keys.pName)
            {
                Sb_Query_Key.Append(Query_And + " " + Inner_Key + " = " + Keys[Inner_Key]);
                Query_And = " And ";
            }

            Query_Key = " 1 = 1 ";
            if (Sb_Query_Key.ToString() != "")
            {
                Query_Key = "(Not (" + Sb_Query_Key.ToString() + "))";
            }

            Dt = Do_Methods_Query.GetQuery(
                "[" + TableName + "]"
                , "Count(1) As [Ct]"
                , Query_Key + " And " + SeriesField + " = '" + SeriesNo + "'");
            if (Dt.Rows.Count > 0)
            {
                if ((Int32)Dt.Rows[0][0] > 0)
                {
                    Rv = true;
                }
            }

            //True means duplicates have been found
            return(Rv);
        }
        public DataTable Load_TableDetails(string ObjectName,  ClsKeys Keys, string Condition)
        {
            StringBuilder Sb_Condition = new StringBuilder();
            DataTable Dt;

            if (Keys == null)
            { Dt = this.GetQuery(this.Connection, ObjectName, "*", "1 = 0"); }
            else
            {
                string Inner_Condition_And = "";
                bool IsStart = false;
                foreach (string Inner_Key in Keys.pName)
                {
                    Sb_Condition.Append(Inner_Condition_And + " " + Inner_Key + " = " + Keys[Inner_Key]);
                    if (!IsStart) Inner_Condition_And = " And ";
                    IsStart = true;
                }

                string OtherCondition = "";
                if (Condition != "") OtherCondition = " And " + Condition;

                Dt = this.GetQuery(this.Connection, ObjectName, "*", Sb_Condition.ToString() + OtherCondition);
            }

            return Dt;
        }
        //[-]
        /// <summary>
        /// (Overridable) Loads the Data Object with the supplied Key
        /// </summary>
        /// <param name="Keys">
        /// Key object to use
        /// </param>
        public virtual void Load(ClsKeys Keys = null)
        {
            try
            {
                this.mDa.Connect();

                //[-]

                this.mHeader_Dr = this.mDa.Load(this.mHeader_ViewName, this.mHeader_Key, Keys);

                //[-]

                if (this.mBase_TableDetail != null)
                {
                    foreach (ClsBaseTableDetail Inner_Obj in this.mBase_TableDetail)
                    { Inner_Obj.Load(this.mDa, Keys); }
                }

                //[-]

                if (this.mBase_RowDetail != null)
                {
                    foreach (ClsBaseRowDetail Inner_Obj in this.mBase_RowDetail)
                    { Inner_Obj.Load(this.mDa, Keys); }
                }

                //[-]

                this.AddRequired();
            }

            catch (Exception Ex)
            { throw Ex; }
            finally
            { this.mDa.Close(); }
        }
        public DataRow Load(string ObjectName, List<string> List_Key, ClsKeys Keys)
        {
            DataTable Dt;
            DataRow Dr;

            if (Keys == null)
            { Dr = this.GetQuery(this.Connection, ObjectName, "*", "1 = 0").NewRow(); }
            else
            {
                StringBuilder Sb_Condition = new StringBuilder();

                if (Keys.Count() != List_Key.Count)
                { throw new Exception("Keys not equal to required keys."); }

                Sb_Condition.Append(" 1 = 1 ");
                foreach (string Inner_Key in List_Key)
                { Sb_Condition.Append(" And " + Inner_Key + " = " + Keys[Inner_Key]); }

                Dt = this.GetQuery(this.Connection, ObjectName, "*", Sb_Condition.ToString());
                if (Dt.Rows.Count > 0)
                { Dr = Dt.Rows[0]; }
                else
                { throw new ClsCustomException("Record not found."); }
            }
            return Dr;
        }
        /// <summary>
        /// Gets the Keys of the supplied row using the Key Definition of the Data Object
        /// </summary>
        /// <param name="Dr">
        /// Source datarow, mostly the same definition as from Me.List()
        /// </param>
        /// <returns></returns>
        public ClsKeys GetKeys(DataRow Dr)
        {
            ClsKeys Obj = new ClsKeys();

            foreach (string Key in this.mHeader_Key)
            {
                Int64 ID = (Int64)Methods.IsNull(Dr[Key], 0);
                Obj.Add(Key, ID);
            }

            return Obj;
        }
        /// <summary>
        /// Gets the Keys of the supplier datarow using the supplier Key Definition
        /// </summary>
        /// <param name="Dr">
        /// Source datarow
        /// </param>
        /// <param name="KeyNames">
        /// Key definition
        /// </param>
        /// <returns></returns>
        public ClsKeys GetKeys(DataRow Dr, List<string> KeyNames)
        {
            bool IsFound = false;
            ClsKeys Key = new ClsKeys();

            foreach (string Inner_Key in KeyNames)
            {
                if (!Information.IsDBNull(Dr[Inner_Key]))
                { Key.Add(Inner_Key, (Int64)Methods.IsNull(Dr[Inner_Key], 0)); }
                else
                {
                    IsFound = true;
                    break;
                }
            }

            if (IsFound)
            { Key = null; }

            return Key;
        }
        /*
        public void Load(Interface_DataAccess Da, string Condition)
        {
            string OtherCondition = "";
            if (this.mOtherLoadCondition != "") OtherCondition = " And " + this.mOtherLoadCondition;

            DataTable Dt;

            if (Condition == "") Dt = this.mDa.GetQuery(Da.Connection, this.mViewName, "*", "1 = 0");
            else Dt = this.mDa.GetQuery(Da.Connection, this.mViewName, "*", Condition + OtherCondition);

            this.mDt = Dt;
        }
        */
        /*
        public void Load(string Condition)
        {
            try
            {
                this.mDa.Connect();
                this.Load(this.mDa, Condition);
            }
            catch (Exception ex)
            { throw ex; }
            finally
            { this.mDa.Close(); }
        }
        */
        public void Load(Interface_DataAccess Da, ClsKeys Keys)
        {
            this.mDt = Da.Load_TableDetails(this.mViewName, Keys, this.mOtherLoadCondition);
        }
        //[-]
        /// <summary>
        /// Gets the current Keys of the Data Object
        /// </summary>
        /// <returns></returns>
        public ClsKeys GetKeys()
        {
            ClsKeys Obj = new ClsKeys();

            foreach (string Key in this.mHeader_Key)
            {
                Int64 ID = Convert.ToInt64(Methods.IsNull(this.mHeader_Dr[Key], 0));
                Obj.Add(Key, ID);
            }

            return Obj;
        }
        protected void RadAjaxPanel1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
        {
            string[] Tmp;
            string CommandName = string.Empty;
            Int32 ItemIndex = -1;
            string ComboText = "";
            try
            {
                Tmp = e.Argument.Split(',');
                CommandName = Tmp[0];

                switch (CommandName)
                {
                    case "Dialog_Answer":
                        ComboText = Tmp[1];
                        break;
                    case "Delete":
                        ItemIndex = Methods.Convert_Int32(Tmp[1], -1);
                        break;
                }
            }
            catch { }

            switch (CommandName)
            {
                case "Dialog_Answer":
                    {
                        Int64 Key = Methods.Convert_Int64(this.RadWindow1_Hid_TmpKey.Value);
                        Layer02_Objects.Modules_Objects.ClsQuestion Obj = (Layer02_Objects.Modules_Objects.ClsQuestion)this.mObj_Base;
                        Layer02_Objects.Modules_Objects.ClsAnswer Obj_Answer = null;
                        System.Data.DataRow Dr_QA = null;

                        bool IsNew = false;
                        if (Key == 0)
                        { IsNew = true; }
                        else
                        {
                            System.Data.DataRow[] Arr_Dr = Obj.pDt_QuestionAnswer.Select("TmpKey = " + Key);
                            if (Arr_Dr.Length > 0)
                            {
                                Dr_QA = Arr_Dr[0];
                                Obj_Answer = (Layer02_Objects.Modules_Objects.ClsAnswer)Obj.pBO_Answer[Key.ToString()];
                            }
                            else
                            { IsNew = true; }
                        }

                        if (IsNew)
                        {
                            Dr_QA = Obj.pDt_QuestionAnswer.NewRow();
                            Dr_QA["TmpKey"] = Layer02_Objects.Modules_Base.Abstract.ClsBase.GetNewTmpKey(Obj.pDt_QuestionAnswer);
                            Obj.pDt_QuestionAnswer.Rows.Add(Dr_QA);
                        }

                        bool IsNewAnswer = false;
                        if (this.RadWindow1_RadComboBox1.SelectedValue == "")
                        { IsNewAnswer = true; }

                        if (IsNewAnswer || IsNew)
                        {
                            Obj_Answer = new Layer02_Objects.Modules_Objects.ClsAnswer();
                            if (IsNewAnswer)
                            {
                                Obj_Answer.Load();
                                //Obj_Answer.pDr["Answer"] = this.RadWindow1_RadComboBox1.Text;
                                Obj_Answer.pDr["Answer"] = ComboText;
                            }

                            Obj.pBO_Answer.Add(Dr_QA["TmpKey"].ToString(), Obj_Answer);
                        }

                        if (!IsNewAnswer)
                        {
                            Layer02_Objects._System.ClsKeys Inner_Key = null;
                            Inner_Key = new Layer02_Objects._System.ClsKeys();
                            Inner_Key.Add("RecruitmentTestAnswersID", Layer01_Common.Common.Methods.Convert_Int64(this.RadWindow1_RadComboBox1.SelectedValue));
                            Obj_Answer.Load(Inner_Key);
                        }

                        Dr_QA["IsAnswer"] = this.RadWindow1_Chk_IsAnswer.Checked;
                        Dr_QA["Lkp_RecruitmentTestAnswersID_Desc"] = (string)Layer01_Common.Common.Methods.IsNull(Obj_Answer.pDr["Answer"], "");

                        break;
                    }
                case "Delete":
                    {
                        Int64 Key = Methods.Convert_Int64(this.RadGrid1.MasterTableView.Items[ItemIndex].GetDataKeyValue("TmpKey").ToString());
                        ClsQuestion Obj = (ClsQuestion)this.mObj_Base;
                        DataRow[] Arr_Dr = Obj.pDt_QuestionAnswer.Select("TmpKey = " + Key);
                        if (Arr_Dr.Length > 0)
                        { Arr_Dr[0].Delete(); }
                        break;
                    }
            }

            this.BindGrid();
        }
Beispiel #15
0
        //[-]
        public virtual void Load(ClsKeys Keys = null)
        {
            ClsDataAccess Da = new ClsDataAccess();
            StringBuilder Sb_Condition = new StringBuilder();
            string Condition = "";

            try
            {
                if (Keys != null)
                {
                    if (Keys.Count() != this.mHeader_Key.Count)
                    { throw new Exception("Keys not equal to required keys."); }

                    string Inner_Condition_And = "";
                    bool IsStart = false;
                    foreach (string Inner_Key in this.mHeader_Key)
                    {
                        Sb_Condition.Append(Inner_Condition_And + " " + Inner_Key + " = " + Keys[Inner_Key]);
                        if (!IsStart) Inner_Condition_And = " And ";
                        IsStart = true;
                    }
                }

                Condition = Sb_Condition.ToString();

                Da.Connect();

                DataTable Dt;
                DataRow Dr;

                if (Keys == null)
                {
                    Dt = Methods_Query.GetQuery(Da, this.mHeader_ViewName, "*", "1 = 0");
                    Dr = Dt.NewRow();
                }
                else
                {
                    Dt = Methods_Query.GetQuery(Da, this.mHeader_ViewName, "*", Condition);
                    Dr = Dt.Rows[0];
                }

                this.mHeader_Dr = Dr;

                //[-]

                if (this.mBase_TableDetail != null)
                {
                    foreach (ClsBaseTableDetail Inner_Obj in this.mBase_TableDetail)
                    { Inner_Obj.Load(Da, Condition); }
                }

                //[-]

                if (this.mBase_RowDetail != null)
                {
                    foreach (ClsBaseRowDetail Inner_Obj in this.mBase_RowDetail)
                    { Inner_Obj.Load(Da, Condition); }
                }

                //[-]

                this.AddRequired();
            }
            catch { }
        }
        public override void Load(ClsKeys Keys = null)
        {
            base.Load(Keys);
            this.CheckIfDeleted();

            //[-]

            Int64 QuestionID = Convert.ToInt64(Layer01_Methods.IsNull(this.pDr["RecruitmentTestQuestionsID"], 0));
            if (QuestionID != 0)
            {
                Keys = new ClsKeys();
                Keys.Add("Lkp_RecruitmentTestQuestionsID", QuestionID);
            }
            else
            { Keys = null; }

            this.mBL_QuestionAnswer.Load(Keys);

            foreach (DataRow Dr in this.mBL_QuestionAnswer.pDt_List.Rows)
            {
                ClsAnswer Inner_Obj = new ClsAnswer();
                ClsKeys Inner_Keys = null;
                Int64 Inner_ID = Convert.ToInt64(Layer01_Methods.IsNull(Dr["Lkp_RecruitmentTestAnswersID"], 0));

                if (Inner_ID != 0)
                {
                    Inner_Keys = new ClsKeys();
                    Inner_Keys.Add("RecruitmentTestAnswersID", Inner_ID);
                }

                Inner_Obj.Load(Inner_Keys);
                this.mBO_Answer.Add(Convert.ToInt64(Layer01_Methods.IsNull(Dr["TmpKey"], 0)).ToString(), Inner_Obj);
            }

            DataRow[] ArrDr = this.mBL_QuestionAnswer.pDt_List.Select("", "OrderIndex");
            int Ct = 0;
            foreach (DataRow Dr in ArrDr)
            {
                Ct++;
                Dr["OrderIndex"] = Ct;
            }

            this.FixOrderIndex(true);
            this.mBL_QuestionAnswer.pDt_List.DefaultView.Sort = "OrderIndex";
        }
        public void LoadExam(Int64 ExamID, Int64 ItemsLimit)
        {
            ClsBase Base = new ClsBase();
            Interface_DataAccess Da = Base.pDa;

            DataTable Dt_Exam = Da.GetQuery("RecruitmentTestExams", "", "RecruitmentTestExamsID = " + ExamID);
            Int64 ApplicantID = 0;
            if (Dt_Exam.Rows.Count > 0)
            {
                this.mDr_Exam = Dt_Exam.Rows[0];
                ApplicantID = Convert.ToInt64(Layer01_Methods.IsNull(this.mDr_Exam["RecruitmentTestApplicantID"], 0));
            }
            else
            { throw new Exception("Exam Data not found."); }

            ClsKeys Key = new ClsKeys();
            Key.Add("RecruitmentTestApplicantID", ApplicantID);

            this.mObj_Applicant = new ClsApplicant();
            this.mObj_Applicant.Load(Key);

            DataSet Ds = this.mEm.LoadExam(ExamID);
            this.mDs = Ds;
            this.mDt_Question = Ds.Tables[0];
            this.mDt_Question_Answer = Ds.Tables[1];

            this.mDt_Question.Columns.Add("Ct", typeof(Int64));
            Int64 Ct = 0;
            foreach (DataRow Dr in this.mDt_Question.Rows)
            {
                Ct++;
                Dr["Ct"] = Ct;
            }

            this.mDt_Question_Answer.Columns.Add("Ct", typeof(Int64));
            Ct = 0;
            foreach (DataRow Dr in this.mDt_Question_Answer.Rows)
            {
                Ct++;
                Dr["Ct"] = Ct;
            }

            this.mItemsLimit = ItemsLimit;
            this.mItems = this.mDt_Question.Rows.Count;

            this.mPages = this.mItems / this.mItemsLimit;
            if (this.mItems % this.mItemsLimit > 0)
            { this.mPages++; }
        }
        void SetupPage()
        {
            ClsSysCurrentUser CurrentUser = this.Master.pCurrentUser;
            Int64 ID = Methods.Convert_Int64(this.Request.QueryString["ID"]);
            ClsKeys Key = null;

            if (ID != 0)
            {
                Key = new Layer02_Objects._System.ClsKeys();
                Key.Add("RecruitmentTestQuestionsID", ID);
            }
            else
            { this.mIsNew = true; }

            this.mObj_Base = new ClsQuestion(this.Master.pCurrentUser);
            this.mObj_Base.Load(Key);

            this.mObjID = CurrentUser.GetNewPageObjectID();
            this.ViewState[CnsObjID] = this.mObjID;
            this.Session[this.mObjID] = this.mObj_Base;

            //[-]

            Int64 UserID = Methods.Convert_Int64(CurrentUser.pDrUser["RecruitmentTestUserID"], 0);
            Int64 UserID_CreatedBy = Methods.Convert_Int64(this.mObj_Base.pDr["RecruitmentTestUserID_CreatedBy"], 0);
            bool IsApproved = Convert.ToBoolean(Methods.IsNull(this.mObj_Base.pDr["IsApproved"], false));

            if (!
                    (
                        (CurrentUser.pIsAdmin || ((UserID == UserID_CreatedBy) && (!IsApproved)))
                        || (this.mIsNew)
                    )
                )
            { this.mIsReadOnly = true; }

            //[-]

            if ((bool)Methods.IsNull(CurrentUser.pDrUser["IsAdministrator"], false))
            {
                this.Btn_Approve.Enabled = true;
                //this.Btn_Approve2.Enabled = true;
            }

            //[-]

            ClsQuestion Obj_Question = (ClsQuestion)this.mObj_Base;

            this.Txt_Question.Text = (string)Methods.IsNull(Obj_Question.pDr["Question"], "");
            this.Chk_IsMultipleAnswer.Checked = Convert.ToBoolean(Methods.IsNull(Obj_Question.pDr["IsMultipleAnswer"], false));

            //[-]

            this.SetupPage_ControlAttributes();
            this.BindGrid();
        }