Пример #1
0
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            List <DonGiaDV> _lmaDV = new List <DonGiaDV>();
            int             count  = 0;

            for (int i = 0; i < grvExCell.RowCount; i++)
            {
                if (grvExCell.GetRowCellValue(i, colCheck) != null && Convert.ToBoolean(grvExCell.GetRowCellValue(i, colCheck)) == true)
                {
                    if ((grvExCell.GetRowCellValue(i, gridColumn4) != null) && (grvExCell.GetRowCellValue(i, gridColumn7) != null))
                    {
                        DonGiaDV dg = new DonGiaDV();
                        dg.MaQD   = grvExCell.GetRowCellValue(i, gridColumn4).ToString();
                        dg.DonGia = Convert.ToDouble(grvExCell.GetRowCellValue(i, gridColumn7));
                        var qdv = _ldv.Where(p => p.MaQD == dg.MaQD).ToList();
                        _lmaDV.Add(dg);
                    }
                }
            }
            if (_lmaDV.Count > 0)
            {
                foreach (var dg in _lmaDV)
                {
                    foreach (var item in _ldv)
                    {
                        if (item.MaDV == dg.MaDV)
                        {
                            item.DonGia = dg.DonGia;
                            count++;
                        }
                    }
                }
            }
            grcDichVu.DataSource = _ldv;
            if (count > 0)
            {
                btnLuu.Enabled = true;
            }
            else
            {
                MessageBox.Show("Không tìm thấy dịch vụ tương ứng với các dịch vụ đã chọn");
            }
            ////_data = new Hospital();

            ////for (int i = 0; i < grvExCell.RowCount; i++)
            ////{
            ////    if (grvExCell.GetRowCellValue(i, colCheck) != null && Convert.ToBoolean(grvExCell.GetRowCellValue(i, colCheck)) == true)
            ////    {
            ////        if ((grvExCell.GetRowCellValue(i, colMaDV) != null) && (grvExCell.GetRowCellValue(i, colDonGia) != null))
            ////        {

            ////            int maDV= Convert.ToInt32(grvExCell.GetRowCellValue(i, colMaDV));
            ////            double dongia = Convert.ToDouble(grvExCell.GetRowCellValue(i, colDonGia));
            ////            var qdv = _data.DichVus.Where(p => p.MaDV ==maDV).ToList();
            ////            if (qdv.Count > 0)
            ////                qdv.First().DonGia = dongia;
            ////        }
            ////    }
            ////}
        }
Пример #2
0
        private void btnChonFile_Click(object sender, EventArgs e)
        {
            string         fileName = "";
            OpenFileDialog op       = new OpenFileDialog();

            op.Multiselect = false;
            op.Filter      = "XLS (*.xls)|*.xls|(*.xlsx)|*.xlsx";
            if (op.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                fileName = op.FileName;
            }
            DataTable       data     = OpenFile(fileName);
            List <DonGiaDV> _lDonGia = new List <DonGiaDV>();

            for (int i = 0; i < data.Rows.Count; i++)
            {
                if (i > 1)
                {
                    DonGiaDV dg = new DonGiaDV();
                    // dg.Check = false;
                    dg.MaQD    = data.Rows[i][1].ToString();
                    dg.DonGia  = data.Rows[i][5] == DBNull.Value ?0:  Convert.ToDouble(data.Rows[i][5]);
                    dg.DonGia2 = data.Rows[i][4] == DBNull.Value ? 0 : Convert.ToDouble(data.Rows[i][4]);
                    dg.TenDV   = data.Rows[i][2].ToString();
                    if (dg.DonGia == 0 || dg.DonGia == dg.DonGia2)
                    {
                        dg.Check = false;
                    }
                    else
                    {
                        dg.Check = true;
                    }
                    _lDonGia.Add(dg);
                }
            }
            grcExCell.DataSource = _lDonGia;
            gridColumn7.DisplayFormat.FormatString = "n2";
            gridColumn7.DisplayFormat.FormatType   = DevExpress.Utils.FormatType.Custom;
            gridColumn8.DisplayFormat.FormatString = "n2";
            gridColumn8.DisplayFormat.FormatType   = DevExpress.Utils.FormatType.Custom;
            //data.Columns.Add("Check", typeof(bool));
            //foreach (DataRow row in data.Rows)
            //{
            //    row["Check"] = true;
            //}

            //    grcExCell.DataSource = data;
        }