示例#1
0
        private void lstDetails_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (((Worker)lstWorkers.SelectedItem).Name == "")
            {
                MessageBox.Show("Операторо не выбран!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            var inp = new frmInputNum();

            if (inp.ShowDialog() != DialogResult.OK)
            {
                return;
            }


            int quant = inp.Value;

            var detail = lstDetails.SelectedItem as Detail;

            var producedDeatil = new ProducedDetail
            {
                Count        = quant,
                Detail       = detail,
                ProducedDate = dtpProducedData.Value,
                Worker       = lstWorkers.SelectedItem as Worker,
            };

            _context.ProducedDetails.Add(producedDeatil);
            _producedDetails.Add(producedDeatil);
            _context.SaveChanges();
            RefreshProdusedList();
        }
示例#2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (grid.SelectedRows.Count == 0)
            {
                MessageBox.Show("Выберите запись!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            var            id  = Guid.Parse(grid.SelectedRows[0].Cells["colId"].Value.ToString());
            ProducedDetail tmp = _context.ProducedDetails.First(x => x.Id == id);

            if ((MessageBox.Show("Удалить запись?", "Предупреждение", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) == DialogResult.OK)
            {
                _context.ProducedDetails.Remove(tmp);
                _context.SaveChanges();
                DownloadAllProducedDetails(dtpStartPeriod.Value, dtpEndPeriod.Value);
                if (txtSearch.Text.Length == 0 && cmbWorker.SelectedIndex == 0)
                {
                    RefreshGrid(dtpStartPeriod.Value, dtpEndPeriod.Value);
                }
                else if (txtSearch.Text.Length != 0)
                {
                    RefreshGrid(dtpStartPeriod.Value, dtpEndPeriod.Value);
                    btnSearch_Click(sender, e);
                }
                else if (cmbWorker.SelectedIndex != 0)
                {
                    RefreshGrid(dtpStartPeriod.Value, dtpEndPeriod.Value);
                    cmbWorker_SelectedIndexChanged(sender, e);
                }
            }
        }