Example #1
0
File: ASPDac.cs Project: ue96/ue96
        public int InsertShipArea(ShipAreaInfo oParam)
        {
            string sql = @"INSERT INTO ShipType_Area_Un
                            (
                            ShipTypeSysNo, AreaSysNo
                            )
                            VALUES (
                            @ShipTypeSysNo, @AreaSysNo
                            );
                            set @SysNo = SCOPE_IDENTITY();";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int, 4);
            SqlParameter paramShipTypeSysNo = new SqlParameter("@ShipTypeSysNo", SqlDbType.Int, 4);
            SqlParameter paramAreaSysNo = new SqlParameter("@AreaSysNo", SqlDbType.Int, 4);

            paramSysNo.Direction = ParameterDirection.Output;

            paramShipTypeSysNo.Value = oParam.ShipTypeSysNo;
            paramAreaSysNo.Value = oParam.AreaSysNo;

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramShipTypeSysNo);
            cmd.Parameters.Add(paramAreaSysNo);

            return SqlHelper.ExecuteNonQuery(cmd, out oParam.SysNo);
        }
Example #2
0
 private void Map(ShipAreaInfo oParam, DataRow tempdr)
 {
     oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]);
     oParam.ShipTypeSysNo = Util.TrimIntNull(tempdr["ShipTypeSysNo"]);
     oParam.AreaSysNo = Util.TrimIntNull(tempdr["AreaSysNo"]);
 }
Example #3
0
 public void InitShipAreaUn()
 {
     lock (shipAreaLock)
     {
         shipAreaHash.Clear();
         string sql = "select * from shiptype_area_un";
         DataSet ds = SqlHelper.ExecuteDataSet(sql);
         if (!Util.HasMoreRow(ds))
             return;
         foreach (DataRow dr in ds.Tables[0].Rows)
         {
             ShipAreaInfo item = new ShipAreaInfo();
             Map(item, dr);
             shipAreaHash.Add(item.SysNo, item);
         }
     }
 }
Example #4
0
        public int InsertShipAreaUn(ShipAreaInfo oParam)
        {
            string sql = "select * from shiptype_area_un where ShipTypeSysNo = " + oParam.ShipTypeSysNo + " and AreaSysNo = " + oParam.AreaSysNo;
            DataSet ds = SqlHelper.ExecuteDataSet(sql);
            if (Util.HasMoreRow(ds))
                throw new BizException("this Area" + oParam.AreaSysNo + " shiptype_area_un record exists");

            int result = new ASPDac().InsertShipArea(oParam);
            SyncManager.GetInstance().SetDbLastVersion((int)AppEnum.Sync.ASP);

            if (shipAreaHash == null)
                shipAreaHash = new Hashtable(10);
            shipAreaHash.Add(oParam.SysNo, oParam);
            return result;
        }
Example #5
0
        public void ImportShipAreaUn()
        {
            if (!AppConfig.IsImportable)
                throw new BizException("Is Importable is false");

            /*  do not  use the following code after Data Pour in */
            string sql = @"select * from ShipType_Area_Un";
            DataSet ds = SqlHelper.ExecuteDataSet(sql);
            if (Util.HasMoreRow(ds))
                throw new BizException("the table ShipType_Area is not empty");

            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {

                string sql1 = @"select shiptype_convert.newsysno as ShipTypeSysNo, area_convert.newsysno as AreaSysNo from
                            ipp2003..area_ship as Old,
                            ippconvert..area as area_convert,
                            ippconvert..shiptype as shiptype_convert
                            where
                            Old.ShipTypeSysNo = shiptype_convert.oldsysno
                            and Old.AreaSysNo = area_convert.oldsysno";
                DataSet ds1 = SqlHelper.ExecuteDataSet(sql1);
                foreach (DataRow dr1 in ds1.Tables[0].Rows)
                {
                    ShipAreaInfo oShipArea = new ShipAreaInfo();

                    oShipArea.ShipTypeSysNo = Util.TrimIntNull(dr1["ShipTypeSysNo"]);
                    oShipArea.AreaSysNo = Util.TrimIntNull(dr1["AreaSysNo"]);

                    this.InsertShipAreaUn(oShipArea);

                }
                scope.Complete();
            }
        }