Exemple #1
0
        private void P1ClientTbl_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView table = sender as DataGridView;

            if (table == null)
            {
                MessageBox.Show("Critical error.", "Error");
                return;
            }

            List <Waybill> waybills = WayBillRepository.GetAllEntities();
            int            clientID = (int)table.Rows[e.RowIndex > 0 ? e.RowIndex : 0].Cells["ID"].Value;

            this.UpdateP1WaybillTbl(waybills.Where(wb => wb.ClientID == clientID).ToList());

            List <AccumulationRegister> accumulations = AccumRegisterRepository.GetAllEntities().Where(a => a.ClientID == clientID).ToList();

            AccumulationRegister lastRecord = accumulations.Where(a => a.DateTime == accumulations.Max(ac => ac.DateTime)).FirstOrDefault();

            if (lastRecord == null)
            {
                P1TotalWbTxt.Text     = "waybills not found.";
                P1TotalRoamWbTxt.Text = "waybills not found.";
                return;
            }

            P1TotalWbTxt.Text     = lastRecord.TotalAmount.ToString();
            P1TotalRoamWbTxt.Text = lastRecord.RoamingAmount.ToString();
        }