コード例 #1
0
        private CRMCustomerType GetSaveEntity()
        {
            var entity = new CRMCustomerType();

            if (string.IsNullOrEmpty(txtCustTypeID.Text.Trim()) == false)
            {
                entity.CustTypeID = int.Parse(txtCustTypeID.Text.Trim());
            }
            if (string.IsNullOrEmpty(txtCustType.Text.Trim()) == false)
            {
                entity.CustType = txtCustType.Text.Trim();
            }
            return(entity);
        }
コード例 #2
0
        //---------------保存CRMCustomerType---------------------------
        public CRMCustomerType Save(CRMCustomerType entity)
        {
            if (this.dataCtx.Connection != null)
            {
                if (this.dataCtx.Connection.State == ConnectionState.Closed)
                {
                    this.dataCtx.Connection.Open();
                }
            }
            DbTransaction tran = this.dataCtx.Connection.BeginTransaction();

            dataCtx.Transaction = tran;

            try
            {
                var qry = from t in CRMCustomerTypes
                          where t.CustTypeID == entity.CustTypeID
                          select t;
                var obj = qry.SingleOrDefault();
                if (obj != null)
                {
                    this.CopyEntity(obj, entity);
                }
                else
                {
                    this.CRMCustomerTypes.InsertOnSubmit(entity);
                }

                this.dataCtx.SubmitChanges();
                tran.Commit();
                return(entity);
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw ex;
            }
            finally
            {
                dataCtx.Connection.Close();
            }
        }
コード例 #3
0
 private CRMCustomerType GetSaveEntity()
 {
     var entity = new CRMCustomerType();
     if (string.IsNullOrEmpty(txtCustTypeID.Text.Trim()) == false)
         entity.CustTypeID = int.Parse(txtCustTypeID.Text.Trim());
     if (string.IsNullOrEmpty(txtCustType.Text.Trim()) == false)
         entity.CustType = txtCustType.Text.Trim();
     return entity;
 }
コード例 #4
0
        //---------------保存CRMCustomerType---------------------------
        public CRMCustomerType Save(CRMCustomerType entity)
        {
            if (this.dataCtx.Connection != null)
                if (this.dataCtx.Connection.State == ConnectionState.Closed)
                    this.dataCtx.Connection.Open();
            DbTransaction tran = this.dataCtx.Connection.BeginTransaction();
            dataCtx.Transaction = tran;

            try
            {
                var qry = from t in CRMCustomerTypes
                          where t.CustTypeID == entity.CustTypeID
                          select t;
                var obj = qry.SingleOrDefault();
                if (obj != null)
                    this.CopyEntity(obj, entity);
                else
                    this.CRMCustomerTypes.InsertOnSubmit(entity);

                this.dataCtx.SubmitChanges();
                tran.Commit();
                return entity;
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw ex;
            }
            finally
            {
                dataCtx.Connection.Close();
            }
        }