예제 #1
0
파일: Branch.cs 프로젝트: nettatata/btsman
        public static bool CreateForm(OdbcDataReader reader, Branch branch)
        {
            int fCount = reader.FieldCount;
            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);

                // Map to DB field. Need to change if db changed
                switch (name) {
                    case "branch_id": branch._branchID = reader.GetInt32(i);
                                      break;
                    case "branch_name": branch._branchName = reader.GetString(i);
                                      break;
                    case "branch_code": branch._branchCode = reader.GetString(i);
                                      break;
                    case "address": branch._address = reader.GetString(i);
                                      break;
                    case "tel": branch._tel = reader.GetString(i);
                                      break;
                    case "img": branch._img = reader.GetString(i);
                                      break;
                    case "supervisor": branch._supervisor = reader.GetString(i);
                                      break;
                }
            }
            return reader.HasRows;
        }
예제 #2
0
파일: AppUser.cs 프로젝트: nettatata/btsman
        public static bool CreateForm(OdbcDataReader reader, AppUser user)
        {
            int fCount = reader.FieldCount;
            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);
                // Map to DB field. Need to change if db changed
                switch (name)
                {
                    case "username": user._username = reader.GetString(i);
                        break;
                    case "user_id": user._userId = reader.GetInt32(i);
                        break;
                    case "passwd": user._encodedPassword = reader.GetString(i);
                        break;
                    case "firstname": user._firstname = reader.GetString(i);
                        break;
                    case "surname": user._surname = reader.GetString(i);
                        break;
                    case "role_id": user._roleId = reader.GetInt32(i);
                        break;
                    case "branch_id": user._branchID = reader.GetInt32(i);
                        break;
                    case "is_valid": user._isValid = reader.GetInt32(i) > 0 ? true : false;
                        break;

                    // helper info
                    case "branch_name": user._branchName = reader.GetString(i);
                        break;

                }
            }
            return reader.HasRows;
        }
예제 #3
0
파일: Room.cs 프로젝트: nettatata/btsman
        public static bool CreateForm(OdbcDataReader reader, Room room)
        {
            int fCount = reader.FieldCount;
            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);

                // Map to DB field. Need to change if db changed
                switch (name) {
                    case "room_id": room._roomID = reader.GetInt32(i);
                                      break;
                    case "branch_id": room._branchID = reader.GetInt32(i);
                                      break;
                    case "name": room._name = reader.GetString(i);
                                      break;
                    case "seat_no": room._seatNo = reader.GetInt32(i);
                                      break;
                    case "img": room._img = reader.GetString(i);
                                      break;
                    case "description": room._description = reader.GetString(i);
                                      break;

                    // helper info
                    case "branch_name": room._branchName = reader.GetString(i);
                                      break;

                }
            }
            return reader.HasRows;
        }
예제 #4
0
 private static void PrintResults(OdbcDataReader reader) {
   for (int ii = 0; ii < reader.FieldCount; ii += 1) {
     System.Console.Write("{0}{1}",
         reader.GetName(ii),
         ii + 1 < reader.FieldCount ? "\t" : "\n");
   }
   while (reader.Read()) {
     for (int ii = 0; ii < reader.FieldCount; ii += 1) {
       System.Console.Write("{0}{1}",
           reader.GetValue(ii),
           ii + 1 < reader.FieldCount ? "\t" : "\n");
     }
   }
 }
예제 #5
0
파일: Role.cs 프로젝트: nettatata/btsman
        public static bool CreateForm(OdbcDataReader reader, Role role)
        {
            int fCount = reader.FieldCount;
            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);

                // Map to DB field. Need to change if db changed
                switch (name) {
                    case "name": role._name = reader.GetString(i);
                                      break;
                    case "role_id": role._roleId = reader.GetInt32(i);
                                      break;
                }
            }
            return reader.HasRows;
        }
예제 #6
0
        public static void LVLoad(System.Windows.Forms.ListView LV,
                                  System.Data.Odbc.OdbcDataReader reader,
                                  bool bUpdateHeaders)
        {
            int    i = 0, nFields = 0, nRows = 0;
            string s;

            try
            {
                LV.BeginUpdate();
                LV.Sorting = SortOrder.None;
                LV.Items.Clear();

                if (bUpdateHeaders == true)
                {
                    LV.Columns.Clear();
                    nFields = reader.FieldCount;
                    for (i = 0; i < nFields; i++)
                    {
                        LV.Columns.Add(reader.GetName(i));
                    }
                }

                nRows = 0;
                while (reader.Read())
                {
                    s = reader.GetValue(0).ToString();
                    LV.Items.Add(s);

                    for (i = 1; i < nFields; i++)
                    {
                        s = reader.GetValue(i).ToString();
                        LV.Items[nRows].SubItems.Add(s);
                    }
                    nRows += 1;
                }

                LV.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                LV.EndUpdate();
            }catch (Exception ex) { MessageBox.Show(ex.Message); }
            finally
            {
            }
        }
