Ejemplo n.º 1
0
        private void RegButtonClick(object sender, EventArgs e)
        {
            try
            {
                var btn = (UIButton)sender;
                if (btn.ImageIndex == 0)
                {
                    if (LoadType != "ForResultDetail")
                    {
                        var objTRL = new TRegList();
                        objTRL.Barcode    = Utility.sDbnull(grdTestInfo.GetValue("Barcode"));
                        objTRL.TestDataId = Utility.sDbnull(btn.Tag);
                        objTRL.TestId     = Utility.Int32Dbnull(grdTestInfo.GetValue("Test_ID"), -1);
                        objTRL.PatientId  = Utility.DecimaltoDbnull(grdTestInfo.GetValue("Patient_id"));
                        objTRL.ParaName   = btn.Text;
                        objTRL.AliasName  = btn.Tag.ToString();
                        objTRL.Status     = 0;
                        objTRL.IsNew      = true;
                        objTRL.Save();

                        grdTestInfo.CurrentRow.Cells["RegCount"].Value =
                            Utility.Int32Dbnull(grdTestInfo.CurrentRow.Cells["RegCount"].Value, 0) + 1;
                        grdTestInfo.UpdateData();
                    }
                    else
                    {
                        ProcessData.AddRowTableDetail(ref dtResultDetail, Utility.sDbnull(btn.Tag), patientId, currentTest_ID);
                    }
                    btn.ImageIndex = 1;
                    ////////Todo: xử lý theo từng thiết bị

                    ////////Nạp các thiết bị có test Data ID này:
                    //////var dtDevices =
                    //////    new Select(DDeviceList.Columns.DeviceId, DDeviceList.Columns.DeviceName).From(
                    //////        DDataControl.Schema.Name).LeftOuterJoin(DDeviceList.DeviceIdColumn,
                    //////                                                DDataControl.DeviceIdColumn).Where(
                    //////                                                    DDataControl.Columns.TestDataId).IsEqualTo(
                    //////                                                        obj.Tag).ExecuteDataSet().Tables[0];
                    //////// Nạp danh sách vừa lấy được lên combobox
                    //////var dr = dtDevices.NewRow();
                    //////dr[DDeviceList.Columns.DeviceId] = -1;
                    //////dr[DDeviceList.Columns.DeviceName] = "Tất cả";
                    //////dtDevices.Rows.InsertAt(dr,0);

                    ////////Nạp danh sách lên Combobox
                    //////cboDevices.Items.Clear();
                    //////foreach (DataRow row in dtDevices.Rows)
                    //////{
                    //////    var deviceName = Utility.sDbnull(row[DDeviceList.Columns.DeviceName],"");
                    //////    var deviceId = Utility.Int32Dbnull(row[DDeviceList.Columns.DeviceId]);
                    //////    var item = new CCBoxItem(deviceName,deviceId);
                    //////    cboDevices.Items.Add(item);
                    //////}

                    ////////Utility.ShowMsg("OK");
                }
                else if (btn.ImageIndex == 1)
                {
                    if (LoadType != "ForResultDetail")
                    {
                        new Delete().From(TRegList.Schema.Name).Where(TRegList.Columns.TestId).
                        IsEqualTo(Utility.Int32Dbnull(grdTestInfo.GetValue("Test_ID"), -1)).
                        And(TRegList.Columns.Barcode).IsEqualTo(Utility.sDbnull(grdTestInfo.GetValue("Barcode"))).
                        And(TRegList.Columns.TestDataId).IsEqualTo(btn.Tag.ToString()).Execute();


                        grdTestInfo.CurrentRow.Cells["RegCount"].Value =
                            Utility.Int32Dbnull(grdTestInfo.CurrentRow.Cells["RegCount"].Value, 0) - 1;
                        grdTestInfo.UpdateData();
                    }
                    else
                    {
                        ProcessData.DelRowTableDetail(ref dtResultDetail, Utility.sDbnull(btn.Tag), currentTest_ID);
                    }
                    btn.ImageIndex = 0;
                }
                else if (btn.ImageIndex == 2 & !GroupButtonIsPressed)
                {
                    Utility.ShowMsg("Không được hủy. Tồn tại dữ liệu !");
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }