Exemplo n.º 1
0
 private void OutButton_Click(object sender, EventArgs e)
 {
     Thread.Sleep(1000);
     if (WarehouseDGV.SelectedRows.Count != 0)
     {
         if (Int32.TryParse(WarehouseDGV.Rows[WarehouseDGV.SelectedRows[0].Index].Cells[0].Value.ToString(), out int id))
         {
             if (WarehouseDGV.Rows[WarehouseDGV.SelectedRows[0].Index].Cells[8].Value != null &&
                 WarehouseDGV.Rows[WarehouseDGV.SelectedRows[0].Index].Cells[9].Value == null &&
                 WarehouseDGV.Rows[WarehouseDGV.SelectedRows[0].Index].Cells[7].Value.ToString() == Status.EntryAllowed)
             {
                 using (CheckPoint db = new CheckPoint())
                 {
                     var rq = db.Request.Where(x => x.FID == id).FirstOrDefault();
                     if (rq != null)
                     {
                         rq.FWHDATEEND = DateTime.Now;
                         rq.FSTATUS    = Status.ShipmentCompleted;
                     }
                     var io = db.InOut.Where(x => x.FID == id)
                              .Where(x => x.FFACTDATEEND == null)
                              .FirstOrDefault();
                     if (io != null)
                     {
                         io.FWHDATEEND = DateTime.Now;
                     }
                     db.SaveChanges();
                 }
                 FillWarehouse();
             }
         }
     }
 }
Exemplo n.º 2
0
        private void FillWarehouse()
        {
            int selectedRow = 0;

            if (WarehouseDGV.SelectedRows.Count > 0)
            {
                selectedRow = WarehouseDGV.SelectedRows[0].Index;
            }
            int displayedRow = 0;

            if (WarehouseDGV.Rows.Count > 0 && WarehouseDGV.FirstDisplayedCell != null)
            {
                displayedRow = WarehouseDGV.FirstDisplayedCell.RowIndex;
            }
            DateTime datebegin = WarehouseDTP.Value.Date.AddDays(1);
            DateTime dateend   = WarehouseDTP.Value.Date;

            using (CheckPoint db = new CheckPoint())
            {
                var rq = db.Request.Where(x => x.FDATEBEGIN.CompareTo(datebegin) <= 0 && x.FDATEEND.CompareTo(dateend) >= 0)
                         .Where(x => x.FSTATUS != Status.Initial && x.FSTATUS != Status.Changed && x.FSTATUS != Status.Approved && x.FSTATUS != Status.ActiveOutput)
                         .Where(x => x.FGUESTFIO.ToUpper().Contains(FilterFIOTB.Text.ToUpper()) || FilterFIOTB.Text == "")
                         .Where(x => x.FAUTONUMBER.ToUpper().Contains(FilterAutoTB.Text.ToUpper()) || FilterAutoTB.Text == "")
                         .Select(x => new Warehouse_View
                {
                    FID          = x.FID,
                    FGUESTFIO    = x.FGUESTFIO,
                    FAUTOMARK    = x.FAUTOMARK,
                    FAUTONUMBER  = x.FAUTONUMBER,
                    FLOCATION    = x.FLOCATION,
                    FDATEBEGIN   = x.FDATEBEGIN,
                    FDATEEND     = x.FDATEEND,
                    FSTATUS      = x.FSTATUS,
                    FWHDATEBEGIN = x.FWHDATEBEGIN,
                    FWHDATEEND   = x.FWHDATEEND,
                    FMEETFIO     = x.FMEETFIO,
                    FGUESTJOB    = x.FGUESTJOB,
                    FWHCOMMENT   = x.FWHCOMMENT,
                    FDESCR       = x.FDESCR,
                    FPURPOSE     = x.FPURPOSE,
                    FUTVDATE     = x.FUTVDATE,
                    FPHONE       = x.FPHONE,
                    FWHPERSON    = x.FWHPERSON
                });
                WarehouseDGV.DataSource = new CustomBindingList <Warehouse_View>(rq.ToList());
            }
            WarehouseDGV.Select();
            SumLabel.Text = "ИТОГО: " + WarehouseDGV.Rows.Count.ToString() + " шт.";
            if (selectedRow != 0 && selectedRow < WarehouseDGV.Rows.Count)
            {
                WarehouseDGV.Rows[selectedRow].Selected = true;
            }
            if (displayedRow != 0 && displayedRow < WarehouseDGV.Rows.Count)
            {
                WarehouseDGV.FirstDisplayedScrollingRowIndex = displayedRow;
            }
        }