예제 #7
0
파일: Payment.cs 프로젝트: nettatata/btsman
        public static bool CreateForm(OdbcDataReader reader, Payment payment)
        {
            int fCount = reader.FieldCount;
            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);

                // Map to DB field. Need to change if db changed
                switch (name) {
                    case "course_id": payment._courseID = reader.GetInt32(i);
                                      break;
                    case "sum_all_cost": payment._sumAllCost = reader.GetInt32(i);
                                      break;
                    case "sum_max_payable": payment._sumMaxPayable = reader.GetInt32(i);
                                      break;
                    case "sum_paid_cost": payment._sumPaidCost = reader.GetInt32(i);
                                      break;
                    case "last_paid_date": payment._lastPaidDate = new DateTime(reader.GetDate(i).Ticks);
                                      break;
                    case "paid_round": payment._paidRound = reader.GetInt32(i);
                                      break;
                    case "status": payment._status = reader.GetInt32(i);
                                      break;
                    // helper info
                    case "bts_course_id": payment._btsCourseID = reader.GetString(i);
                                      break;
                    case "course_name": payment._courseName = reader.GetString(i);
                                      break;
                    case "course_start_date": payment._courseStartDate = new DateTime(reader.GetDate(i).Ticks);
                                      break;
                    case "course_end_date": payment._courseEndDate = new DateTime(reader.GetDate(i).Ticks);
                                      break;
                    case "paid_group_id": payment._paidGroupID = reader.GetInt32(i);
                                      break;

                }
            }
            return reader.HasRows;
        }
예제 #8
0
파일: Teacher.cs 프로젝트: nettatata/btsman
        public static bool CreateForm(OdbcDataReader reader, Teacher teacher)
        {
            int fCount = reader.FieldCount;
            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);

                // Map to DB field. Need to change if db changed
                switch (name) {
                    case "teacher_id": teacher._teacherID = reader.GetInt32(i);
                                      break;
                    case "sex": teacher._sex = reader.GetString(i);
                                      break;
                    case "addr": teacher._addr = reader.GetString(i);
                                      break;
                    case "tel": teacher._tel = reader.GetString(i);
                                      break;
                    case "email": teacher._email = reader.GetString(i);
                                      break;
                    case "birthday":
                        teacher._birthday = new DateTime(reader.GetDate(i).Ticks);
                                      break;
                    case "firstname": teacher._firstname = reader.GetString(i);
                                      break;
                    case "surname": teacher._surname = reader.GetString(i);
                                      break;
                    case "citizen_id": teacher._citizenID = reader.GetString(i);
                                      break;
                    case "image": teacher._img = reader.GetString(i);
                                      break;
                    case "subject": teacher._subject = reader.GetString(i);
                                      break;
                    case "is_active": teacher._isActive = reader.GetInt32(i) > 0 ? true : false;
                                      break;

                }
            }
            return reader.HasRows;
        }
예제 #9
0
        public static bool CreateForm(OdbcDataReader reader, PaidGroup paidGroup)
        {
            int fCount = reader.FieldCount;
            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);
                // Map to DB field. Need to change if db changed
                switch (name) {
                    case "paid_group_id": paidGroup._paidGroupID = reader.GetInt32(i);
                                      break;
                    case "name": paidGroup._name = reader.GetString(i);
                                      break;
                    case "current_round": paidGroup._currentRound = reader.GetInt32(i);
                                      break;
                    case "rate_info": paidGroup._rawRateInfo = reader.GetString(i);
                                      paidGroup._rateInfo = PaidRateInfo.Parse(paidGroup._rawRateInfo);
                                      break;

                    // helper info

                }
            }
            return reader.HasRows;
        }
