コード例 #1
0
ファイル: ContCardDal.cs プロジェクト: AGYSolution/GateOUT
 private void MappingDataReaderToContCard(NpgsqlDataReader npgsqlDataReader, ContCard contCard)
 {
     contCard.ContCardID = npgsqlDataReader.GetInt64(npgsqlDataReader.GetOrdinal("contcardid"));
     contCard.CardMode   = npgsqlDataReader.GetString(npgsqlDataReader.GetOrdinal("cardmode"));
     contCard.RefID      = npgsqlDataReader.GetInt64(npgsqlDataReader.GetOrdinal("refid"));
     contCard.Cont       = npgsqlDataReader.GetString(npgsqlDataReader.GetOrdinal("cont"));
     contCard.Size       = npgsqlDataReader.GetString(npgsqlDataReader.GetOrdinal("size"));
     contCard.Type       = npgsqlDataReader.GetString(npgsqlDataReader.GetOrdinal("type"));
     if (npgsqlDataReader["dtm1"] != DBNull.Value)
     {
         contCard.Dtm1 = npgsqlDataReader.GetDateTime(npgsqlDataReader.GetOrdinal("dtm1")).ToString();
     }
     contCard.Loc1 = npgsqlDataReader.GetString(npgsqlDataReader.GetOrdinal("loc1"));
     if (npgsqlDataReader["dtm2"] != DBNull.Value)
     {
         contCard.Dtm2 = npgsqlDataReader.GetDateTime(npgsqlDataReader.GetOrdinal("dtm2")).ToString();
     }
     contCard.Loc2   = npgsqlDataReader.GetString(npgsqlDataReader.GetOrdinal("loc2"));
     contCard.Remark = npgsqlDataReader.GetString(npgsqlDataReader.GetOrdinal("remark"));
     if (npgsqlDataReader["dtm3"] != DBNull.Value)
     {
         contCard.Dtm3 = npgsqlDataReader.GetDateTime(npgsqlDataReader.GetOrdinal("dtm3")).ToString();
     }
     contCard.ContInOutID = npgsqlDataReader.GetInt64(npgsqlDataReader.GetOrdinal("continoutid"));
     contCard.UserID3     = npgsqlDataReader.GetString(npgsqlDataReader.GetOrdinal("userid3"));
     contCard.Seal1       = npgsqlDataReader.GetString(npgsqlDataReader.GetOrdinal("seal1"));
     contCard.Seal2       = npgsqlDataReader.GetString(npgsqlDataReader.GetOrdinal("seal2"));
     contCard.Seal3       = npgsqlDataReader.GetString(npgsqlDataReader.GetOrdinal("seal3"));
     contCard.Seal4       = npgsqlDataReader.GetString(npgsqlDataReader.GetOrdinal("seal4"));
     contCard.NoMobilOut  = npgsqlDataReader.GetString(npgsqlDataReader.GetOrdinal("nomobilout"));
     contCard.AngkutanOut = npgsqlDataReader.GetString(npgsqlDataReader.GetOrdinal("angkutanout"));
     contCard.Token       = npgsqlDataReader.GetString(npgsqlDataReader.GetOrdinal("token"));
     contCard.IsCombo     = npgsqlDataReader.GetBoolean(npgsqlDataReader.GetOrdinal("iscombo"));
 }
コード例 #2
0
        public InOutRevenue FillInOutRevenueByContCard(ContCard contCard)
        {
            InOutRevenue inOutRevenue    = new InOutRevenue();
            string       columnCondition = string.Empty;

            switch (contCard.CardMode)
            {
            case "IN":
                columnCondition = "r.refid";
                break;

            case "OUT":
                columnCondition = "r.inoutrevenueid";
                break;

            default:
                return(inOutRevenue);
            }
            string query = string.Format("SELECT {0} " +
                                         " FROM {1} {2} " +
                                         " WHERE {3} " +
                                         "   (SELECT refid FROM contcard WHERE contcardid = @ContCardId) AND noseri like 'K%' " +
                                         " ORDER BY r.inoutrevenueid, r.noseri",
                                         string.Format(DEFAULT_COLUMN, "r"),
                                         DEFAULT_TABLE,
                                         "r",
                                         columnCondition);

            try
            {
                using (NpgsqlConnection npgsqlConnection = AppConfig.GetConnection())
                {
                    if (npgsqlConnection.State == ConnectionState.Closed)
                    {
                        npgsqlConnection.Open();
                    }

                    using (NpgsqlCommand npgsqlCommand = new NpgsqlCommand(query, npgsqlConnection))
                    {
                        npgsqlCommand.Parameters.AddWithValue("@ContCardId", contCard.ContCardID);
                        using (NpgsqlDataReader npgsqlDataReader = npgsqlCommand.ExecuteReader())
                        {
                            if (npgsqlDataReader.Read())
                            {
                                MappingDataReaderToInOutRevenue(npgsqlDataReader, inOutRevenue);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(inOutRevenue);
        }
コード例 #3
0
ファイル: ContCardDal.cs プロジェクト: AGYSolution/GateOUT
        public ContCard CheckKendaraan(long contCardID)
        {
            ContCard contCard = null;

            try
            {
                using (NpgsqlConnection npgsqlConnection = AppConfig.GetConnection())
                {
                    if (npgsqlConnection.State == ConnectionState.Closed)
                    {
                        npgsqlConnection.Open();
                    }
                    string query = string.Format("SELECT {0} FROM {1} WHERE contcardid=@ContCardId ",
                                                 string.Format(DEFAULT_COLUMN, string.Empty),
                                                 DEFAULT_TABLE);
                    using (NpgsqlCommand npgsqlCommand = new NpgsqlCommand(query, npgsqlConnection))
                    {
                        npgsqlCommand.Parameters.AddWithValue("@ContCardId", contCardID);
                        using (NpgsqlDataReader npgsqlDataReader = npgsqlCommand.ExecuteReader())
                        {
                            if (npgsqlDataReader.Read())
                            {
                                contCard = new ContCard();
                                MappingDataReaderToContCard(npgsqlDataReader, contCard);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(contCard);
        }