Example #1
0
        public FormSCL()
        {
            InitializeComponent();
            context   = new SclContext();
            dateLabel = new ToolStripLabel();
            timeLabel = new ToolStripLabel();
            statusStrip1.Items.Add(dateLabel);
            statusStrip1.Items.Add(timeLabel);
            InitializeCategories();
            InitializeRegions();
            comboBoxRegion.SelectedIndex      = -1;
            comboBoxCategory.SelectedIndex    = -1;
            comboBoxOrgCategory.SelectedIndex = -1;
            comboBoxOrgRegion.SelectedIndex   = -1;


            dataGridViewCustomers.AutoGenerateColumns = false;
            //ToolStripMenuItem
            contextMenuStripDataGridView.Items.AddRange(new[] { SaveToDocument, ChangeStatusCustomer });
            dataGridViewCustomers.ContextMenuStrip = contextMenuStripDataGridView;
            SaveToDocument.Click       += SaveToDocument_Click;
            ChangeStatusCustomer.Click += ChangeStatusCustomer_Click;


            //Get 1 sec Timer for a clock
            timer = new Timer()
            {
                Interval = 1000
            };
            timer.Tick += timer_Tick;
            timer.Start();
        }
Example #2
0
        private void ChangeStatusCustomer_Click(object sender, EventArgs e)
        {
            string custId = dataGridViewCustomers.CurrentRow.Cells[0].Value.ToString();
            int    cuID   = System.Convert.ToInt32(custId);

            using (SclContext context = new SclContext())
            {
                Customer cust = context.Customers.FirstOrDefault(p => p.CustomerId.Equals(cuID));
                if (cust.UserStatus.Equals("Не діє"))
                {
                    cust.UserStatus = "Діє";
                }
                else if (cust.UserStatus.Equals("Діє"))
                {
                    cust.UserStatus = "Не діє";
                }
                else
                {
                    MessageBox.Show("Статус користувача має не допустиме значення");
                }



                context.SaveChanges();
            }
        }
Example #3
0
        private void buttonFormFindOrgRC_Click(object sender, EventArgs e)
        {
            using (SclContext db = new SclContext())
            {
                var org = db.Organizations.Where(p => p.OrgName.Contains(textBoxNameOrganizationFormFindOrgRC.Text));

                dataGridViewFindOrgRc.DataSource = org.ToList();
            }
        }
Example #4
0
        private void SaveToDocument_Click(object sender, EventArgs e)
        {
            string custId = dataGridViewCustomers.CurrentRow.Cells[0].Value.ToString();
            int    cuID   = System.Convert.ToInt32(custId);

            using (SclContext db = new SclContext())
            {
                var getCust = db.Customers.Where(cust => cust.CustomerId.Equals(cuID)).ToList();
                // MessageBox.Show(getCust[0].Phone.ToString());
                MessageBox.Show("Приложение требует ексель");

                var excelApp = new Excel.Application();
                excelApp.Workbooks.Add();
                Excel._Worksheet workSheet = (Excel.Worksheet)excelApp.ActiveSheet;
                excelApp.Visible = true;

                workSheet.Cells[1, "A"] = "Назва організації";
                workSheet.Cells[1, "B"] = "ПІБ";
                workSheet.Cells[1, "C"] = "Посада";
                workSheet.Cells[1, "D"] = "Логін";
                workSheet.Cells[1, "E"] = "Пароль";

                var OrgName = context.Organizations.Where(p => p.OrgShortName.Equals(dataGridViewCustomers.CurrentRow.Cells[6].Value));

                //workSheet.Cells[2, "A"] = OrgName.ToString();//.Value.ToString();
                workSheet.Cells[2, "B"] = "" + dataGridViewCustomers.CurrentRow.Cells[1].Value.ToString() + " "
                                          + dataGridViewCustomers.CurrentRow.Cells[2].Value.ToString() + " "
                                          + dataGridViewCustomers.CurrentRow.Cells[3].Value.ToString();
                workSheet.Cells[2, "C"] = dataGridViewCustomers.CurrentRow.Cells[7].Value.ToString();
                workSheet.Cells[2, "D"] = dataGridViewCustomers.CurrentRow.Cells[10].Value.ToString();

                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter           = "Excel files 2003(*.xls)|*.xls|Excel files 2007(*.xlsx)|*.xlsx| All files(*.*)|*.*";
                saveFileDialog.DefaultExt       = ".xlsx";
                saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                saveFileDialog.Title            = "Введіть назву та виберіть шлях для збереження файлу";
                saveFileDialog.OverwritePrompt  = true;


                try
                {
                    if (saveFileDialog.ShowDialog() == DialogResult.Cancel)
                    {
                        return;
                    }
                    excelApp.ActiveWorkbook.SaveCopyAs(saveFileDialog.FileName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Виникла помилка:" + ex.ToString());
                }

                excelApp.ActiveWorkbook.Close(false);
                excelApp.Quit();
            }
        }
Example #5
0
 public FormAddOrganization(SclContext context)
 {
     this.context = context;
     InitializeComponent();
     comboBoxNewOrgStatus.SelectedIndex   = 0;
     comboBoxNewOrgRegion.SelectedIndex   = -1;
     comboBoxNewOrgCategory.SelectedIndex = -1;
     InitializeCategories();
     InitializeRegions();
 }
 public FormChangeOrganization(SclContext context, Organization organization = null)
 {
     this.context = context;
     InitializeComponent();
     InitializeCategories();
     InitializeRegions();
     //comboBoxNewOrgStatus.SelectedIndex = 0;
     //comboBoxNewOrgRegion.SelectedIndex = -1;
     //comboBoxNewOrgCategory.SelectedIndex = -1;
     this.organization = organization ?? new Organization();
     InitializeForm();
 }
Example #7
0
        //private MyOrganization myOrgTakeInfo = new MyOrganization();
        public FormChangeCustomer(SclContext context, Customer customer = null)
        {
            this.context = context;
            InitializeComponent();
            InitializeCategories();
            InitializeRegions();
            InitializeCities();
            groupBoxLoginFormChangeCustomer.Enabled = false;

            this.customer = customer ?? new Customer();
            login         = new Login();

            InitializeForm();
        }
Example #8
0
        //private MyOrganization myOrgTakeInfo = new MyOrganization();
        public FormAddCustomer(SclContext context, Customer customer = null)
        {
            this.context = context;

            InitializeComponent();

            InitializeCategories();
            InitializeRegions();
            InitializeCities();

            //comboBoxNewCategory.SelectedIndex = -1;
            //comboBoxNewCustRegion.SelectedIndex = -1;
            //comboBoxNewCustCode.SelectedIndex = -1;

            this.customer = customer ?? new Customer();
            login         = new Login();
        }