Beispiel #1
0
        public CallRecord GetRecord(int ID)
        {
            string          com     = "SELECT * FROM IncomingCalls WHERE ID = " + ID.ToString();
            MySqlCommand    command = new MySqlCommand(com, con);
            MySqlDataReader reader  = command.ExecuteReader();
            CallRecord      record  = new CallRecord();
            int             counter = 0;

            while (reader.Read())
            {
                counter++;
                record.ID             = ID;
                record.Date           = reader["Date"].ToString();
                record.Time           = reader["Time"].ToString();
                record.Name           = reader["Name"].ToString();
                record.Phone          = reader["PhoneNumber"].ToString();
                record.Type           = reader["TechType"].ToString();
                record.Brand          = reader["Brand"].ToString();
                record.Reason         = reader["Reason"].ToString();
                record.Status         = CallRecord.StringToStatus(reader["State"].ToString());
                record.DiagnosticDate = reader["DiagnosticDate"].ToString();
                record.RecallDate     = reader["RecallDate"].ToString();
            }
            reader.Close();
            return(record);
        }
Beispiel #2
0
        public string WriteRecord(CallRecord record)
        {
            string       com  = (new StringBuilder()).AppendFormat("INSERT INTO IncomingCalls (Date,Time,Name,PhoneNumber,TechType,Brand,Reason,State) VALUES ('{0}','{1}','{2}','+7{3}','{4}','{5}','{6}','{7}')", record.Date, record.Time, record.Name, record.Phone, record.Type, record.Brand, record.Reason, CallRecord.StatusToString(record.Status)).ToString();
            MySqlCommand comm = new MySqlCommand(com, con);

            comm.ExecuteNonQuery();
            RecordReceived();
            return(com);
        }
Beispiel #3
0
        public int[] GetTotalCallsToday()
        {
            string          com          = "SELECT * FROM IncomingCalls WHERE Date = '" + DateTime.Now.ToShortDateString() + "'";
            MySqlCommand    command      = new MySqlCommand(com, con);
            MySqlDataReader reader       = command.ExecuteReader();
            int             counter      = 0;
            int             wrongCounter = 0;

            while (reader.Read())
            {
                counter++;
                if (reader["State"].ToString() == CallRecord.StatusToString(ApplicationStatus.WrongCall))
                {
                    wrongCounter++;
                }
            }
            reader.Close();

            int[] ar = new int[2];
            ar[0] = counter;
            ar[1] = wrongCounter;
            return(ar);
        }
Beispiel #4
0
        public List <CallRecord> GetAllAtDiagnostic()
        {
            List <CallRecord> records = new List <CallRecord>();

            string com = "SELECT * FROM IncomingCalls WHERE DiagnosticDate = '" + DateTime.Now.ToShortDateString() + "'";

            MySqlCommand command = new MySqlCommand(com, con);

            MySqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                CallRecord rec = new CallRecord();
                rec.Name   = reader["Name"].ToString();
                rec.Phone  = reader["PhoneNumber"].ToString();
                rec.Reason = reader["Reason"].ToString();
                rec.Status = CallRecord.StringToStatus(reader["State"].ToString());
                records.Add(rec);
            }

            reader.Close();
            return(records);
        }
Beispiel #5
0
        public bool UpdateRecord(CallRecord record)
        {
            string com = " ";

            try
            {
                com = new StringBuilder().AppendFormat("" +
                                                       "UPDATE" +
                                                       " IncomingCalls" +
                                                       " SET" +
                                                       " Date = '{0}'," +
                                                       " Time = '{1}'," +
                                                       " Name = '{2}'," +
                                                       " PhoneNumber = '{3}'," +
                                                       " TechType = '{4}'," +
                                                       " Brand = '{5}'," +
                                                       " Reason = '{6}'," +
                                                       " State =  '{7}'," +
                                                       " DiagnosticDate = '{8}'," +
                                                       " RecallDate = '{9}'" +
                                                       " WHERE ID= {10}"
                                                       , record.Date, record.Time, record.Name, record.Phone, record.Type,
                                                       record.Brand, record.Reason,
                                                       CallRecord.StatusToString(record.Status),
                                                       record.DiagnosticDate, record.RecallDate, record.ID.ToString()).ToString();

                MySqlCommand command = new MySqlCommand(com, con);
                command.ExecuteNonQuery();
                RecordReceived();
                return(true);
            }
            catch (MySqlException e)
            {
                return(false);
            }
        }
Beispiel #6
0
        public List <CallRecord> GetAllRecievedRecords()
        {
            List <CallRecord> records = new List <CallRecord>();

            string       com     = "SELECT ID, Date, Time, Name, PhoneNumber, TechType, Brand, Reason, State FROM IncomingCalls WHERE State = 'Звонок принят'";
            MySqlCommand command = new MySqlCommand(com, con);

            MySqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                records.Add(new CallRecord(Convert.ToInt32(reader["ID"].ToString()), reader["Date"].ToString(), reader["Time"].ToString(), reader["Name"].ToString(), reader["PhoneNumber"].ToString(), reader["TechType"].ToString(), reader["Brand"].ToString(), reader["Reason"].ToString(), CallRecord.StringToStatus(reader["State"].ToString())));
            }

            reader.Close();
            return(records);
        }