コード例 #1
0
        public static Penjualan FindOneByKode(string kode)
        {
            Database.OpenConnection();
            string select = String.Concat("SELECT * FROM ", nama_tabel, " WHERE kode = @kode");

            Sql.MySqlDataAdapter da = new Sql.MySqlDataAdapter();

            da.SelectCommand = new Sql.MySqlCommand(select, Database.conn);
            da.SelectCommand.Parameters.AddWithValue("@kode", kode);

            Sql.MySqlCommandBuilder cb = new Sql.MySqlCommandBuilder(da);
            DataSet ds = new DataSet();

            da.Fill(ds);
            Database.CloseConnection();

            Penjualan penjualan = new Penjualan();

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow dr = ds.Tables[0].Rows[0];
                penjualan.setId(Convert.ToInt32(dr["id"]));
                penjualan.setKode(dr["kode"].ToString());
                penjualan.setCustomer(Customer.FindOneById(Convert.ToInt16(dr["id_customer"])));
                penjualan.setCreatedAt(Convert.ToDateTime(dr["created_at"]));
                penjualan.setUpdatedAt(Convert.ToDateTime(dr["updated_at"]));

                return(penjualan);
            }
            return(null);
        }
コード例 #2
0
        public static PenjualanDetail FindOneById(int id)
        {
            Database.OpenConnection();
            string select = String.Concat("SELECT * FROM ", nama_tabel, " WHERE id = @id");

            Sql.MySqlDataAdapter da = new Sql.MySqlDataAdapter();

            da.SelectCommand = new Sql.MySqlCommand(select, Database.conn);
            da.SelectCommand.Parameters.AddWithValue("@id", id);

            Sql.MySqlCommandBuilder cb = new Sql.MySqlCommandBuilder(da);
            DataSet ds = new DataSet();

            da.Fill(ds);
            Database.CloseConnection();

            PenjualanDetail penjualanDetail = new PenjualanDetail();

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow dr = ds.Tables[0].Rows[0];
                penjualanDetail.setId(Convert.ToInt32(dr["id"]));
                penjualanDetail.setBarang(Barang.FindOneById(Convert.ToInt32(dr["id_barang"])));
                penjualanDetail.setPenjualan(Penjualan.FindOneById(Convert.ToInt32(dr["id_penjualan"])));
                penjualanDetail.setKuantitas(Convert.ToInt32(dr["kuantitas"]));
                penjualanDetail.setHargaBarang(Convert.ToDecimal(dr["harga_barang"]));
                penjualanDetail.setCreatedAt(Convert.ToDateTime(dr["created_at"]));
                penjualanDetail.setUpdatedAt(Convert.ToDateTime(dr["updated_at"]));

                return(penjualanDetail);
            }

            return(null);
        }
コード例 #3
0
 public PenjualanDetail setPenjualan(Penjualan penjualan)
 {
     this.penjualan = penjualan;
     return(this);
 }