Example #1
0
        private DataTable loadPhototerminalOrdersFromDB(string what)
        {
            FormLoading loading = new FormLoading();

            loading.Show();

            DataTable tblOrders = new DataTable();

            using (var con = new DBUtils().getDBConnection())
            {
                using (var cmd = new MySqlCommand("get_phototerminal_orders", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new MySqlParameter("@what", MySqlDbType.VarChar));
                    cmd.Parameters["@what"].Value = what;
                    cmd.Parameters.Add(new MySqlParameter("@dateFrom", MySqlDbType.VarChar));
                    cmd.Parameters["@dateFrom"].Value = Convert.ToDateTime(dateTimePickerFrom.Text).ToString("yyyy-MM-dd");;
                    cmd.Parameters.Add(new MySqlParameter("@dateTo", MySqlDbType.VarChar));
                    cmd.Parameters["@dateTo"].Value = Convert.ToDateTime(dateTimePickerTo.Text).ToString("yyyy-MM-dd");
                    MySqlDataAdapter dap = new MySqlDataAdapter(cmd);
                    dap.Fill(tblOrders);
                }
            }
            loading.Dispose();
            return(tblOrders);
        }
Example #2
0
        private bool checkLoginPass(string login, string pass)
        {
            FormLoading loading = new FormLoading();

            loading.Show();

            using (var con = new DBUtils().getDBConnection())
            {
                con.Open();
                using (var cmd = new MySqlCommand("check_login_pass", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new MySqlParameter("@login", MySqlDbType.VarChar));
                    cmd.Parameters["@login"].Value = login;
                    cmd.Parameters.Add(new MySqlParameter("@pass", MySqlDbType.VarChar));
                    cmd.Parameters["@pass"].Value = pass;
                    if (cmd.ExecuteReader().HasRows)
                    {
                        loading.Dispose();
                        return(true);
                    }
                    else
                    {
                        loading.Dispose();
                        return(false);
                    }
                }
            }
        }
Example #3
0
        private void FormLogs_Load(object sender, EventArgs e)
        {
            FormLoading loading = new FormLoading();

            loading.Show();

            using (var mySqlConnection = new DBUtils().getDBConnection())
            {
                mySqlConnection.Open();
                using (var cmd = new MySqlCommand("load_logs", mySqlConnection))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    using (DbDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                string strResult = reader.GetString(0).Replace("\\n", Environment.NewLine);
                                richTextBox1.Text += strResult + "\n--------------------------\n";
                            }
                        }
                    }
                }
            }
            loading.Dispose();
        }
Example #4
0
        private void buttonSend_Click(object sender, EventArgs e)
        {
            FormLoading loading = new FormLoading();

            loading.Show(this);
            try
            {
                SmtpClient smtp = new SmtpClient("smtp.mail.ru");
                using (MailMessage message = new MailMessage())
                {
                    Encoding encoding = System.Text.Encoding.UTF8;
                    message.IsBodyHtml      = false;
                    message.SubjectEncoding = encoding;
                    message.BodyEncoding    = encoding;
                    message.From            = new MailAddress("*****@*****.**", "USERS", encoding);
                    message.Bcc.Add(new MailAddress("*****@*****.**", "leninred", encoding));
                    message.Subject = "New Error Detected in CRM";
                    message.Body    = richTextBoxErrorInfo.Text;
                    if (!openFileDialog1.FileName.Contains("openFileDialog1"))
                    {
                        var attachment = new Attachment(openFileDialog1.FileName);
                        message.Attachments.Add(attachment);
                    }
                    smtp.EnableSsl      = true;
                    smtp.Credentials    = new System.Net.NetworkCredential("*****@*****.**", "Zxcvb123!");
                    smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                    smtp.Send(message);
                    MessageBox.Show("Сообщение отправлено");
                    this.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            loading.Dispose();
        }
Example #5
0
        private void buttonAddOrder_Click(object sender, EventArgs e)
        {
            if (!checkInet())
            {
                return;
            }
            FormLoading loading = new FormLoading();

            loading.Show();

            string custName, comm, subcomm = "-";

            if (radioButtonExistCustomer.Checked)
            {
                if (comboBoxCustomers.SelectedIndex != -1)
                {
                    string selectedCustomer = comboBoxCustomers.SelectedItem.ToString();
                    custName = selectedCustomer.Substring(0, selectedCustomer.IndexOf('('));
                    comm     = selectedCustomer.Substring(selectedCustomer.IndexOf('(') + 1, selectedCustomer.IndexOf(')') - selectedCustomer.IndexOf('(') - 1);
                }
                else
                {
                    MessageBox.Show("Выберите заказчика");
                    loading.Dispose();
                    return;
                }
            }
            else
            {
                custName = textBoxCustomer.Text;
                comm     = textBoxPriorComm.Text;
                subcomm  = textBoxSubComm.Text.ToString();
            }

            if (!checkCustomerExist(custName))
            {
                addNewCustomer(custName, comm, subcomm);
            }

            if ((comboBoxOrderStatus.SelectedIndex != -1) && (comboBoxOrderType.SelectedIndex != -1) && (comboBoxAcceptor.SelectedIndex != -1) && (comboBoxPointOfGrub.SelectedIndex != -1))
            {
                if (!custName.Trim().Equals(""))
                {
                    if (!comm.Trim().Equals(""))
                    {
                        if (!subcomm.Trim().Equals(""))
                        {
                            if (richTextBoxOrderInfo.Text.Length > 10)
                            {
                                if (textBoxCost.Text.Length > 1)
                                {
                                    if (textBoxFactCost.Text.Length > 1)
                                    {
                                        if (order_id == 0)
                                        {
                                            order_id = getLastOrderID() + 1;
                                        }
                                        else
                                        {
                                            string l = "";
                                            if (!logData[0].Equals(textBoxPriorComm.Text))
                                            {
                                                l += "Вид связи: " + logData[0] + " -> " + textBoxPriorComm.Text + "\n";
                                            }
                                            if (!logData[1].Equals(textBoxSubComm.Text))
                                            {
                                                l += "Доп вид связи: " + logData[1] + " -> " + textBoxSubComm.Text + "\n";
                                            }
                                            if (!logData[2].Equals(richTextBoxOrderInfo.Text))
                                            {
                                                l += "Инфо заказа: " + logData[2] + " -> " + richTextBoxOrderInfo.Text + "\n";
                                            }
                                            if (!logData[3].Equals(textBoxCost.Text))
                                            {
                                                l += "Цена: " + logData[3] + " -> " + textBoxCost.Text + "\n";
                                            }
                                            if (!logData[4].Equals(textBoxFactCost.Text))
                                            {
                                                l += "Фактический оплаченныя сумма: " + logData[4] + " -> " + textBoxFactCost.Text + "\n";
                                            }
                                            if (!logData[5].Equals(comboBoxOrderType.Text))
                                            {
                                                l += "Тип заказа: " + logData[5] + " -> " + comboBoxOrderType.Text + "\n";
                                            }
                                            if (!logData[6].Equals(comboBoxOrderStatus.Text))
                                            {
                                                l += "Статус заказа: " + logData[6] + " -> " + comboBoxOrderStatus.Text + "\n";
                                            }
                                            if (!logData[7].Equals(comboBoxExecutor.Text))
                                            {
                                                l += "Исполнитель: " + logData[7] + " -> " + comboBoxExecutor.Text + "\n";
                                            }
                                            if (!logData[8].Equals(comboBoxExecutor.Text))
                                            {
                                                l += "Принявший заказ: " + logData[8] + " -> " + comboBoxAcceptor.Text + "\n";
                                            }
                                            if (!logData[9].Equals(textBoxDate.Text))
                                            {
                                                l += "Дата дедлайна:" + logData[9] + " -> " + textBoxDate.Text + "\n";
                                            }
                                            if (!logData[10].Equals(textBoxDate.Text))
                                            {
                                                l += "Точка выдачи:" + logData[10] + " -> " + comboBoxPointOfGrub.Text + "\n";
                                            }
                                            if (l.Length > 0)
                                            {
                                                log += " " + DateTime.Now.ToString("yyyy-MM-dd") + " изменили заявку No_" + order_id + ": \n";
                                                log += l;
                                                using (var mySqlConnection = new DBUtils().getDBConnection())
                                                {
                                                    using (var cmd = new MySqlCommand())
                                                    {
                                                        cmd.Connection  = mySqlConnection;
                                                        cmd.CommandType = System.Data.CommandType.StoredProcedure;
                                                        cmd.CommandText = "addLog";
                                                        cmd.Parameters.Clear();
                                                        MySqlParameter p1 = cmd.Parameters.Add("@log", MySqlDbType.VarChar);
                                                        p1.Direction = ParameterDirection.Input;

                                                        p1.Value = log;

                                                        mySqlConnection.Open();
                                                        cmd.ExecuteNonQuery();
                                                    }
                                                }
                                            }
                                        }

                                        using (var mySqlConnection = new DBUtils().getDBConnection())
                                        {
                                            using (var cmd = new MySqlCommand())
                                            {
                                                cmd.Connection  = mySqlConnection;
                                                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                                                cmd.CommandText = comText;
                                                cmd.Parameters.Clear();
                                                MySqlParameter p1 = cmd.Parameters.Add("@customer", MySqlDbType.VarChar);
                                                p1.Direction = ParameterDirection.Input;
                                                MySqlParameter p2 = cmd.Parameters.Add("@order_info", MySqlDbType.VarChar);
                                                p2.Direction = ParameterDirection.Input;
                                                MySqlParameter p3 = cmd.Parameters.Add("@order_status", MySqlDbType.VarChar);
                                                p3.Direction = ParameterDirection.Input;
                                                MySqlParameter p4 = cmd.Parameters.Add("@order_type", MySqlDbType.VarChar);
                                                p4.Direction = ParameterDirection.Input;
                                                MySqlParameter p5 = cmd.Parameters.Add("@executor", MySqlDbType.VarChar);
                                                p5.Direction = ParameterDirection.Input;
                                                MySqlParameter p6 = cmd.Parameters.Add("@acceptor", MySqlDbType.VarChar);
                                                p6.Direction = ParameterDirection.Input;
                                                MySqlParameter p7 = cmd.Parameters.Add("@cost", MySqlDbType.VarChar);
                                                p7.Direction = ParameterDirection.Input;
                                                MySqlParameter p8 = cmd.Parameters.Add("@fact_cost", MySqlDbType.VarChar);
                                                p8.Direction = ParameterDirection.Input;
                                                MySqlParameter p9 = cmd.Parameters.Add("@communication", MySqlDbType.VarChar);
                                                p9.Direction = ParameterDirection.Input;
                                                MySqlParameter p10 = cmd.Parameters.Add("@subCommunication", MySqlDbType.VarChar);
                                                p10.Direction = ParameterDirection.Input;
                                                MySqlParameter p11 = cmd.Parameters.Add("@orderId", MySqlDbType.Int32);
                                                p11.Direction = ParameterDirection.Input;
                                                MySqlParameter p12 = cmd.Parameters.Add("@deadline", MySqlDbType.VarChar);
                                                p12.Direction = ParameterDirection.Input;
                                                MySqlParameter p13 = cmd.Parameters.Add("@point", MySqlDbType.VarChar);
                                                p13.Direction = ParameterDirection.Input;
                                                MySqlParameter p14 = cmd.Parameters.Add("@cust_notif", MySqlDbType.Int16);
                                                p14.Direction = ParameterDirection.Input;

                                                p1.Value  = custName.TrimStart();
                                                p2.Value  = richTextBoxOrderInfo.Text.TrimStart();
                                                p3.Value  = comboBoxOrderStatus.SelectedItem.ToString();
                                                p4.Value  = comboBoxOrderType.SelectedItem.ToString();
                                                p5.Value  = comboBoxExecutor.SelectedItem.ToString();
                                                p6.Value  = comboBoxAcceptor.SelectedItem.ToString();
                                                p7.Value  = textBoxCost.Text.ToString();
                                                p8.Value  = textBoxFactCost.Text.ToString();
                                                p9.Value  = textBoxPriorComm.Text.TrimStart();
                                                p10.Value = textBoxSubComm.Text.TrimStart();
                                                p11.Value = order_id;
                                                p12.Value = textBoxDate.Text;
                                                p13.Value = comboBoxPointOfGrub.Text;
                                                p14.Value = checkBoxCustNotif.Checked ? 1 : 0;
                                                mySqlConnection.Open();
                                                cmd.ExecuteNonQuery();
                                            }
                                        }
                                        if (openFileDialog1.FileName != "")
                                        {
                                            uploadFiles("" + order_id, openFileDialog1.FileNames);
                                        }
                                        string json = "";
                                        if (ord_type == 0)
                                        {
                                            json = @"{" +
                                                   "\"ordertype\":\"new\"," +
                                                   "\"order_id\":\"" + order_id + "\"," +
                                                   "\"deadline\":\"" + textBoxDate.Text + "\"," +
                                                   "\"cust_name\":\"" + custName.TrimStart() + "\"," +
                                                   "\"cust_phone\":\"" + textBoxPriorComm.Text.TrimStart() + "\"" + "}";
                                        }
                                        else
                                        {
                                            if (comboBoxOrderStatus.Text == "Ожидание внешнего подрядчика")
                                            {
                                                json = @"{" +
                                                       "\"ordertype\":\"ext\"," +
                                                       "\"order_id\":\"" + order_id + "\"," +
                                                       "\"deadline\":\"" + textBoxDate.Text + "\"," +
                                                       "\"cust_name\":\"" + custName.TrimStart() + "\"," +
                                                       "\"cust_phone\":\"" + textBoxPriorComm.Text.TrimStart() + "\"" + "}";
                                            }
                                        }
                                        try
                                        {
                                            ClientLaunchAsync(json);
                                        }
                                        catch { MessageBox.Show("Оповещение о создании/изменении заявки не отправлено, обратитесь к руководителю либо напишите разработчику из меню сообщения об ошибке"); }
                                        MessageBox.Show("Заявка номер " + order_id + " составлена");
                                        this.Close();
                                    }
                                    else
                                    {
                                        MessageBox.Show("Введите фактически оплаченную сумму");
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Введите стоимость услуги");
                                }
                            }
                            else
                            {
                                MessageBox.Show("Информация о заявке должна быть длиннее десяти символов");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Почта заказчика - обязательное поле для ввода");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Номер телефона заказчика - обязательное поле для ввода");
                    }
                }
                else
                {
                    MessageBox.Show("Введите Ф.И.О заказчика");
                }
            }
            else
            {
                MessageBox.Show("Выберите статус, тип и сотрудника принявшего заявку");
            }
            loading.Dispose();
        }