Beispiel #1
0
        private void updateIntoDatabase(User user, AppointmentTime appointmentTime, Spec spec)
        {
            try
            {
                string _date = appointmentTime.Dttime.ToString("yyyy-MM-dd");
                _date = _date.Replace(".", "-");
                string _hours   = appointmentTime.Hrtime;
                string _minutes = appointmentTime.Mntime;

                string _info = _date + " " + _hours + ":" + _minutes + " <br /><u>ПІБ: </u> " +
                               user.Name + " <br /><u>Телефон: </u>" + user.Phone;

                using (MySqlConnection conn = new MySqlConnection(ConnStr))
                {
                    string sql = "UPDATE enx4w_ttfsp SET iduser=@iduser, reception='1', rfio=@rfio, rphone=@rphone, info=@info, ipuser=@ipuser, rmail=@rmail" +
                                 " WHERE idspec=@idspec AND dttime=@dttime AND hrtime=@hrtime AND mntime=@mntime";

                    MySqlCommand cmd = new MySqlCommand(sql, conn);

                    cmd.Parameters.AddWithValue("@iduser", user.Id);
                    cmd.Parameters.AddWithValue("@rfio", user.Name);
                    cmd.Parameters.AddWithValue("@rphone", user.Phone);
                    cmd.Parameters.AddWithValue("@info", _info);
                    cmd.Parameters.AddWithValue("@ipuser", "localterminal");
                    cmd.Parameters.AddWithValue("@rmail", user.Email);
                    cmd.Parameters.AddWithValue("@idspec", spec.Id);
                    cmd.Parameters.AddWithValue("@dttime", _date);
                    cmd.Parameters.AddWithValue("@hrtime", _hours);
                    cmd.Parameters.AddWithValue("@mntime", _minutes);

                    conn.Open();

                    cmd.ExecuteNonQuery();
                    cmd.Parameters.Clear();

                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #2
0
        public string InsertAppointment(User user, AppointmentTime appointmentTime, Spec spec)
        {
            string numberOrder = null;

            try
            {
                string   tempOrder = GetNumberOrder();
                string[] tempArray = tempOrder.Split(new char[] { '-' });
                tempOrder = tempArray[0];

                numberOrder = (Convert.ToInt32(tempOrder) + 1).ToString() + "-TER";

                updateIntoDatabase(user, appointmentTime, spec);

                //string[] _dateTemp = appointmentTime.Dttime.Date.ToShortDateString().Split(new char[] { '.' });
                //string _date = _dateTemp[2] + "-" + _dateTemp[1] + "-" + _dateTemp[0];
                string _date           = appointmentTime.Dttime.ToString("yyyy-MM-dd");
                string _hours          = appointmentTime.Hrtime;
                string _minutes        = appointmentTime.Mntime;
                string _office_address = "м.Шостка, вул. Щедріна, 1 Телефони:\r+ 38(05449) 3 - 28 - 95,\r+38(05449) 3-23-52";

                string _info = _date + " " + _hours + ":" + _minutes + " <br /><u>ПІБ: </u> " +
                               user.Name + " <br /><u>Телефон: </u>" + user.Phone;

                using (MySqlConnection conn = new MySqlConnection(ConnStr))
                {
                    string sql = "INSERT INTO enx4w_ttfsp_dop (iduser, id_specialist, rfio, rphone, info, ipuser, rmail, number_order, cdate, date, hours, minutes, office_name, specializations_name, specialist_name, specialist_email, order_password, office_address, number_cabinet) " +
                                 "VALUES(@iduser, @id_specialist, @rfio, @rphone, @info, @ipuser, @rmail, @number_order, @cdate, @date, @hours, @minutes, @office_name, @specializations_name, @specialist_name, @specialist_email, @order_password, @office_address, @number_cabinet)";
                    MySqlCommand cmd = new MySqlCommand(sql, conn);

                    cmd.Parameters.AddWithValue("@iduser", user.Id);
                    cmd.Parameters.AddWithValue("@id_specialist", appointmentTime.Idspec);
                    cmd.Parameters.AddWithValue("@rfio", user.Name);
                    cmd.Parameters.AddWithValue("@rphone", user.Phone);
                    cmd.Parameters.AddWithValue("@info", _info);
                    cmd.Parameters.AddWithValue("@ipuser", "localterminal");
                    cmd.Parameters.AddWithValue("@rmail", user.Email);
                    cmd.Parameters.AddWithValue("@number_order", numberOrder);
                    cmd.Parameters.AddWithValue("@cdate", 1485730860);
                    cmd.Parameters.AddWithValue("@date", _date);
                    cmd.Parameters.AddWithValue("@hours", _hours);
                    cmd.Parameters.AddWithValue("@minutes", _minutes);
                    cmd.Parameters.AddWithValue("@office_name", "Полікліники №4");
                    cmd.Parameters.AddWithValue("@specializations_name", spec.Specialization);
                    cmd.Parameters.AddWithValue("@specialist_name", spec.Name);
                    cmd.Parameters.AddWithValue("@specialist_email", spec.SpecMail);
                    cmd.Parameters.AddWithValue("@order_password", "V9EFJP");
                    cmd.Parameters.AddWithValue("@office_address", _office_address);
                    cmd.Parameters.AddWithValue("@number_cabinet", spec.Number_cabinet);

                    conn.Open();

                    cmd.ExecuteNonQuery();
                    cmd.Parameters.Clear();

                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return(numberOrder);
        }