Exemplo n.º 3
0
        private void FillRequestDGV()
        {
            int selectedRow = 0;

            if (RequestDGV.SelectedRows.Count > 0)
            {
                selectedRow = RequestDGV.SelectedRows[0].Index;
            }
            int displayedRow = 0;

            if (RequestDGV.Rows.Count > 0 && RequestDGV.FirstDisplayedCell != null)
            {
                displayedRow = RequestDGV.FirstDisplayedCell.RowIndex;
            }
            if (Rights.p_staff)
            {
                SelfChB.Visible = true;
            }
            using (CheckPoint db = new CheckPoint())
            {
                var rq = db.Request.Where(x => x.FCREATEDATE.Year == RequestDTP.Value.Year && x.FCREATEDATE.Month == RequestDTP.Value.Month)
                         .Where(x => x.FDESCR == SystemInformation.UserName || (SelfChB.Visible && !SelfChB.Checked))
                         .Select(x => new Request_View
                {
                    FID         = x.FID,
                    FDESCR      = x.FDESCR,
                    FCREATEDATE = x.FCREATEDATE,
                    FGUESTFIO   = x.FGUESTFIO,
                    FGUESTJOB   = x.FGUESTJOB,
                    FAUTOMARK   = x.FAUTOMARK,
                    FAUTONUMBER = x.FAUTONUMBER,
                    FLOCATION   = x.FLOCATION,
                    FDATEBEGIN  = x.FDATEBEGIN,
                    FDATEEND    = x.FDATEEND,
                    FMEETFIO    = x.FMEETFIO,
                    FSTATUS     = x.FSTATUS,
                    FPURPOSE    = x.FPURPOSE,
                    FUTVDATE    = x.FUTVDATE,
                    FPHONE      = x.FPHONE
                });
                RequestDGV.DataSource = new CustomBindingList <Request_View>(rq.ToList());
            }
            RequestDGV.Select();
            if (selectedRow != 0 && selectedRow < RequestDGV.Rows.Count)
            {
                RequestDGV.Rows[selectedRow].Selected = true;
            }
            if (displayedRow != 0 && displayedRow < RequestDGV.Rows.Count)
            {
                RequestDGV.FirstDisplayedScrollingRowIndex = displayedRow;
            }
        }
Exemplo n.º 4
0
 private void FormJournal_Load(object sender, System.EventArgs e)
 {
     using (CheckPoint db = new CheckPoint())
     {
         var io = db.InOut.Where(x => x.FID == request_id)
                  .OrderBy(x => x.FFACTDATEBEGIN)
                  .Select(x => new
         {
             x.FFACTDATEBEGIN,
             x.FWHDATEBEGIN,
             x.FWHDATEEND,
             x.FFACTDATEEND
         });
         JournalDGV.DataSource = io.ToList();
     }
 }
Exemplo n.º 5
0
        private void CheckTimer_Tick(object sender, EventArgs e)
        {
            DateTime datebegin = CheckDTP.Value.Date.AddDays(1);
            DateTime dateend   = CheckDTP.Value.Date;
            int      realcount = 0;

            using (CheckPoint db = new CheckPoint())
            {
                realcount = db.Request.Where(x => x.FDATEBEGIN.CompareTo(datebegin) <= 0 && x.FDATEEND.CompareTo(dateend) >= 0)
                            .Where(x => x.FSTATUS != Status.Initial && x.FSTATUS != Status.Changed)
                            .Where(x => x.FGUESTFIO.ToUpper().Contains(FilterFIOTB.Text.ToUpper()) || FilterFIOTB.Text == "")
                            .Where(x => x.FAUTONUMBER.ToUpper().Contains(FilterAutoTB.Text.ToUpper()) || FilterAutoTB.Text == "")
                            .Count();
            }
            int viewcount = CheckDGV.Rows.Count;

            if (realcount > viewcount)
            {
                RefreshButton.Text      = "Обновить\n(новых: " + (realcount - viewcount).ToString() + ")";
                RefreshButton.ForeColor = Color.Red;
            }
        }
Exemplo n.º 6
0
 private void InButton_Click(object sender, EventArgs e)
 {
     Thread.Sleep(1000);
     if (WarehouseDGV.SelectedRows.Count != 0)
     {
         if (Int32.TryParse(WarehouseDGV.Rows[WarehouseDGV.SelectedRows[0].Index].Cells[0].Value.ToString(), out int id))
         {
             if (WarehouseDGV.Rows[WarehouseDGV.SelectedRows[0].Index].Cells[12].Value == null)
             {
                 MessageBox.Show("Нет комментария склада!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
             if (WarehouseDGV.Rows[WarehouseDGV.SelectedRows[0].Index].Cells[8].Value == null &&
                 WarehouseDGV.Rows[WarehouseDGV.SelectedRows[0].Index].Cells[7].Value.ToString() == Status.ActiveInput)
             {
                 using (CheckPoint db = new CheckPoint())
                 {
                     var rq = db.Request.Where(x => x.FID == id).FirstOrDefault();
                     if (rq != null)
                     {
                         rq.FWHDATEBEGIN = DateTime.Now;
                         rq.FWHDATEEND   = null;
                         rq.FSTATUS      = Status.EntryAllowed;
                     }
                     var io = db.InOut.Where(x => x.FID == id)
                              .Where(x => x.FFACTDATEEND == null)
                              .FirstOrDefault();
                     if (io != null)
                     {
                         io.FWHDATEBEGIN = DateTime.Now;;
                         io.FWHDATEEND   = null;
                     }
                     db.SaveChanges();
                 }
                 FillWarehouse();
             }
         }
     }
 }
Exemplo n.º 7
0
 private void EndButton_Click(object sender, EventArgs e)
 {
     if (CheckDGV.SelectedRows.Count != 0)
     {
         if (Int32.TryParse(CheckDGV.Rows[CheckDGV.SelectedRows[0].Index].Cells[0].Value.ToString(), out int id))
         {
             if (MessageBox.Show("Вы действительно хотите завершить заявку № " + id.ToString() + "?",
                                 "Завершение",
                                 MessageBoxButtons.OKCancel,
                                 MessageBoxIcon.Information) == DialogResult.OK)
             {
                 using (CheckPoint db = new CheckPoint())
                 {
                     var rq = db.Request.Where(x => x.FID == id).FirstOrDefault();
                     if (rq != null)
                     {
                         rq.FSTATUS = Status.Completed;
                     }
                 }
                 FillCheck();
             }
         }
     }
 }
Exemplo n.º 8
0
        private void CreateButton_Click(object sender, EventArgs e)
        {
            if (GuestFIOTB.Text == "" || GuestJobTB.Text == "" || LocationTB.Text == "" || PurposeTB.Text == "" || MeetFIOTB.Text == "" || PhoneTB.Text == "")
            {
                MessageBox.Show("Заполнены не все поля!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            DateTime beginDT = BeginDateDTP.Value.Date.Add(BeginTimeDTP.Value.TimeOfDay);
            DateTime endDT   = EndDateDTP.Value.Date.Add(EndTimeDTP.Value.TimeOfDay);
            DateTime outDT   = OutDateDTP.Value.Date.Add(OutTimeDTP.Value.TimeOfDay);

            if (beginDT.CompareTo(endDT) >= 0)
            {
                MessageBox.Show("Время окончания должно быть больше времени начала!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            using (CheckPoint db = new CheckPoint())
            {
                if (CreateButton.Text == "Создать")
                {
                    if (beginDT.CompareTo(DateTime.Now) < 0)
                    {
                        MessageBox.Show("Время начала должны быть больше текущего!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    Request rq = new Request
                    {
                        FCREATEDATE = DateTime.Now,
                        FDESCR      = SystemInformation.UserName,
                        FGUESTFIO   = GuestFIOTB.Text,
                        FGUESTJOB   = GuestJobTB.Text,
                        FAUTOMARK   = AutoMarkTB.Text,
                        FAUTONUMBER = AutoNumberTB.Text,
                        FLOCATION   = LocationTB.Text,
                        FPURPOSE    = PurposeTB.Text,
                        FDATEBEGIN  = beginDT,
                        FDATEEND    = endDT,
                        FMEETFIO    = MeetFIOTB.Text,
                        FPHONE      = PhoneTB.Text,
                        FSTATUS     = Status.Initial
                    };
                    db.Request.Add(rq);
                }
                if (CreateButton.Text == "Изменить")
                {
                    if (beginDT.CompareTo(DateTime.Now) < 0)
                    {
                        MessageBox.Show("Время начала должны быть больше текущего!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    var rq = db.Request.Where(x => x.FID == request_id).FirstOrDefault();
                    if (rq != null)
                    {
                        rq.FGUESTFIO   = GuestFIOTB.Text;
                        rq.FGUESTJOB   = GuestJobTB.Text;
                        rq.FAUTOMARK   = AutoMarkTB.Text;
                        rq.FAUTONUMBER = AutoNumberTB.Text;
                        rq.FLOCATION   = LocationTB.Text;
                        rq.FPURPOSE    = PurposeTB.Text;
                        rq.FDATEBEGIN  = beginDT;
                        rq.FDATEEND    = endDT;
                        rq.FMEETFIO    = MeetFIOTB.Text;
                        rq.FPHONE      = PhoneTB.Text;
                        rq.FSTATUS     = Status.Changed;
                    }
                }
                if (CreateButton.Text == "Правка")
                {
                    if (outDT.CompareTo(DateTime.Now) > 0)
                    {
                        MessageBox.Show("Время выхода должно быть меньше текущего!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    var rq = db.Request.Where(x => x.FID == request_id).FirstOrDefault();
                    if (rq != null)
                    {
                        rq.FGUESTFIO   = GuestFIOTB.Text;
                        rq.FGUESTJOB   = GuestJobTB.Text;
                        rq.FAUTOMARK   = AutoMarkTB.Text;
                        rq.FAUTONUMBER = AutoNumberTB.Text;
                        rq.FLOCATION   = LocationTB.Text;
                        if (PurposeTB.Text.IndexOf("изменено") != -1)
                        {
                            rq.FPURPOSE = PurposeTB.Text.Substring(0, PurposeTB.Text.IndexOf("изменено")).Trim();
                        }
                        else
                        {
                            rq.FPURPOSE = PurposeTB.Text;
                        }
                        rq.FPURPOSE  += Environment.NewLine + "изменено " + SystemInformation.UserName + " " + DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss");
                        rq.FDATEBEGIN = beginDT;
                        rq.FDATEEND   = endDT;
                        rq.FMEETFIO   = MeetFIOTB.Text;
                        rq.FPHONE     = PhoneTB.Text;
                        if (rq.FFACTDATEEND != null)
                        {
                            rq.FFACTDATEEND = outDT;
                        }
                    }
                    var io = db.InOut.Where(x => x.FID == request_id)
                             .OrderByDescending(x => x.FFACTDATEEND)
                             .FirstOrDefault();
                    if (io != null && rq.FFACTDATEEND != null)
                    {
                        io.FFACTDATEEND = outDT;
                    }
                }
                if (CreateButton.Text == "Редактирование")
                {
                    var rq = db.Request.Where(x => x.FID == request_id).FirstOrDefault();
                    if (rq != null)
                    {
                        rq.FWHCOMMENT = WHTB.Text;
                        rq.FWHPERSON  = SystemInformation.UserName;
                    }
                }
                try
                {
                    db.SaveChanges();
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ошибка обращения к данным!\n" + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }