Example #1
0
        private void tbl_CtHd_CellValueChanged(object sender, EventArgs e)
        {
            CTHD      ct    = new CTHD();
            DoChoiBus dcBus = new DoChoiBus();

            var row = tbl_CtHd.SelectedRows[0];

            ct.MAHD = (int)row.Cells[0].Value;
            ct.MADC = (int)row.Cells[1].Value;
            ct.SL   = (int)row.Cells[2].Value;

            ct.GIA             = dcBus.DochoiById(ct.MADC).GIA *ct.SL;
            row.Cells[3].Value = ct.GIA;

            var li = changedItem.Where(i => (i.MAHD == ct.MAHD && i.MADC == ct.MADC));

            if (li.Count() > 0)
            {
                li.First().GIA = ct.GIA;
                li.First().SL  = ct.SL;
            }
            else
            {
                changedItem.Add(ct);
            }

            data_change = true;
        }
Example #2
0
        private void bt_Nhap_Click(object sender, EventArgs e)
        {
            try
            {
                DoChoiBus dcBus = new DoChoiBus();

                DOCHOI dc = new DOCHOI();

                dc = dcBus.DochoiById(int.Parse(cb_masp.Text));

                dc.SL  = int.Parse(tb_slSP.Text);
                dc.GIA = ((double)dc.GIA * (double)dc.SL);

                bool c = true;
                foreach (DOCHOI i in listDC)
                {
                    if (dc.MADC == i.MADC)
                    {
                        i.SL  += dc.SL;
                        i.GIA += dc.GIA;
                        c      = false;
                        break;
                    }
                }

                if (c)
                {
                    listDC.Add(dc);
                }

                so_sp     += (int)dc.SL;
                tien_tong += ((double)dc.GIA);

                setDefaultValue();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }