Пример #1
0
        private void OnDeleteGiaVonDichVu()
        {
            List <string>  deletedGiaVonList = new List <string>();
            List <DataRow> deletedRows       = new List <DataRow>();
            DataTable      dt = dgGiaVonDichVu.DataSource as DataTable;

            foreach (DataRow row in dt.Rows)
            {
                if (Boolean.Parse(row["Checked"].ToString()))
                {
                    string giaThuocGUID = row["GiaVonDichVuGUID"].ToString();
                    deletedGiaVonList.Add(giaThuocGUID);
                    deletedRows.Add(row);
                }
            }

            if (deletedGiaVonList.Count > 0)
            {
                if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những giá vốn dịch vụ mà bạn đã đánh dấu ?") == DialogResult.Yes)
                {
                    Result result = GiaVonDichVuBus.DeleteGiaVonDichVu(deletedGiaVonList);
                    if (result.IsOK)
                    {
                        foreach (DataRow row in deletedRows)
                        {
                            dt.Rows.Remove(row);
                        }
                    }
                    else
                    {
                        MsgBox.Show(Application.ProductName, result.GetErrorAsString("GiaVonDichVuBus.DeleteGiaVonDichVu"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("GiaVonDichVuBus.DeleteGiaVonDichVu"));
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những giá vốn dịch vụ cần xóa.", IconType.Information);
            }
        }