コード例 #1
0
        /// <summary>
        /// Hàm insert Loại xét nghiệm
        /// </summary>
        /// <param name="pitems"></param>
        /// <returns></returns>
        public static string InsertTestTypeList(TTestTypeList pitems)
        {
            int   i       = 0;
            Query queryRs = TTestTypeList.CreateQuery();

            try
            {
                if (
                    !TTestTypeList.FetchByParameter(TTestTypeList.Columns.TestTypeId, Comparison.Equals,
                                                    pitems.TestTypeId).Read())
                {
                    pitems.IsNew = true;
                    pitems.Save(i);
                    return(queryRs.GetMax(TTestTypeList.Columns.TestTypeId).ToString());
                }
                else
                {
                    return("-1");
                    //throw new Exception(string.Format("Name:{0} Đã tồn tại", pitems.IPAddress));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
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 TTestTypeList();
                        obj.TestTypeName = Utility.sDbnull(txtName.Text);
                        obj.IntOrder     = Utility.ByteDbnull(txtSequence.Value);
                        obj.Abbreviation = Utility.sDbnull(txtAbbreviation.Text);
                        obj.Note         = Utility.sDbnull(txtDesc.Text);
                        obj.Price        = Utility.DecimaltoDbnull(txtPrice.Value);
                        obj.PrintDetail  = Utility.ByteDbnull(ckbPrintDetail.Checked ? 1 : 0);
                        obj.IsNew        = true;
                        obj.Save();

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

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

                    case action.Update:
                        new Update(TTestTypeList.Schema.Name).Set(TTestTypeList.Columns.TestTypeName).EqualTo(
                            txtName.Text).
                        Set(TTestTypeList.Columns.IntOrder).EqualTo(txtSequence.Value).
                        Set(TTestTypeList.Columns.Abbreviation).EqualTo(txtAbbreviation.Text).
                        Set(TTestTypeList.Columns.Note).EqualTo(txtDesc.Text).
                        Set(TTestTypeList.Columns.Price).EqualTo(txtPrice.Value).
                        Set(TTestTypeList.Columns.PrintDetail).EqualTo(
                            Utility.ByteDbnull(ckbPrintDetail.Checked ? 1 : 0)).
                        Where(TTestTypeList.Columns.TestTypeId).IsEqualTo(Utility.Int32Dbnull(txtID.Text)).
                        Execute();
                        ApplyData2Datarow();
                        drList.AcceptChanges();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }