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;
        }
Exemplo n.º 2
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 { }
        }