예제 #10
0
        //---------------------------------------------------//
        private bool execute_query(out OdbcDataReader rec, out bool set_eof, out Hashtable fieldNames, string query, int RecordLimit = -1)
        {
            rec = null;
            set_eof = true;
            fieldNames = new Hashtable(0);

            if (m_con==null) return false;

            OdbcCommand cmd;

            if (RecordLimit >= 0)
            {
                query += SQL_LIMIT_FORMAT(RecordLimit);
            }

            try
            {
                cmd = new OdbcCommand(query, m_con);
            }
            catch (Exception e)
            {
                Form1.addError(e.Message);
                Form1.addError(query);
                return false;
            }

            //-- execute --/
            try
            {
                rec = cmd.ExecuteReader();
            }
            catch (Exception e)
            {
                Form1.addError(e.Message);
                Form1.addError(query);
                return false;
            }


            try
            {
                set_eof = !rec.Read();
            }
            catch (Exception e)
            {
                Form1.addError(e.Message);
                Form1.addError(query);
                set_eof = true;
                return false;
            }

            //-- read Fieldnames --//
            int l = rec.FieldCount;
            fieldNames = new Hashtable(l);

            for (int i = 0; i < l; i++)
            {
                fieldNames.Add(rec.GetName(i).ToLower(), i);
            }

            return true;
        }
예제 #11
0
        private void FillPhysicalTable(OdbcDataReader reader, int colCount, int rowCount)
        {
            //Resets the objects
            foreach(Node nd in Tree.NodeL)
            {
                nd.AttributeL.Clear();
                nd.Dispose();
                nd.LabelTop.Dispose();
                nd.LabelBotton.Dispose();
            }
            Tree.NodeL.Clear();
            Tree.VariableL.Clear();
            Tree.LevelBrotherL.Clear();
            Tree.LevelLast=0;
            Tree.Width = 0;
            Tree.Height = 0;
            Node.CntId=-1;
            //End resets
            //Code of the static tree constructor that must be called
            ArrayList bL = new ArrayList();
            Tree.LevelBrotherL.Add(bL);
            //end Code of the static tree constructor that must be called
            GC.Collect();
            GC.WaitForPendingFinalizers();

            FrmMain.SFrmMain.PT = new PhysicalTable(colCount , rowCount);
            int x, y;
            bool firstTime = true;
            Variable var;
            string colName="";

            grid.Rows.Count = rowCount+1;
            grid.Cols.Count = colCount+1;
            y=0;

            while(reader.Read())
            {
                grid[y+1, 0]=y;
                for(x=0; x < reader.FieldCount; ++x)
                {
                    if(firstTime)
                    {
                        colName = reader.GetName(x).ToLower();
                        grid[y, x+1] = colName;
                        if(reader[x] is double || reader[x] is int)
                        {
                            FrmMain.SFrmMain.PT.AddCol(x, colName, rowCount, PhysicalColumn.DataTypeEnum.Number);
                            var = new Variable(colName, Variable.TypeEnum.Continuous, PhysicalColumn.DataTypeEnum.Number);
                        }
                        else
                        {
                            FrmMain.SFrmMain.PT.AddCol(x, colName, rowCount, PhysicalColumn.DataTypeEnum.Text);
                            var = new Variable(colName, Variable.TypeEnum.Categorical, PhysicalColumn.DataTypeEnum.Text);
                        }
                    }
                    FrmMain.SFrmMain.PT[x, y]=reader[x];
                    grid[y+1, x+1] = reader[x];
                }
                firstTime=false;
                ++y;
            }
            grid.Visible=true;
            //			grid.Cols //Set a code to autofit the columns width

            VirtualTable virtualTable = new VirtualTable(FrmMain.SFrmMain.PT);
            Node root = new Node("All data", virtualTable);
            Tree.Root = root;
        }
예제 #12
0
파일: Course.cs 프로젝트: nettatata/btsman
        public static bool CreateForm(OdbcDataReader reader, Course course)
        {
            if (course._teacher == null) { course._teacher = new Teacher(); }
            if (course._paidGroup == null) { course._paidGroup = new PaidGroup(); }

            int fCount = reader.FieldCount;
            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);

                // Map to DB field. Need to change if db changed
                switch (name) {
                    case "course_id": course._courseID = reader.GetInt32(i);
                                      break;
                    case "bts_course_id": course._btsCourseID = reader.GetString(i);
                                      break;
                    case "course_name": course._courseName = reader.GetString(i);
                                      break;
                    case "short_name": course._shortName = reader.GetString(i);
                                      break;
                    case "course_desc": course._courseDesc = reader.GetString(i);
                                      break;
                    case "course_type": course._courseType = reader.GetString(i);
                                      break;
                    case "room_id": course._roomID = reader.GetInt32(i);
                                      break;
                    case "teacher_id": course._teacherID = reader.GetInt32(i);
                                      course._teacher._teacherID = course._teacherID;
                                      break;
                    case "paid_group_id": course._paidGroupID = reader.GetInt32(i);
                                      course._paidGroup._paidGroupID = course._paidGroupID;
                                      break;
                    case "category": course._category = reader.GetString(i);
                                      break;
                    case "start_date": course._startdate = new DateTime(reader.GetDate(i).Ticks);
                                      break;
                    case "end_date": course._enddate = new DateTime(reader.GetDate(i).Ticks);
                                      break;
                    case "day_of_week": course._dayOfWeek = reader.GetString(i);
                                      break;
                    case "open_time": course._opentime = reader.GetString(i);
                                      break;
                    case "cost":      course._cost = reader.GetInt32(i);
                                      course._discountedCost = course._cost;
                                      break;
                    case "seat_limit": course._seatLimit = reader.GetInt32(i);
                                      break;
                    case "bank_regis_limit": course._bankRegisLimit = reader.GetInt32(i);
                                      break;
                    case "image": course._img = reader.GetString(i);
                                      break;
                    case "is_active": course._isActive = reader.GetInt32(i) > 0 ? true : false;
                                      break;
                    // helper info
                    case "teacher_firstname":
                                      course._teacher._firstname = reader.GetString(i);
                                      break;
                    case "teacher_surname":
                                      course._teacher._surname = reader.GetString(i);
                                      break;
                    case "num_registered":
                                      course._numRegistered = reader.GetInt32(i);
                                      break;

                }
            }
            return reader.HasRows;
        }
예제 #13
0
        public static bool CreateForm(OdbcDataReader reader, Registration reg)
        {
            int fCount = reader.FieldCount;
            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);

                // Map to DB field. Need to change if db changed
                switch (name) {
                    case "regis_id": reg._regisID = reader.GetInt32(i);
                                      break;
                    case "transaction_id": reg._transactionID = reader.GetInt32(i);
                                      break;
                    case "transaction_code": reg._transactionCode = reader.GetString(i);
                                      break;
                    case "regis_date": reg._regisdate = new DateTime(reader.GetDateTime(i).Ticks);
                                      break;
                    case "student_id": reg._studentID = reader.GetInt32(i);
                                      break;
                    case "promotion_id": reg._promotionID = reader.GetInt32(i);
                                      break;
                    case "course_id": reg._courseID = reader.GetInt32(i);
                                      break;
                    case "branch_id": reg._branchID = reader.GetInt32(i);
                                      break;

                    case "full_cost": reg._fullCost = reader.GetInt32(i);
                                      break;
                    case "discounted_cost": reg._discountedCost = reader.GetInt32(i);
                                      break;
                    case "seat_no": reg._seatNo = reader.GetString(i);
                                      break;
                    case "note": reg._note = reader.GetString(i);
                                      break;
                    case "paid_method": reg._paidMethod = reader.GetInt32(i);
                                      break;
                    case "paid_round": reg._paidRound = reader.GetInt32(i);
                                      break;
                    case "paid_date": reg._paiddate = new DateTime(reader.GetDateTime(i).Ticks);
                                      break;
                    case "username": reg._username = reader.GetString(i);
                                      break;
                    case "status": reg._status = reader.GetInt32(i);
                                      break;
                    case "is_paid": reg._isPaid = reader.GetInt32(i) > 0 ? true : false;
                                      break;

                    // helper info
                    case "bts_course_id":
                                      reg._btsCourseID = reader.GetString(i);
                                      break;
                    case "student_firstname":
                                      reg._studentFirstname = reader.GetString(i);
                                      break;
                    case "student_surname":
                                      reg._studentSurname = reader.GetString(i);
                                      break;
                    case "student_school":
                                      reg._studentSchool = reader.GetString(i);
                                      break;
                    case "student_level":
                                      reg._studentLevel = reader.GetInt32(i);
                                      break;
                    case "course_name":
                                      reg._courseName = reader.GetString(i);
                                      break;
                    case "course_type":
                                      reg._courseType = reader.GetString(i);
                                      break;
                    case "course_category":
                                      reg._courseCategotry = reader.GetString(i);
                                      break;
                    case "start_date": reg._courseStart = new DateTime(reader.GetDateTime(i).Ticks);
                                      break;
                    case "end_date": reg._courseEnd = new DateTime(reader.GetDateTime(i).Ticks);
                                      break;

                    case "course_short_name":
                                      reg._courseShortName = reader.GetString(i);
                                      break;
                    case "branch_code":
                                      reg._branchCode = reader.GetString(i);
                                      break;

                }
            }
            return reader.HasRows;
        }
예제 #14
0
        /// <summary>
        /// Transfere dados do banco de dados atual para um banco de dados de destino.
        /// Conexão com o banco de destino precisa estar aberta.
        /// </summary>
        /// <returns>Número de linhas transferidas.</returns>
        /// <param name="p_query">Consulta SQL para buscar os dados no banco atual.</param>
        /// <param name="p_insert">Comando de inserção para inserir cada linha no banco de destino.</param>
        /// <param name="p_destdatabase">Conexão com o banco de destino.</param>
        public override uint Transfer(string p_query, Spartacus.Database.Command p_insert, Spartacus.Database.Generic p_destdatabase)
        {
            uint v_transfered = 0;

            if (this.v_con == null)
            {
                try
                {
                    this.v_con = new System.Data.Odbc.OdbcConnection(this.v_connectionstring);
                    this.v_con.Open();
                    this.v_cmd = new System.Data.Odbc.OdbcCommand(p_query, this.v_con);
                    this.v_reader = this.v_cmd.ExecuteReader();

                    while (v_reader.Read())
                    {
                        for (int i = 0; i < v_reader.FieldCount; i++)
                            p_insert.SetValue(this.FixColumnName(v_reader.GetName(i)).ToLower(), v_reader[i].ToString());

                        p_destdatabase.Execute(p_insert.GetUpdatedText());
                        v_transfered++;
                    }

                    return v_transfered;
                }
                catch (System.Data.Odbc.OdbcException e)
                {
                    throw new Spartacus.Database.Exception(e);
                }
                finally
                {
                    if (this.v_reader != null)
                    {
                        this.v_reader.Close();
                        this.v_reader = null;
                    }
                    if (this.v_cmd != null)
                    {
                        this.v_cmd.Dispose();
                        this.v_cmd = null;
                    }
                    if (this.v_con != null)
                    {
                        this.v_con.Close();
                        this.v_con = null;
                    }
                }
            }
            else
            {
                try
                {
                    this.v_cmd.CommandText = p_query;
                    this.v_reader = this.v_cmd.ExecuteReader();

                    while (v_reader.Read())
                    {
                        for (int i = 0; i < v_reader.FieldCount; i++)
                            p_insert.SetValue(this.FixColumnName(v_reader.GetName(i)).ToLower(), v_reader[i].ToString());

                        p_destdatabase.Execute(p_insert.GetUpdatedText());
                        v_transfered++;
                    }

                    return v_transfered;
                }
                catch (System.Data.Odbc.OdbcException e)
                {
                    throw new Spartacus.Database.Exception(e);
                }
                finally
                {
                    if (this.v_reader != null)
                    {
                        this.v_reader.Close();
                        this.v_reader = null;
                    }
                }
            }
        }
예제 #15
0
        public static bool CreateForm(OdbcDataReader reader, PaymentHistory paymentHistory)
        {
            int fCount = reader.FieldCount;
            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);

                // Map to DB field. Need to change if db changed
                switch (name)
                {
                    case "payment_id": paymentHistory._paymentID = reader.GetInt32(i);
                        break;
                    case "course_id": paymentHistory._courseID = reader.GetInt32(i);
                        break;
                    case "paid_cost": paymentHistory._paidCost = reader.GetInt32(i);
                        break;
                    case "paid_date": paymentHistory._paidDate = new DateTime(reader.GetDateTime(i).Ticks);
                        break;
                    case "sum_all_cost": paymentHistory._sumAllCost = reader.GetInt32(i);
                        break;
                    case "sum_max_payable": paymentHistory._sumMaxPayable = reader.GetInt32(i);
                        break;
                    case "sum_paid_cost": paymentHistory._sumPaidCost = reader.GetInt32(i);
                        break;
                    case "cost_info": paymentHistory._costInfo = reader.GetString(i);
                        break;
                    case "paid_round": paymentHistory._paidRound = reader.GetInt32(i);
                        break;
                    case "receiver_teacher_id": paymentHistory._receiverTeacherID = reader.GetInt32(i);
                        break;
                    case "username": paymentHistory._username = reader.GetString(i);
                        break;
                    case "branch_id": paymentHistory._branchID = reader.GetInt32(i);
                        break;

                    // helper info
                }
            }
            return reader.HasRows;
        }