Exemplo n.º 1
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 LStandardTest();
                        obj.TestDataId   = Utility.sDbnull(txtID.Text, "NONE");
                        obj.DataName     = Utility.sDbnull(txtName.Text, "NONE");
                        obj.DataSequence = Utility.Int32Dbnull(txtSequence.Value, 0);
                        obj.TestTypeId   = Utility.Int32Dbnull(cboTestType.SelectedValue, -1);
                        obj.MeasureUnit  = Utility.sDbnull(txtMeasureUnit.Text);
                        obj.NormalLevel  = Utility.sDbnull(txtNormalLevel.Text);
                        obj.NormalLevelW = Utility.sDbnull(txtNormalLevelW.Text);
                        obj.DataPoint    = (short)Utility.Int32Dbnull(txtDataPoint.Value, 0);
                        obj.DataView     = ckbDataView.Checked;
                        obj.DataPrint    = ckbDataPrint.Checked;
                        obj.Description  = Utility.sDbnull(txtDesc.Text);
                        obj.IsNew        = true;
                        obj.Save();

                        drData = dtTestDataList.NewRow();
                        ApplyData2Datarow();
                        dtTestDataList.Rows.InsertAt(drData, 0);
                        dtTestDataList.AcceptChanges();
                        txtID.Enabled = false;
                        vAction       = action.Update;
                        break;

                    case action.Update:
                        new Update(LStandardTest.Schema.Name).Set(LStandardTest.Columns.TestDataId).EqualTo(txtID.Text).
                        Set(LStandardTest.Columns.DataName).EqualTo(txtName.Text).
                        Set(LStandardTest.Columns.DataSequence).EqualTo(txtSequence.Text).
                        Set(LStandardTest.Columns.TestTypeId).EqualTo(Utility.Int32Dbnull(cboTestType.SelectedValue, -1)).
                        Set(LStandardTest.Columns.MeasureUnit).EqualTo(txtMeasureUnit.Text).
                        Set(LStandardTest.Columns.NormalLevel).EqualTo(txtNormalLevel.Text).
                        Set(LStandardTest.Columns.NormalLevelW).EqualTo(txtNormalLevelW.Text).
                        Set(LStandardTest.Columns.DataPoint).EqualTo(txtDataPoint.Text).
                        Set(LStandardTest.Columns.DataView).EqualTo(ckbDataView.Checked).
                        Set(LStandardTest.Columns.DataPrint).EqualTo(ckbDataPrint.Checked).
                        Set(LStandardTest.Columns.Description).EqualTo(txtDesc.Text).
                        Where(LStandardTest.Columns.TestDataId).IsEqualTo(txtID.Text).Execute();
                        ApplyData2Datarow();
                        drData.AcceptChanges();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
 private void frmQuickReorderTestSequence_FormClosing(object sender, FormClosingEventArgs e)
 {
     for (int i = 0; i < dtDataControl.Rows.Count; i++)
     {
         var item = new LStandardTest(dtDataControl.Rows[i]["TestData_ID"]);
         item.DataSequence = i + 1;
         item.IsNew        = false;
         item.Save();
     }
 }
Exemplo n.º 3
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 LStandardTest();
                            obj.TestDataId = Utility.sDbnull(txtID.Text, "NONE");
                            obj.DataName = Utility.sDbnull(txtName.Text, "NONE");
                            obj.DataSequence = Utility.Int32Dbnull(txtSequence.Value, 0);
                            obj.TestTypeId = Utility.Int32Dbnull(cboTestType.SelectedValue, -1);
                            obj.MeasureUnit = Utility.sDbnull(txtMeasureUnit.Text);
                            obj.NormalLevel = Utility.sDbnull(txtNormalLevel.Text);
                            obj.NormalLevelW = Utility.sDbnull(txtNormalLevelW.Text);
                            obj.DataPoint = (short)Utility.Int32Dbnull(txtDataPoint.Value,0);
                            obj.DataView = ckbDataView.Checked;
                            obj.DataPrint = ckbDataPrint.Checked;
                            obj.Description = Utility.sDbnull(txtDesc.Text);
                            obj.IsNew = true;
                            obj.Save();

                            drData = dtTestDataList.NewRow();
                            ApplyData2Datarow();
                            dtTestDataList.Rows.InsertAt(drData, 0);
                            dtTestDataList.AcceptChanges();
                            txtID.Enabled = false;
                            vAction=action.Update;
                            break;
                        case action.Update:
                            new Update(LStandardTest.Schema.Name).Set(LStandardTest.Columns.TestDataId).EqualTo(txtID.Text).
                                Set(LStandardTest.Columns.DataName).EqualTo(txtName.Text).
                                Set(LStandardTest.Columns.DataSequence).EqualTo(txtSequence.Text).
                                Set(LStandardTest.Columns.TestTypeId).EqualTo(Utility.Int32Dbnull(cboTestType.SelectedValue, -1)).
                                Set(LStandardTest.Columns.MeasureUnit).EqualTo(txtMeasureUnit.Text).
                                Set(LStandardTest.Columns.NormalLevel).EqualTo(txtNormalLevel.Text).
                                Set(LStandardTest.Columns.NormalLevelW).EqualTo(txtNormalLevelW.Text).
                                Set(LStandardTest.Columns.DataPoint).EqualTo(txtDataPoint.Text).
                                Set(LStandardTest.Columns.DataView).EqualTo(ckbDataView.Checked).
                                Set(LStandardTest.Columns.DataPrint).EqualTo(ckbDataPrint.Checked).
                                Set(LStandardTest.Columns.Description).EqualTo(txtDesc.Text).
                                Where(LStandardTest.Columns.TestDataId).IsEqualTo(txtID.Text).Execute();
                            ApplyData2Datarow();
                            drData.AcceptChanges();
                            break;
                    }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
Exemplo n.º 4
0
        private bool ValidData()
        {
            try
            {
                if (string.IsNullOrEmpty(txtID.Text))
                {
                    Utility.ShowMsg("Tên không hợp lệ");
                    txtName.Focus();
                    return(false);
                }
                else if (vAction != action.Update && LStandardTest.FetchByID(txtID.Text) != null)
                {
                    Utility.ShowMsg(string.Format("Đã tồn tại mã {0}", txtID.Text));
                    txtID.Focus();
                    txtID.SelectAll();
                    return(false);
                }

                if (string.IsNullOrEmpty(txtName.Text))
                {
                    Utility.ShowMsg("Tên không hợp lệ");
                    txtName.Focus();
                    return(false);
                }
                else
                {
                    int count =
                        new Select().From(LStandardTest.Schema.Name).
                        Where(LStandardTest.Columns.TestTypeId).IsEqualTo(Utility.Int32Dbnull(cboTestType.SelectedValue, -1)).
                        And(LStandardTest.Columns.DataName).IsEqualTo(txtName.Text).
                        And(LStandardTest.Columns.TestDataId).IsNotEqualTo(txtID.Text).
                        ExecuteDataSet().Tables[0].Rows.Count;
                    if (count > 0)
                    {
                        Utility.ShowMsg(cboTestType.Text + " đã có " + txtName.Text);
                        txtName.Focus();
                        txtName.SelectAll();
                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
                return(false);
            }
        }
 private void frmQuickReorderTestSequence_FormClosing(object sender, FormClosingEventArgs e)
 {
     for (int i = 0; i < dtDataControl.Rows.Count; i++)
     {
         var item = new LStandardTest(dtDataControl.Rows[i]["TestData_ID"]);
         item.DataSequence = i + 1;
         item.IsNew = false;
         item.Save();
     }
 }
Exemplo n.º 6
0
        public void Insert(string TestDataId,int TestTypeId,int? DataSequence,string DataName,string MeasureUnit,short DataPoint,string NormalLevel,string NormalLevelW,bool? DataView,bool? DataPrint,string Description,string ReportDesc)
        {
            LStandardTest item = new LStandardTest();

            item.TestDataId = TestDataId;

            item.TestTypeId = TestTypeId;

            item.DataSequence = DataSequence;

            item.DataName = DataName;

            item.MeasureUnit = MeasureUnit;

            item.DataPoint = DataPoint;

            item.NormalLevel = NormalLevel;

            item.NormalLevelW = NormalLevelW;

            item.DataView = DataView;

            item.DataPrint = DataPrint;

            item.Description = Description;

            item.ReportDesc = ReportDesc;

            item.Save(UserName);
        }