using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Sfera_CRM
{
public partial class ViewsContractsFRM : Form
{
public ViewsContractsFRM()
{
InitializeComponent();
}
Mapping mp = new Mapping();
private void ViewsContractsFRM_Load(object sender, EventArgs e)
{
// TODO: данная строка кода позволяет загрузить данные в таблицу "crmDB_resDataSet.Contracts". При необходимости она может быть перемещена или удалена.
this.contractsTableAdapter.Fill(this.crmDB_resDataSet.Contracts);
}
private void back_Click(object sender, EventArgs e)
{
update_data();
Config.forms["menuFRM"].Show();
Hide();
}
public void update_data()
{
dataGridView1.DataSource = null;
dataGridView1.DataSource = mp.Show("SELECT * FROM Contracts");
}
private void Close_order_Click(object sender, EventArgs e)
{
string contract_id = dataGridView1.CurrentRow.Cells[0].Value.ToString();
string manager_id = dataGridView1.CurrentRow.Cells[2].Value.ToString();
string close_date = dataGridView1.CurrentRow.Cells[6].Value.ToString();
if (Config.right == "0" && manager_id != Config.user_id)
{
MessageBox.Show("Вы не можете закрывать чужие договора");
}
else if (close_date.Length > 4)
{
MessageBox.Show("Договор уже закрыт");
}
else
{
mp.CRUD("UPDATE Contracts SET Close_date=" + DateTime.Now.ToString("dd-MM-yyyy") + " WHERE Contracts_id = " + contract_id);
MessageBox.Show("Договор №" + contract_id + " успешно закрыт");
update_data();
}
}
private void button1_Click(object sender, EventArgs e)
{
update_data();
}
}
}