コード例 #1
0
        public ID Save(AddBranch oAddBranch)
        {
            bool _isBranchExist = false;

            try
            {
                if (oAddBranch.IsNew)
                {
                    string QueryString = "SELECT * FROM tbl_Branchs WHERE brn_title='" + oAddBranch.brn_title + "'";
                    _isBranchExist = ExecuteQueryFunctions.ExeIsExist(QueryString);
                    if (!_isBranchExist)
                    {
                        BusinessObject.Factory.SetID(oAddBranch, new ID(ExecuteQueryFunctions.GetNewID(_conn, "SELECT MAX(brn_id) FROM tbl_Branchs")));
                        string QueryString2 = "INSERT INTO tbl_Branchs (brn_id,brn_type,brn_title,brn_location,DBUserID,DBSDT)"
                                              + "VALUES(" +
                                              oAddBranch.ObjectID + "," +
                                              (int)oAddBranch.ebrn_type + ",'" +
                                              oAddBranch.brn_title + "','" +
                                              oAddBranch.brn_location + "'," +
                                              EMSGlobal._nCurrentUserID + ",'" +
                                              DateTime.Now + "')";
                        ExecuteQueryFunctions.ExeNonQuery(_conn, QueryString2);
                    }
                    else
                    {
                        throw new ServiceException("This Title Already Exist.");
                    }
                }

                BusinessObject.Factory.SetObjectState(oAddBranch, ObjectState.Saved);
            }
            catch (Exception e)
            {
                throw new ServiceException(e.Message, e);
            }
            return(oAddBranch.ID);
        }