Example #1
0
        private void ActionManufacturer(action vAction)
        {
            try
            {
                if (grdManufacturer.CurrentRow == null && (vAction == action.Update || vAction == action.Delete))
                {
                    return;
                }

                switch (vAction)
                {
                case action.Normal:
                    dtManufacturer             = new Select().From(LManufacture.Schema.Name).ExecuteDataSet().Tables[0];
                    grdManufacturer.DataSource = dtManufacturer;
                    break;

                case action.Delete:
                    if (
                        DDeviceList.CreateQuery().WHERE(DDeviceList.Columns.ManufactureId,
                                                        Utility.Int32Dbnull(grdManufacturer.GetValue("ID"))).
                        GetRecordCount() > 0)
                    {
                        Utility.ShowMsg("Danh mục đang được sử dụng. Không được xóa");
                        return;
                    }
                    if (Utility.AcceptQuestion("Thực hiện xóa " + grdManufacturer.GetValue("sName"), "Thông báo",
                                               true))
                    {
                        new Delete().From(LManufacture.Schema.Name).Where(LManufacture.Columns.Id).IsEqualTo(
                            Utility.Int32Dbnull(grdManufacturer.GetValue("ID"))).Execute();
                        grdManufacturer.CurrentRow.Delete();
                        grdManufacturer.UpdateData();
                    }
                    break;

                default:
                    var oForm = new frmManufacturerList_AU();
                    if (vAction == action.Update)
                    {
                        oForm.txtID.Text = Utility.sDbnull(grdManufacturer.GetValue("ID"));
                    }
                    oForm.dtList  = dtManufacturer;
                    oForm.grdList = grdManufacturer;
                    oForm.ShowDialog();
                    break;
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
Example #2
0
        private void LoadFormTestTypeAU(action vAction)
        {
            try
            {
                if (grdTestType.CurrentRow == null && (vAction == action.Update || vAction == action.Delete))
                {
                    return;
                }

                switch (vAction)
                {
                case action.Normal:
                    dtTestType =
                        new Select().From(TTestTypeList.Schema.Name).OrderAsc(TTestTypeList.Columns.IntOrder).
                        ExecuteDataSet().Tables[0];
                    grdTestType.DataSource = dtTestType;
                    break;

                case action.Delete:
                    if (
                        DDeviceList.CreateQuery().WHERE(DDeviceList.Columns.TestTypeId,
                                                        Utility.Int32Dbnull(grdTestType.GetValue("TestType_ID"))).
                        GetRecordCount() > 0)
                    {
                        Utility.ShowMsg("Danh mục đang được sử dụng. Không được xóa");
                        return;
                    }
                    if (Utility.AcceptQuestion("Thực hiện xóa " + grdTestType.GetValue("TestType_Name"), "Thông báo", true))
                    {
                        new Delete().From(TTestTypeList.Schema.Name).Where(TTestTypeList.Columns.TestTypeId).
                        IsEqualTo(
                            Utility.Int32Dbnull(grdTestType.GetValue("TestType_ID"))).Execute();
                        grdTestType.CurrentRow.Delete();
                        grdTestType.UpdateData();
                    }
                    break;

                default:
                    var oForm = new frmTestTypeList_AU();
                    oForm.vAction = vAction;
                    oForm.drList  = Utility.GetDataRow(dtTestType, TTestTypeList.Columns.TestTypeId,
                                                       grdTestType.GetValue("TestType_ID"));
                    oForm.dtList = dtTestType;
                    oForm.ShowDialog();
                    break;
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
Example #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                txtID.Text = txtID.Text.ToUpper();
                if (ValidData())
                {
                    switch (vAction)
                    {
                    case action.Insert:
                        var obj = new DDeviceList();
                        obj.DeviceName    = Utility.sDbnull(txtName.Text);
                        obj.TestTypeId    = Utility.Int32Dbnull(cboTestType.SelectedValue);
                        obj.ManufactureId = Utility.ByteDbnull(cboManufacturer.SelectedValue);
                        obj.Description   = Utility.sDbnull(txtDesc.Text);
                        obj.Valid         = ckbValid.Checked;
                        obj.IsNew         = true;
                        obj.Save();

                        drList = dtList.NewRow();
                        drList[DDeviceList.Columns.DeviceId] = DDeviceList.CreateQuery().GetMax(DDeviceList.Columns.DeviceId);
                        ApplyData2Datarow();
                        dtList.Rows.InsertAt(drList, 0);
                        dtList.AcceptChanges();

                        txtID.Text = Utility.sDbnull(drList[DDeviceList.Columns.DeviceId]);
                        vAction    = action.Update;
                        break;

                    case action.Update:
                        new Update(DDeviceList.Schema.Name).Set(DDeviceList.Columns.DeviceName).EqualTo(txtName.Text).
                        Set(DDeviceList.Columns.TestTypeId).EqualTo(Utility.Int32Dbnull(cboTestType.SelectedValue)).
                        Set(DDeviceList.Columns.ManufactureId).EqualTo(Utility.Int32Dbnull(cboManufacturer.SelectedValue)).
                        Set(DDeviceList.Columns.Description).EqualTo(txtDesc.Text).
                        Set(DDeviceList.Columns.Valid).EqualTo(ckbValid.Checked).
                        Where(DDeviceList.Columns.DeviceId).IsEqualTo(Utility.Int32Dbnull(txtID.Text)).
                        Execute();
                        ApplyData2Datarow();
                        drList.AcceptChanges();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
Example #4
0
 public static void UpdateDevice(DDeviceList pItem)
 {
     try
     {
         //Kiểm tra xem nếu tồn tại thì Update
         if (DDeviceList.FetchByID(pItem.DeviceId) != null)
         {
             pItem.IsNew = false;
             pItem.Save();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #5
0
 public static void DeleteDevice(int pId)
 {
     try
     {
         if (DDeviceList.FetchByID(pId) != null)
         {
             new Delete().From(DDeviceList.Schema)
             .Where(DDeviceList.Columns.DeviceId).IsEqualTo(pId)
             .Execute();
             DDataControl.Delete(DDataControl.Columns.DeviceId, pId);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                txtID.Text = txtID.Text.ToUpper();
                if (ValidData())
                    switch (vAction)
                    {
                        case action.Insert:
                            var obj = new DDeviceList();
                            obj.DeviceName = Utility.sDbnull(txtName.Text);
                            obj.TestTypeId = Utility.Int32Dbnull(cboTestType.SelectedValue);
                            obj.ManufactureId = Utility.ByteDbnull(cboManufacturer.SelectedValue);
                            obj.Description = Utility.sDbnull(txtDesc.Text);
                            obj.Valid = ckbValid.Checked;
                            obj.IsNew = true;
                            obj.Save();

                            drList = dtList.NewRow();
                            drList[DDeviceList.Columns.DeviceId] = DDeviceList.CreateQuery().GetMax(DDeviceList.Columns.DeviceId);
                            ApplyData2Datarow();
                            dtList.Rows.InsertAt(drList, 0);
                            dtList.AcceptChanges();

                            txtID.Text = Utility.sDbnull(drList[DDeviceList.Columns.DeviceId]);
                            vAction = action.Update;
                            break;
                        case action.Update:
                            new Update(DDeviceList.Schema.Name).Set(DDeviceList.Columns.DeviceName).EqualTo(txtName.Text).
                                Set(DDeviceList.Columns.TestTypeId).EqualTo(Utility.Int32Dbnull(cboTestType.SelectedValue)).
                                Set(DDeviceList.Columns.ManufactureId).EqualTo(Utility.Int32Dbnull(cboManufacturer.SelectedValue)).
                                Set(DDeviceList.Columns.Description).EqualTo(txtDesc.Text).
                                Set(DDeviceList.Columns.Valid).EqualTo(ckbValid.Checked).
                                Where(DDeviceList.Columns.DeviceId).IsEqualTo(Utility.Int32Dbnull(txtID.Text)).
                                Execute();
                            ApplyData2Datarow();
                            drList.AcceptChanges();
                            break;
                    }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
Example #7
0
 private void PerfromUpdatePortId(bool UpdateOrClear)
 {
     try
     {
         if (grdDevice.CurrentRow == null | grdPort.CurrentRow == null)
         {
             return;
         }
         if (grdDevice.CurrentRow.RowType != RowType.Record | grdPort.CurrentRow.RowType != RowType.Record)
         {
             Utility.ShowMsg("Lựa chọn không đúng !");
             return;
         }
         int portID   = UpdateOrClear ? Utility.Int32Dbnull(grdPort.GetValue("Port_ID")) : -1;
         int deviceID = Utility.Int32Dbnull(grdDevice.GetValue("Device_ID"));
         if (UpdateOrClear)
         {
             if (DDeviceList.CreateQuery().WHERE(DDeviceList.Columns.PortId, portID).GetRecordCount() > 0)
             {
                 Utility.ShowMsg(string.Format("Cổng {0} đã được sử dụng !", portID));
                 return;
             }
         }
         new Update(DDeviceList.Schema).Set(DDeviceList.Columns.PortId).EqualTo(UpdateOrClear ? portID : SqlInt32.Null).
         Where(DDeviceList.Columns.DeviceId).IsEqualTo(deviceID).Execute();
         grdPort.RootTable.FormatConditions[0].Value1 = portID;
         if (UpdateOrClear)
         {
             grdDevice.SetValue("Port_ID", portID);
             grdDevice.SetValue("LocalAlias", Utility.sDbnull(grdPort.GetValue("LocalAlias")));
         }
         else
         {
             grdDevice.SetValue("Port_ID", DBNull.Value);
             grdDevice.SetValue("LocalAlias", DBNull.Value);
         }
         grdDevice.UpdateData();
         dtDevice.AcceptChanges();
     }
     catch (Exception ex)
     {
         Utility.ShowMsg(ex.Message);
     }
 }
Example #8
0
        /// <summary>
        /// hàm thực hiện lấy thông tin loại xét nghiệm
        /// </summary>
        /// <param name="ThietBi_ID"></param>
        /// <returns></returns>
        private string GetTestType_Name(int ThietBi_ID)
        {
            string   MaDV     = "FUNNY";
            SqlQuery sqlQuery = new Select().From(DDeviceList.Schema)
                                .Where(DDeviceList.Columns.DeviceId).IsEqualTo(ThietBi_ID);
            DDeviceList objDeviceList = sqlQuery.ExecuteSingle <DDeviceList>();

            if (objDeviceList != null)
            {
                SqlQuery query =
                    new Select().From(TTestTypeList.Schema).Where(TTestTypeList.Columns.TestTypeId).IsEqualTo(
                        objDeviceList.TestTypeId);
                TTestTypeList testTypeList = query.ExecuteSingle <TTestTypeList>();
                if (testTypeList != null)
                {
                    MaDV = testTypeList.Abbreviation;
                }
            }
            return(MaDV);
        }
Example #9
0
 /// <summary>
 /// Thêm mới thiết bị
 /// </summary>
 /// <param name="pItem"></param>
 public static string InsertDevice(DDeviceList pItem)
 {
     try
     {
         Query queryRs = DDeviceList.CreateQuery();
         using (var sh = new SharedDbConnectionScope())
         {
             using (var scope = new TransactionScope())
             {
                 pItem.IsNew = true;
                 pItem.Save();
                 return(queryRs.GetMax(DDeviceList.Columns.DeviceId).ToString());
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #10
0
        private DDeviceList CreateDeviceList()
        {
            var item = new DDeviceList();

            try
            {
                item = new DDeviceList(Convert.ToInt32(txtDeviceID.Text.Trim()));
            }
            catch (Exception)
            {
                item = new DDeviceList();
            }
            item.DeviceName      = txtDeviceName.Text.Trim();
            item.ComputerName    = txtComputerName.Text.Trim();
            item.ManufactureId   = Convert.ToInt16(cboManufacturer.SelectedValue.ToString());
            item.TestTypeId      = Convert.ToInt16(cboTest.SelectedValue.ToString());
            item.Description     = txtDesc.Text.Trim();
            item.DeviceClass     = cboDeviceClass.Text;
            item.DeviceNameSpace = cboDeviceNameSpace.Text;
            item.ConnectorID     = Utility.ByteDbnull(txtConnectorId.Text.Trim());
            item.Valid           = rdUsed.Checked ? true : false;
            item.Protocol        = rdOne.Checked ? true : false;
            if (rdR232.Checked)
            {
                item.DeviceConnectorType = 1;
            }
            else if (rdTCPIP.Checked)
            {
                item.DeviceConnectorType = 0;
            }
            else
            {
                item.DeviceConnectorType = null;
            }
            return(item);
        }
Example #11
0
        public void Insert(int? DeviceType,int? TestTypeId,string DeviceName,int? PortId,short? ManufactureId,bool? DeviceControl,bool? Valid,string Description,string BarcodeType,short SendType)
        {
            DDeviceList item = new DDeviceList();

            item.DeviceType = DeviceType;

            item.TestTypeId = TestTypeId;

            item.DeviceName = DeviceName;

            item.PortId = PortId;

            item.ManufactureId = ManufactureId;

            item.DeviceControl = DeviceControl;

            item.Valid = Valid;

            item.Description = Description;

            item.BarcodeType = BarcodeType;

            item.SendType = SendType;

            item.Save(UserName);
        }