Exemplo n.º 1
0
        public static string InsertDataControl(DDataControl pitems)
        {
            int   i        = 0;
            Query _QueryRS = DDataControl.CreateQuery();

            try
            {
                //if ((!DDataControl.FetchByParameter(DDataControl.Columns.DataName, Comparison.Equals, pitems.DataName).
                //          Read()) &&
                //    (!DDataControl.FetchByParameter(DDataControl.Columns.AliasName, Comparison.Equals, pitems.AliasName)
                //          .Read()))
                //{
                pitems.IsNew = true;
                pitems.Save(i);
                return(_QueryRS.GetMax(DDataControl.Columns.DataControlId).ToString());
                //}
                //else
                //{
                //    return "-1";
                //}
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        private void cmdDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (grdTestData.CurrentRow != null && grdTestData.CurrentRow.RowType == RowType.Record)
                {
                    //if (DDataControl.CreateQuery().WHERE(DDataControl.Columns.TestDataId, Utility.sDbnull(grdTestData.GetValue("TestData_ID"))).GetRecordCount() > 0 |
                    //   TResultDetail.CreateQuery().WHERE(TResultDetail.Columns.TestDataId, Utility.sDbnull(grdTestData.GetValue("TestData_ID"))).GetRecordCount() > 0)

                    if (DDataControl.CreateQuery().WHERE(DDataControl.Columns.TestDataId, Utility.sDbnull(grdTestData.GetValue("TestData_ID"))).GetRecordCount() > 0
                        )
                    {
                        Utility.ShowMsg(string.Format("{0} đang sử dụng. Không được xóa.", grdTestData.GetValue("TestData_ID")));
                    }
                    else
                    if (
                        Utility.AcceptQuestion(
                            string.Format("Xóa {0} của {1}", grdTestData.GetValue("Data_Name"),
                                          grdTestData.GetValue("TestType_Name")), "Thông báo", true))
                    {
                        new Delete().From(LStandardTest.Schema.Name).Where(LStandardTest.Columns.TestDataId).IsEqualTo(
                            grdTestData.GetValue("TestData_ID")).Execute();
                        grdTestData.CurrentRow.Delete();
                        grdTestData.UpdateData();
                        dtTestDataList.AcceptChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
Exemplo n.º 3
0
        private void ActionDevice(action vAction)
        {
            try
            {
                if (grdDevice.CurrentRow == null && (vAction == action.Update || vAction == action.Delete))
                {
                    return;
                }

                switch (vAction)
                {
                case action.Normal:
                    dtDevice =
                        new Select(DDeviceList.Schema.Name + ".*", TTestTypeList.Columns.TestTypeName,
                                   LManufacture.Columns.SName)
                        .From(DDeviceList.Schema.Name).
                        LeftOuterJoin(TTestTypeList.TestTypeIdColumn, DDeviceList.TestTypeIdColumn).
                        LeftOuterJoin(LManufacture.IdColumn, DDeviceList.ManufactureIdColumn).
                        ExecuteDataSet().Tables[0];
                    grdDevice.DataSource = dtDevice;
                    break;

                case action.Delete:
                    if (
                        DDataControl.CreateQuery().WHERE(DDataControl.Columns.DeviceId, Utility.Int32Dbnull(grdDevice.GetValue("Device_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 " + grdDevice.GetValue("Device_Name"), "Thông báo",
                                               true))
                    {
                        new Delete().From(DDeviceList.Schema.Name).Where(DDeviceList.Columns.DeviceId).IsEqualTo(
                            Utility.Int32Dbnull(grdDevice.GetValue("Device_ID"))).Execute();
                        grdDevice.CurrentRow.Delete();
                        grdDevice.UpdateData();
                    }
                    dtDevice.AcceptChanges();
                    break;

                default:
                    var oForm = new frmDeviceList_AU();
                    oForm.vAction = vAction;
                    oForm.drList  = Utility.GetDataRow(dtDevice, DDeviceList.Columns.DeviceId,
                                                       grdDevice.GetValue("Device_ID"));
                    oForm.dtList = dtDevice;
                    oForm.ShowDialog();
                    break;
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
Exemplo n.º 4
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            try
            {
                txtID.Text = txtID.Text.ToUpper();
                if (ValidData())
                {
                    switch (vAction)
                    {
                    case action.Insert:
                        var obj = new DDataControl();
                        obj.DataName    = "";
                        obj.DeviceId    = Utility.Int32Dbnull(cboDevice.SelectedValue, -1);
                        obj.DataTypeId  = 0;
                        obj.ControlType = true;
                        obj.AliasName   = Utility.sDbnull(txtAlias.Text);
                        obj.Description = Utility.sDbnull(txtDesc.Text);
                        obj.IsNew       = true;
                        obj.Save();

                        drData = dtDataControl.NewRow();
                        drData[DDataControl.Columns.DataControlId] =
                            DDataControl.CreateQuery().WHERE(DDataControl.Columns.DeviceId, Utility.Int32Dbnull(cboDevice.SelectedValue, -1)).
                            WHERE(DDataControl.Columns.AliasName, txtAlias.Text).GetMax(DDataControl.Columns.DataControlId);
                        txtID.Text = drData[DDataControl.Columns.DataControlId].ToString();
                        ApplyData2Datarow();
                        dtDataControl.Rows.InsertAt(drData, 0);
                        dtDataControl.AcceptChanges();
                        vAction = action.Update;
                        break;

                    case action.Update:
                        new Update(DDataControl.Schema.Name).Set(DDataControl.Columns.AliasName).EqualTo(txtAlias.Text).
                        Set(DDataControl.Columns.Description).EqualTo(txtDesc.Text).
                        Set(DDataControl.Columns.DeviceId).EqualTo(Utility.Int32Dbnull(cboDevice.SelectedValue, -1)).
                        Where(DDataControl.Columns.DataControlId).IsEqualTo(Utility.Int32Dbnull(txtID.Text, -1)).Execute();
                        ApplyData2Datarow();
                        drData.AcceptChanges();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }